List of usage examples for org.openqa.selenium.interactions Actions doubleClick
public Actions doubleClick(WebElement target)
From source file:cc.kune.selenium.SeleniumUtils.java
License:GNU Affero Public License
/** * Double click.//from w ww . ja v a 2 s . c o m * * @param webdriver * the webdriver * @param element * the element */ public static void doubleClick(final WebDriver webdriver, final WebElement element) { SeleniumUtils.moveMouseTo(webdriver, element); sleep(300); SeleniumUtils.hightlight(element, webdriver); final Actions builder = new Actions(webdriver); final Action doubleClick = builder.doubleClick(element).build(); doubleClick.perform(); }
From source file:com.atanas.kanchev.testframework.selenium.handlers.Interact.java
License:Apache License
/** * {@inheritDoc}// w ww. j a v a 2 s . c o m */ @Override public Interact doubleClick() { if (((SeleniumContext) context().getCurrentContext()).getCurrentElement() != null) { logger.debug("Double Clicking Element"); Actions actions = new Actions(((SeleniumContext<WebDriver>) context().getCurrentContext()).getDriver()); actions.doubleClick(((SeleniumContext) context().getCurrentContext()).getCurrentElement()).perform(); } else { logger.error("doubleClick() : Element is Null"); } return this; }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void doubleClick(String locator) { WebElement element = elementToBeClickable(locator); Actions action = new Actions(webDriver); try {//from w w w.j a v a 2s .c o m action.doubleClick(element); action.perform(); } catch (Exception e) { log.warn("Could not double click : " + e); } }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
public String getVersion(Enum<Modules> portal) { String response = null;/*from ww w.j a va 2 s . c o m*/ try { if (portal == Modules.CONSUMER_MENU) { WebElement html = driver.findElement(By.tagName("html")); Assert.assertTrue("The page is not displayed.", html != null); String selectAll = Keys.chord(Keys.CONTROL, Keys.SHIFT, "v"); html.sendKeys(selectAll); Alert alertVersion = driver.switchTo().alert(); response = alertVersion.getText().split(":")[1]; alertVersion.accept(); } else if (portal == Modules.MOBILE_PORTAL) { WebElement element = driver.findElement(By.xpath("//div[contains(@class, 'site-version')]")); Actions actions = new Actions(driver); Action doubleClick = actions.doubleClick(element).build(); doubleClick.perform(); Alert alertVersion = driver.switchTo().alert(); response = alertVersion.getText(); alertVersion.accept(); } } catch (Exception e) { e.printStackTrace(); response = null; } return response; }
From source file:com.epam.jdi.uitests.mobile.appium.elements.base.Element.java
License:Open Source License
public void doubleClick() { invoker.doJAction("Double click on Element", () -> { Actions builder = new Actions(getDriver()); builder.doubleClick(getWebElement()).perform(); });/*from ww w . j av a 2s .c o m*/ }
From source file:com.epam.jdi.uitests.web.selenium.elements.base.Element.java
License:Open Source License
public void doubleClicks() { invoker.doJAction("Double click on Element", () -> { Actions builder = new Actions(getDriver()); builder.doubleClick(getWebElement()).perform(); });//from w w w.j a v a2 s .c o m }
From source file:com.example.selenium.action.DoubleClick.java
@Test public void testDoubleClick() throws Exception { WebElement element = driver.findElement(By.id("div")); // Verify color is Blue Assert.assertEquals("rgba(0, 0, 255, 1)", element.getCssValue("background-color")); Thread.sleep(2000);//from w w w. j a v a 2s. c om Actions builder = new Actions(driver); builder.doubleClick(element).perform(); Thread.sleep(2000); //Verify Color is Yellow Assert.assertEquals("rgba(255, 255, 0, 1)", element.getCssValue("background-color")); }
From source file:com.gargoylesoftware.htmlunit.html.ClickableElement2Test.java
License:Apache License
/** * @throws Exception if the test fails/*from w w w.j a va 2 s .co m*/ */ @Test @Alerts("click click dblclick ") @BuggyWebDriver({ FF, CHROME }) 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")); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * FF behaves is different./* w w w . j a va 2 s.co m*/ * @throws Exception if an error occurs */ @Test @Alerts(IE = "click href click doubleClick ", CHROME = "click href click href doubleClick ", FF = "click href click doubleClick href ") @BuggyWebDriver({ FF, CHROME }) @NotYetImplemented({ FF, IE }) 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")); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.event.UIEventTest.java
License:Apache License
/** * @throws Exception if an error occurs/* w w w . ja va 2 s . com*/ */ @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++]); }