Example usage for org.openqa.selenium.interactions Actions doubleClick

List of usage examples for org.openqa.selenium.interactions Actions doubleClick

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions Actions doubleClick.

Prototype

public Actions doubleClick(WebElement target) 

Source Link

Document

Performs a double-click at middle of the given element.

Usage

From source file:org.cerberus.service.webdriver.impl.WebDriverService.java

License:Open Source License

@Override
public MessageEvent doSeleniumActionDoubleClick(Session session, Identifier identifier,
        boolean waitForVisibility, boolean waitForClickability) {
    MessageEvent message;/*from w ww  .ja  v  a  2  s  .c  om*/
    try {
        AnswerItem answer = this.getSeleniumElement(session, identifier, waitForVisibility,
                waitForClickability);
        if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
            WebElement webElement = (WebElement) answer.getItem();
            if (webElement != null) {
                Actions actions = new Actions(session.getDriver());
                actions.doubleClick(webElement);
                actions.build().perform();
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_DOUBLECLICK);
                message.setDescription(message.getDescription().replace("%ELEMENT%",
                        identifier.getIdentifier() + "=" + identifier.getLocator()));
                return message;
            }
        }
        message = answer.getResultMessage();
        return message;
    } catch (NoSuchElementException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK_NO_SUCH_ELEMENT);
        message.setDescription(message.getDescription().replace("%ELEMENT%",
                identifier.getIdentifier() + "=" + identifier.getLocator()));
        MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString());
        return message;
    } catch (TimeoutException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_TIMEOUT);
        message.setDescription(message.getDescription().replace("%TIMEOUT%",
                String.valueOf(session.getCerberus_selenium_wait_element())));
        MyLogger.log(WebDriverService.class.getName(), Level.WARN, exception.toString());
        return message;
    } catch (WebDriverException exception) {
        MyLogger.log(WebDriverService.class.getName(), Level.FATAL, exception.toString());
        return parseWebDriverException(exception);
    }
}

From source file:org.cerberus.serviceEngine.impl.SeleniumService.java

License:Open Source License

@Override
public MessageEvent doSeleniumActionDoubleClick(Selenium selenium, String html, String property) {
    MessageEvent message;/*from  w w  w  . j  a  v  a 2s  .co m*/
    try {
        Actions actions = new Actions(selenium.getDriver());
        if (!StringUtil.isNull(property)) {
            try {
                actions.doubleClick(this.getSeleniumElement(selenium, property, true));
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_DOUBLECLICK);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", property));
                return message;
            } catch (NoSuchElementException exception) {
                message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK_NO_SUCH_ELEMENT);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", property));
                MyLogger.log(SeleniumService.class.getName(), Level.ERROR, exception.toString());
                return message;
            }
        } else if (!StringUtil.isNull(html)) {
            try {
                actions.doubleClick(this.getSeleniumElement(selenium, html, true));
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_DOUBLECLICK);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", html));
                return message;
            } catch (NoSuchElementException exception) {
                message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK_NO_SUCH_ELEMENT);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", property));
                MyLogger.log(SeleniumService.class.getName(), Level.ERROR, exception.toString());
                return message;
            }
        }
    } catch (WebDriverException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);
        MyLogger.log(SeleniumService.class.getName(), Level.FATAL, exception.toString());
        return message;
    }
    return new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK);
}

From source file:org.cerberus.serviceEngine.impl.WebDriverService.java

License:Open Source License

@Override
public MessageEvent doSeleniumActionDoubleClick(Session session, String html, String property) {
    MessageEvent message;// w  w  w  . ja  va 2s. c om
    try {
        Actions actions = new Actions(session.getDriver());
        if (!StringUtil.isNull(property)) {
            try {
                WebElement element = this.getSeleniumElement(session, property, true, true);
                actions.doubleClick(element);
                actions.build().perform();
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_DOUBLECLICK);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", property));
                return message;
            } catch (NoSuchElementException exception) {
                message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK_NO_SUCH_ELEMENT);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", property));
                MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString());
                return message;
            }
        } else if (!StringUtil.isNull(html)) {
            try {
                WebElement element = this.getSeleniumElement(session, html, true, true);
                actions.doubleClick(element);
                actions.build().perform();
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_DOUBLECLICK);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", html));
                return message;
            } catch (NoSuchElementException exception) {
                message = new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK_NO_SUCH_ELEMENT);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%", html));
                MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString());
                return message;
            }
        }
    } catch (WebDriverException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);
        MyLogger.log(WebDriverService.class.getName(), Level.FATAL, exception.toString());
        return message;
    }
    return new MessageEvent(MessageEventEnum.ACTION_FAILED_DOUBLECLICK);
}

From source file:org.eclipse.che.ide.ext.datasource.itests.NewDatasourceWizard.java

License:Open Source License

public String clickOnHostedDatabaseCategory() {
    WebElement category = newDatasourceWizard.getHostedDatabaseCategoryElement();
    Actions action = new Actions(driver);
    action.doubleClick(category);
    action.perform();/*from   ww  w.  ja va 2s . c  o m*/
    return "unfolds";
}

