List of usage examples for org.openqa.selenium.interactions Actions Actions
public Actions(WebDriver driver)
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
@Test public void testSpecialChars() throws Exception { changeArticleText(readFile("Step8.txt")); checkErrorsExist();//from www .j a v a 2s .c o m String articleHandle = getDriver().getWindowHandle(); openVisualEditor(3); switchToEditor(articleHandle); editActionNode(5, "Therapy ", "" + Keys.ARROW_DOWN); editActionNode(6, "Therapy ", "" + Keys.ARROW_DOWN); //editActionNode(6, "Therapy " + Keys.ARROW_DOWN + Keys.ARROW_DOWN, "" + Keys.ARROW_DOWN + Keys.ARROW_DOWN); saveAndSwitchBack(articleHandle); checkNoErrorsExist(); openVisualEditor(3); switchToEditor(articleHandle); setFlowName("BMI-SelectTherapy $`/\\=,!{};:_-"); editStartNode(2, "Mild therapy $`#/\\\\|=,!{};:_-"); editStartNode(3, "Rigorous therapy $`#/\\\\|=,!{};:_-"); addCommentNode(-400, 300, "Here we test a lot of special characters &%$`<#>/\\\\|=,!(){};:_-"); // 11 new Actions(getDriver()).dragAndDropBy(getDriver().findElement(By.id("#node_3")), -100, 0).perform(); connect(getDriver().findElement(By.id("#rule_8")).findElement(By.className("rule_selector")), 11); connect(11, 6); editExitNode(4, "Done $`#/\\|=,!{};:_-"); saveAndSwitchBack(articleHandle); checkErrorsExist(); openVisualEditor(1); switchToEditor(articleHandle); editActionNode(13, "BMI-SelectTh", "" + Keys.ARROW_DOWN); editActionNode(14, "BMI-SelectTh", "" + Keys.ARROW_DOWN + Keys.ARROW_DOWN); editEdge(20, "Done "); editEdge(21, "Done "); saveAndSwitchBack(articleHandle); checkNoErrorsExist(); }
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
private void connect(WebElement source, int targetId, String... text) throws InterruptedException { source.click();/*from w ww . ja v a2 s. c om*/ WebElement arrowTool = getDriver().findElement(By.className("ArrowTool")); WebElement targetNode = getDriver().findElement(By.id("#node_" + targetId)); (new Actions(getDriver())).dragAndDrop(arrowTool, targetNode).perform(); if (text.length > 0) { Select select = new Select(getDriver().findElement(By.cssSelector(".selectedRule select"))); if (text[0].equalsIgnoreCase("formula")) { select.selectByIndex(10); getDriver().findElement(By.cssSelector(".selectedRule textarea")).sendKeys(text[1] + Keys.ENTER); } else { switch (text[0]) { case "[ .. ]": select.selectByValue("8"); break; case "[ .. [": select.selectByValue("9"); break; default: select.selectByVisibleText(text[0].trim()); break; } if (text.length > 1) { List<WebElement> inputs = getDriver().findElements(By.cssSelector(".GuardEditor input")); inputs.get(0).sendKeys(text[1]); if (text.length > 2) { inputs.get(1).sendKeys(text[2] + Keys.ENTER); } else { inputs.get(0).sendKeys(Keys.ENTER); } } } } }
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
protected void clickTool(String markupClass, int nth, String tooltipContains) throws UnsupportedEncodingException { WebElement markup = getDriver().findElements(By.className(markupClass)).get(nth - 1); WebElement toolMenu = markup.findElement(By.className("headerMenu")); WebElement editTool = markup.findElements(By.cssSelector(".markupMenu a.markupMenuItem")).stream() .filter(element -> Strings.containsIgnoreCase(element.getAttribute("title"), tooltipContains)) .findFirst().get();// w w w .j a va2 s . c om if (getDriver() instanceof JavascriptExecutor) { List<WebElement> stickyRows = getDriver().findElements(By.className("sticky")); JavascriptExecutor jse = (JavascriptExecutor) getDriver(); for (WebElement row : stickyRows) { jse.executeScript("arguments[0].style.display = 'none';", row); } } new Actions(getDriver()).moveToElement(toolMenu).moveToElement(editTool).click(editTool).perform(); }
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
private void addNode(int xOffset, int yOffset, By prototypeSelector, By textSelector, String... text) throws InterruptedException { WebElement start = getDriver().findElement(prototypeSelector); new Actions(getDriver()).dragAndDropBy(start, xOffset, yOffset).perform(); Thread.sleep(200);/*from w ww . j av a 2s. c om*/ if (text.length > 0) { String selector = prototypeSelector.toString(); if (selector.contains("start") || selector.contains("snapshot") || selector.contains("exit")) { // for decision nodes, editor opens automatically List<WebElement> nodes = getDriver().findElements(By.cssSelector(".Flowchart > .Node")); WebElement newNode = nodes.get(nodes.size() - 1); new Actions(getDriver()).doubleClick(newNode).perform(); } setNodeAttributes(textSelector, text); } }
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
private void editNode(int nodeId, By textSelector, String... text) throws InterruptedException { new Actions(getDriver()).doubleClick(getDriver().findElement(By.id("#node_" + nodeId))).perform(); setNodeAttributes(textSelector, text); }
From source file:de.knowwe.uitest.KnowWEUITest.java
License:Open Source License
protected void moveMouseTo(By selector) { new Actions(getDriver()).moveToElement(getDriver().findElement(selector)); }
From source file:de.learnlib.alex.data.entities.actions.web.ClickAction.java
License:Apache License
@Override public ExecuteResult execute(WebSiteConnector connector) { final WebElementLocator nodeWithVariables = new WebElementLocator(insertVariableValues(node.getSelector()), node.getType());//from w ww . j a v a 2s. c o m try { final WebElement element = connector.getElement(nodeWithVariables); if (doubleClick) { new Actions(connector.getDriver()).doubleClick(element).build().perform(); } else { element.click(); } LOGGER.info(LoggerMarkers.LEARNER, "Clicked on element '{}' (doubleClick: {}).", nodeWithVariables, doubleClick); return getSuccessOutput(); } catch (NoSuchElementException e) { LOGGER.info(LoggerMarkers.LEARNER, "Could not find element '{}' (doubleClick: {}).", nodeWithVariables, doubleClick); } catch (Exception e) { LOGGER.info(LoggerMarkers.LEARNER, "Failed to click on element '{}' (doubleClick: {}).", nodeWithVariables, doubleClick, e); } return getFailedOutput(); }
From source file:de.learnlib.alex.data.entities.actions.web.MoveMouseAction.java
License:Apache License
@Override protected ExecuteResult execute(WebSiteConnector connector) { final WebElementLocator nodeWithVariables = node == null ? null : new WebElementLocator(insertVariableValues(node.getSelector()), node.getType()); try {//from w w w .j a va 2s . c o m final Actions actions = new Actions(connector.getDriver()); if (nodeWithVariables == null || nodeWithVariables.getSelector().trim().equals("")) { actions.moveByOffset(offsetX, offsetY).build().perform(); LOGGER.info(LoggerMarkers.LEARNER, "Moved the mouse to the position ({}, {}) ", offsetX, offsetY); } else { final WebElement element = connector.getElement(nodeWithVariables); actions.moveToElement(element, offsetX, offsetY).build().perform(); LOGGER.info(LoggerMarkers.LEARNER, "Moved the mouse to the element '{}'", nodeWithVariables); } return getSuccessOutput(); } catch (Exception e) { LOGGER.info(LoggerMarkers.LEARNER, "Could not move the mouse to the element '{}' or the position ({}, {})", nodeWithVariables, offsetX, offsetY); return getFailedOutput(); } }
From source file:dhtml1.Dhtml.java
@Test public void products() throws InterruptedException { Actions action = new Actions(driver); WebElement we = driver//from ww w .j a v a 2 s. c o m .findElement(By.xpath("html/body/div[1]/header/div[1]/div/div/div/div/nav/ul/li[1]/a")); action.moveToElement(we).build().perform(); WebElement we1 = driver .findElement(By.xpath("html/body/div[1]/header/div[1]/div/div/div/div/nav/ul/li[1]/ul/li[3]/a")); action.moveToElement(we1).build().perform(); Thread.sleep(2000); driver.findElement(By.xpath( "html/body/div[1]/header/div[1]/div/div/div/div/nav/ul/li[1]/ul/li[3]/ul/li[6]/ul[2]/li[2]/a")) .click(); driver.findElement(By.xpath("html/body/div[1]/header/div[1]/div/div/div/div/nav/ul/li[4]/a")).click(); driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("kishantejy12@gmail.com"); driver.findElement(By.xpath(".//*[@id='license']")).sendKeys("kishantej"); driver.findElement(By.xpath(".//*[@class='btn-thin-blue']")).click(); String actualtext = driver.findElement(By.xpath(".//*[@class='submit-error m-bottom-30']")).getText(); String expectedurl = "ERROR: Invalid e-mail or license number"; Assert.assertEquals(actualtext, expectedurl); }
From source file:dk.dma.ais.abnormal.web.StatisticDataIT.java
License:Open Source License
private void clickOnACell() throws InterruptedException { zoomIntoHelsinore();/*from ww w. j av a 2 s . c o m*/ waitForCellsToBeDisplayed(); WebElement map = getMap(); Actions actions = new Actions(browser); actions.moveToElement(map, map.getSize().getWidth() / 2, map.getSize().getHeight() / 2); actions.click(); actions.perform(); // Cursor position is exactly in the center of the map browser.findElement(By.id("tab-map")).click(); assertEquals("(5602'05.7\"N, 1238'59.7\"E)", browser.findElement(By.cssSelector("div#cursorpos.useroutput p")).getText()); // Assert statistic data for correct cell displayed final String expectedCellInfo = "Cell id 6249302540 (5602'06.5\"N,1238'53.8\"E) - (5602'00\"N,1239'00.3\"E)"; By actualCellInfoElement = By.cssSelector("div.cell-data-contents > h5"); wait.until(ExpectedConditions.textToBePresentInElement(actualCellInfoElement, expectedCellInfo)); }