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:library.functions.CommonFunctions.java

License:Open Source License

public void doubleClick(By by) throws InterruptedException, IOException {
    Thread.sleep(1000);//w  ww.ja  v a  2s.com
    Actions builder = new Actions(getWebDriver());
    try {
        WebElement tagElement = getWebDriver().findElement(by);
        builder.doubleClick(tagElement).perform();
        Thread.sleep(1000);
    } catch (Exception e) {
        takeScreenshot();
    }
}

From source file:omelet.driver.DriverUtility.java

License:Apache License

/***
 * Double click on WebElement using JavaScript or Actions Class
 * //from w w w. ja  v a  2 s.c o  m
 * @param element
 *            :Element on which Double click needs to be performed
 * @param clickStrategy
 *            : double click using javascript or using action class
 * @param driver
 * @author kapilA
 */
public static void doubleClick(WebElement element, WebDriver driver, CLICK_STRATEGY clickStrategy) {

    switch (clickStrategy) {

    case USING_ACTION:
        Actions action = new Actions(driver);
        action.doubleClick(element).perform();
        break;
    case USING_JS:
        ((JavascriptExecutor) driver).executeScript("var evt = document.createEvent('MouseEvents');"
                + "evt.initMouseEvent('dblclick',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);"
                + "arguments[0].dispatchEvent(evt);", element);
        break;
    default:
        String clickStrategyParameter = "";
        try {
            clickStrategyParameter = clickStrategy.toString();
        } catch (Exception e) {
            clickStrategyParameter = "null";
        }
        LOGGER.error("Parameter missmatch: Unknown click strategy. " + clickStrategyParameter);
    }
}

From source file:org.alfresco.po.PageElement.java

License:Open Source License

/**
 * Double click on an element//from  w  w  w . j a  va  2  s. c  o m
 * 
 * @param element {@link WebElement}
 */
public void doubleClickOnElement(WebElement element) {
    PageUtils.checkMandatoryParam("doubleclick element", element);
    Actions builder = new Actions(driver);
    Action doubleClick = builder.doubleClick(element).build();
    doubleClick.perform();
}

From source file:org.apache.zeppelin.integration.ParagraphActionsIT.java

License:Apache License

public void testEditOnDoubleClick() throws Exception {
    try {/*from   w w  w . j  av  a2  s  .  co  m*/
        createNewNote();
        Actions action = new Actions(driver);

        waitForParagraph(1, "READY");

        setTextOfParagraph(1, "%md");
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.ARROW_RIGHT);
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.ENTER);
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(Keys.SHIFT + "3");
        driver.findElement(By.xpath(getParagraphXPath(1) + "//textarea")).sendKeys(" abc");

        runParagraph(1);
        waitForParagraph(1, "FINISHED");

        collector.checkThat("Markdown editor is hidden after run ",
                driver.findElements(By
                        .xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]"))
                        .size(),
                CoreMatchers.equalTo(0));

        collector.checkThat("Markdown editor is shown after run ",
                driver.findElement(By.xpath(
                        getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]"))
                        .isDisplayed(),
                CoreMatchers.equalTo(true));

        // to check if editOnDblClick field is fetched correctly after refresh
        driver.navigate().refresh();
        waitForParagraph(1, "FINISHED");

        action.doubleClick(driver.findElement(By.xpath(getParagraphXPath(1)))).perform();
        ZeppelinITUtils.sleep(1000, false);
        collector.checkThat("Markdown editor is shown after double click ",
                driver.findElement(By
                        .xpath(getParagraphXPath(1) + "//div[contains(@ng-if, 'paragraph.config.editorHide')]"))
                        .isDisplayed(),
                CoreMatchers.equalTo(true));

        collector.checkThat("Markdown editor is hidden after double click ",
                driver.findElement(By.xpath(
                        getParagraphXPath(1) + "//div[contains(@ng-show, 'paragraph.config.tableHide')]"))
                        .isDisplayed(),
                CoreMatchers.equalTo(false));

        deleteTestNotebook(driver);

    } catch (Exception e) {
        handleException("Exception in ParagraphActionsIT while testEditOnDoubleClick ", e);
    }
}

From source file:org.auraframework.components.ui.InputTextUITest.java

License:Apache License