From source file:org.eclipse.che.ide.ext.datasource.itests.NewDatasourceWizard.java

License:Open Source License

public String clickOnGoogleCategory() {
    WebElement category = newDatasourceWizard.getGoogleCategoryElement();
    Actions action = new Actions(driver);
    action.doubleClick(category);
    action.perform();/*from   w w  w .  j a v  a  2  s  . c  o m*/
    return "unfolds";
}

From source file:org.eclipse.che.ide.ext.datasource.itests.NewDatasourceWizard.java

License:Open Source License

public String clickOnAmazonCategory() {
    WebElement category = newDatasourceWizard.getAmazonCategoryElement();
    Actions action = new Actions(driver);
    action.doubleClick(category);
    action.perform();/*from   w w  w  . ja  v a2s.  co m*/
    return "unfolds";
}

From source file:org.eclipse.che.selenium.pageobject.ProjectExplorer.java

License:Open Source License

/**
 * Opens an item with specified {@code path} in the project explorer
 *
 * @param path item's path in format: 'Test/src/pom.xml'
 *///  ww w . j  av a2  s.  com
public void openItemByPath(String path) {
    Actions action = seleniumWebDriverHelper.getAction();

    seleniumWebDriverHelper.waitNoExceptions(() -> {
        waitAndSelectItem(path);
        waitItemIsSelected(path);
    }, (EXPECTED_MESS_IN_CONSOLE_SEC + ELEMENT_TIMEOUT_SEC) * 2, NoSuchElementException.class,
            TimeoutException.class);

    seleniumWebDriverHelper.waitNoExceptions(() -> {
        action.doubleClick(waitAndGetItem(path)).perform();
    }, LOAD_PAGE_TIMEOUT_SEC, StaleElementReferenceException.class);

    loader.waitOnClosed();
}

From source file:org.finra.jtaf.ewd.widget.element.InteractiveElement.java

License:Apache License

@Override
public void doubleClick() throws WidgetException {
    try {//from  w w  w  .j  ava 2s.co  m
        Actions builder = new Actions(getGUIDriver().getWrappedDriver());
        synchronized (InteractiveElement.class) {
            getGUIDriver().focus();
            builder.doubleClick(getWebElement()).build().perform();
        }
    } catch (Exception e) {
        throw new WidgetException("Error while double clicking element", getLocator(), e);
    }
}

From source file:org.safs.selenium.webdriver.lib.Tree.java

License:Open Source License

/**
 * @param fullnode// w w w .  java2 s . c  o m
 * @param isSelect
 * @throws SeleniumPlusException
 * @deprecated merged to the implementation of AbstractTreeSelectable, see DefaultSelectable_Tree
 */
private void node(String fullnode, boolean isSelect) throws SeleniumPlusException {

    StringTokenizer st = new StringTokenizer(fullnode, GuiObjectRecognition.DEFAULT_PATH_SEPARATOR);
    String node = null;
    while (st.hasMoreElements()) {
        node = (String) st.nextElement();
        WebElement item = null;
        try {
            item = SearchObject.getObject(webelement,
                    SearchObject.SEARCH_CRITERIA_TEXT + SearchObject.assignSeparator + node);

            if (item == null) {
                throw new SeleniumPlusException(node + " node not found" + "(text=" + node + ")");
            }

            if (isSelect) {
                if (st.countTokens() == 0) {
                    item.click();
                    break;
                }
            }
            if (item.getAttribute(ATTRIBUTE_ARIA_EXPANDED).equals("false")) {
                Actions action = new Actions(SearchObject.getWebDriver());
                Action doubleClick = action.doubleClick(item).build();
                doubleClick.perform();
                try {
                    Thread.sleep(500); //slowdown,correct way?
                } catch (InterruptedException e) {
                    // never happen ?
                }
            }
        } catch (SeleniumPlusException spe) {
            throw spe;
        } catch (Exception msee) {
            throw new SeleniumPlusException("Click action failed on node " + node);
        }
    }
}

From source file:org.testeditor.fixture.web.WebFixture.java

License:Open Source License

/**
 * Double clicks on a element or button. <br />
 * <br />//from w w  w  .  j a va2 s .  c o m
 * 
 * FitNesse usage..: |double click;|arg1|[arg2, arg3, ...]| <br />
 * FitNesse example: |double click;|ButtonInRow{0}Col{1}|[5, 3]| <br />
 * <br />
 * 
 * @param elementListKey
 *            key to find the technical locator
 * @param replaceArgs
 *            values to replace the place holders in the element list entry
 *            with
 * @return true if click was successful; otherwise false
 */
public boolean doubleClick(String elementListKey, String... replaceArgs) {
    boolean result = false;

    WebElement element = findWebelement(elementListKey, replaceArgs);

    if (element != null && element.isDisplayed()) {
        Actions action = new Actions(webDriver);
        action.doubleClick(element).build().perform();
        result = true;
    }

    return result;
}