Java Code Examples for org.openqa.selenium.interactions.Actions#doubleClick()

The following examples show how to use org.openqa.selenium.interactions.Actions#doubleClick() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIEventTest.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = {"[object Event]", "undefined", "[object MouseEvent]", "1", "[object MouseEvent]", "2"},
        IE = {"[object Event]", "undefined", "[object PointerEvent]", "0", "[object PointerEvent]", "0"})
public void detail() throws Exception {
    final String html =
          "<html><head><script>\n"
        + "  function alertDetail(e) {\n"
        + "    alert(e);\n"
        + "    alert(e.detail);\n"
        + "  }\n"
        + "</script></head>\n"
        + "<body onload='alertDetail(event)'>\n"
        + "  <div id='a' onclick='alertDetail(event)'>abc</div>\n"
        + "  <div id='b' ondblclick='alertDetail(event)'>xyz</div>\n"
        + "</body></html>";

    final String[] alerts = getExpectedAlerts();
    int i = 0;

    final WebDriver driver = loadPage2(html);
    verifyAlerts(driver, alerts[i++], alerts[i++]);

    driver.findElement(By.id("a")).click();
    verifyAlerts(driver, alerts[i++], alerts[i++]);

    final Actions action = new Actions(driver);
    action.doubleClick(driver.findElement(By.id("b")));
    action.perform();
    verifyAlerts(driver, alerts[i++], alerts[i++]);
}
 
Example 2
Source File: HtmlAnchorTest.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * FF behaves is different.
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = "click href click doubleClick href ",
        IE = "click href click doubleClick ")
@BuggyWebDriver(
        FF = "click doubleClick click href href ",
        FF68 = "click doubleClick click href href ",
        FF60 = "click doubleClick click href href ")
@NotYetImplemented
public void doubleClick() throws Exception {
    final String html =
          "<html>\n"
        + "<body>\n"
        + "  <a id='myAnchor' "
        +       "href=\"javascript:document.getElementById('myTextarea').value+='href ';void(0);\" "
        +       "onClick=\"document.getElementById('myTextarea').value+='click ';\" "
        +       "onDblClick=\"document.getElementById('myTextarea').value+='doubleClick ';\">foo</a>\n"
        + "  <textarea id='myTextarea'></textarea>\n"
        + "</body></html>";

    final WebDriver driver = loadPage2(html);

    final Actions action = new Actions(driver);
    action.doubleClick(driver.findElement(By.id("myAnchor")));
    action.perform();

    assertEquals(getExpectedAlerts()[0], driver.findElement(By.id("myTextarea")).getAttribute("value"));
}
 
Example 3
Source File: ClickableElement2Test.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("click click dblclick ")
public void dblClick() throws Exception {
    final String content = "<html>\n"
        + "<head>\n"
        + "<script>\n"
        + "  function clickMe() {\n"
        + "    document.getElementById('myTextarea').value+='click ';\n"
        + "  }\n"
        + "  function dblClickMe() {\n"
        + "    document.getElementById('myTextarea').value+='dblclick ';\n"
        + "  }\n"
        + "</script>\n"
        + "</head>\n"
        + "<body id='myBody' onclick='clickMe()' ondblclick='dblClickMe()'>\n"
        + "<textarea id='myTextarea'></textarea>\n"
        + "</body></html>";

    final WebDriver driver = loadPage2(content);

    final Actions action = new Actions(driver);
    action.doubleClick(driver.findElement(By.id("myBody")));
    action.perform();

    assertEquals(getExpectedAlerts()[0], driver.findElement(By.id("myTextarea")).getAttribute("value"));
}
 
Example 4
Source File: SeleniumClick.java    From phoenix.webui.framework with Apache License 2.0 4 votes vote down vote up
@Override
public void dbClick(Element ele)
{
	Actions actions = new Actions(engine.getDriver());
	actions.doubleClick(searchStrategyUtils.findStrategy(WebElement.class, ele).search(ele));
}