@TargetBrowsers({ BrowserType.GOOGLECHROME })
public void doTestUpdateOnAttributeWithCertainEventsChrome(String url) throws Exception {
    open(url);//from  w w w.  j a v  a 2 s. c om
    String value = getCurrentModelValue();
    WebDriver d = getDriver();
    Actions a = new Actions(d);

    WebElement outputDiv = findDomElement(By.id("output"));

    String eventName = "dblclick";
    WebElement input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value);
    a.doubleClick(input).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mousemove";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value);
    a.moveToElement(input).moveByOffset(0, 100).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseout";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value);
    a.moveToElement(input).moveToElement(outputDiv).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseover";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value);
    outputDiv.click();
    a.moveToElement(input).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseup";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value);
    input.click();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "select";
    input = auraUITestingUtil.findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value);
    a.doubleClick(input).build().perform();
    value = assertModelValue(eventName);
}

From source file:org.auraframework.components.ui.menu.MenuUITest.java

License:Apache License

/**
 * Test case to check double clicking on Menu Trigger link component within 350ms with disableDoubleClicks attribute
 * set disregards the 2nd click. Test case for W-1855568
 * //from  w ww . j  a  v  a  2s .  c o m
 * @throws MalformedURLException
 * @throws URISyntaxException
 */
public void testDoubleClickOnMenuTrigger() throws MalformedURLException, URISyntaxException {
    open(MENUTEST_APP);
    String label = "triggercheckPosition";
    String menuName = "checkPosition";
    WebDriver driver = this.getDriver();
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement menu = driver.findElement(By.className(menuName));
    Actions a = new Actions(driver);
    a.doubleClick(menuLabel).build().perform();
    assertTrue("Check Menu list should be expanded even after double click",
            menu.getAttribute("class").contains("visible"));
}

From source file:org.auraframework.integration.test.components.ui.inputText.InputTextUITest.java

License:Apache License

@TargetBrowsers({ BrowserType.GOOGLECHROME })
public void doTestUpdateOnAttributeWithCertainEventsChrome(String url) throws Exception {
    open(url);//from   w  w w .j a  va2  s  .c o  m
    String value = getCurrentModelValue();
    WebDriver d = getDriver();
    Actions a = new Actions(d);

    WebElement outputDiv = findDomElement(By.id("output"));

    String eventName = "dblclick";
    WebElement input = getAuraUITestingUtil().findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.doubleClick(input).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mousemove";
    input = getAuraUITestingUtil().findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.moveToElement(input).moveByOffset(0, 100).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseout";
    input = getAuraUITestingUtil().findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.moveToElement(input).moveToElement(outputDiv).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseover";
    input = getAuraUITestingUtil().findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    outputDiv.click();
    a.moveToElement(input).build().perform();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "mouseup";
    input = getAuraUITestingUtil().findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    input.click();
    value = assertModelValue(eventName);
    assertDomEventSet();

    eventName = "select";
    input = getAuraUITestingUtil().findElementAndTypeEventNameInIt(eventName);
    assertModelValue(value, "Value shouldn't be updated yet.");
    a.doubleClick(input).build().perform();
    value = assertModelValue(eventName);
}

From source file:org.auraframework.integration.test.components.ui.menu.MenuUITest.java

License:Apache License

/**
 * Test case to check double clicking on Menu Trigger link component within 350ms with disableDoubleClicks attribute
 * set disregards the 2nd click. Test case for W-1855568
 *//*from  www .ja v  a 2 s .c om*/
@Test
public void testDoubleClickOnMenuTrigger() throws Exception {
    open(MENUTEST_APP);
    String label = "doubleClick";
    String menuName = "doubleClickDisabledMenuList";
    WebDriver driver = this.getDriver();
    WebElement menuLabel = driver.findElement(By.className(label));
    WebElement menu = driver.findElement(By.className(menuName));
    Actions a = new Actions(driver);
    a.doubleClick(menuLabel).build().perform();
    waitForMenuOpen(menu);
}

From source file:org.bigtester.ate.model.page.elementaction.DoubleClickAction.java

License:Apache License

/**
  * {@inheritDoc}/*  w w  w  .  ja v a2  s.c  o  m*/
  */
@Override
public void doAction(final WebElement webElm) {
    Actions act = new Actions(getMyWd().getWebDriver());
    act.doubleClick(webElm);
}

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

License:Open Source License

@Override
public MessageEvent doSeleniumActionDoubleClick(Session session, Identifier identifier) {
    MessageEvent message;//from w  w  w  .j a v a  2s  . c om

    try {

        AnswerItem answer = this.getSeleniumElement(session, identifier, true, true);
        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().replaceAll("%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().replaceAll("%ELEMENT%",
                identifier.getIdentifier() + "=" + identifier.getLocator()));
        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;
    }
}