List of usage examples for org.openqa.selenium.interactions Action perform
void perform();
From source file:io.selendroid.webviewdrivertests.touch.TouchScrollTest.java
License:Apache License
@Test public void testCanScrollHorizontallyFromWebElement() { openWebdriverTestPage(HtmlTestData.LONG_CONTENT_PAGE); WebElement link = driver().findElement(By.id("link1")); int x = link.getLocation().x; // The element is located at the right of the page, // so it is not initially visible on the screen. assertTrue("Expected x > 1500, but got x = " + x, x > 1500); WebElement toScroll = driver().findElement(By.id("imagestart")); Action scroll = getBuilder(driver()).scroll(toScroll, -1000, 0).build(); scroll.perform(); x = link.getLocation().x;/*from ww w.j a va2 s.com*/ // After scrolling, the location of the element should change accordingly. assertTrue("Expected x < 3000, but got x = " + x, x < 3000); }
From source file:io.selendroid.webviewdrivertests.touch.TouchScrollTest.java
License:Apache License
@Test public void testCanScrollVertically() { openWebdriverTestPage(HtmlTestData.LONG_CONTENT_PAGE); WebElement link = driver().findElement(By.id("link3")); int y = link.getLocation().y; // The element is located at the right of the page, // so it is not initially visible on the screen. assertTrue(y > 4200);//from w ww.j a v a2 s . c o m Action scrollDown = getBuilder(driver()).scroll(0, 800).build(); scrollDown.perform(); y = link.getLocation().y; // After scrolling, the location of the element should change accordingly. assertTrue(y < 3500); }
From source file:io.selendroid.webviewdrivertests.touch.TouchScrollTest.java
License:Apache License
@Test public void testCanScrollHorizontally() { openWebdriverTestPage(HtmlTestData.LONG_CONTENT_PAGE); WebElement link = driver().findElement(By.id("link1")); int x = link.getLocation().x; // The element is located at the right of the page, // so it is not initially visible on the screen. assertTrue("Expected x > 1500, but got x = " + x, x > 1500); Action scrollDown = getBuilder(driver()).scroll(400, 0).build(); scrollDown.perform(); x = link.getLocation().y;/*ww w . ja va2 s .co m*/ // After scrolling, the location of the element should change accordingly. assertTrue("Expected x < 1500, but got x = " + x, x < 1500); }
From source file:io.selendroid.webviewdrivertests.touch.TouchSingleTapTest.java
License:Apache License
private void singleTapOnElement(String elementId) { WebElement toSingleTap = driver().findElement(By.id(elementId)); Action singleTap = getBuilder(driver()).singleTap(toSingleTap).build(); singleTap.perform(); }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
/** * Drag the source element and drop into target element. * //from w w w. ja v a2 s . c o m * @param source - Source Element * @param target - Target Element */ public void dragAndDrop(WebElement source, WebElement target) { PageUtils.checkMandatoryParam("source element", source); PageUtils.checkMandatoryParam("target element", target); Actions builder = new Actions(driver); Action dragAndDrop = builder.clickAndHold(source).moveToElement(target).release(target).build(); dragAndDrop.perform(); }
From source file:org.alfresco.po.PageElement.java
License:Open Source License
/** * Double click on an element//from w w w .ja v a2 s. c om * * @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.alfresco.po.PageElement.java
License:Open Source License
/** * Drag and drop element by x,y// www . j av a 2 s . co m * @param source html element * @param x coordinate * @param y coordinate */ public void dragAndDrop(WebElement source, int x, int y) { PageUtils.checkMandatoryParam("source element", source); Actions builder = new Actions(driver); Action dragAndDrop = builder.dragAndDropBy(source, x, y).build(); dragAndDrop.perform(); }
From source file:org.auraframework.integration.test.util.WebDriverTestCase.java
License:Apache License
public void flick(WebElement element, int xOffset, int yOffset, int speed) { WebDriver driver = getDriver();// w w w .j av a 2s .c o m // check for wrapped driver if (driver instanceof EventFiringWebDriver) { driver = ((EventFiringWebDriver) driver).getWrappedDriver(); } driver = augmentDriver(); // for iPhone int yOffsetByDevice = yOffset; if (this.getBrowserType() == BrowserType.IPAD) { yOffsetByDevice = yOffset * 2; } if (driver instanceof HasTouchScreen) { Action flick = (new TouchActions(driver)).flick(element, xOffset, yOffsetByDevice, speed).build(); flick.perform(); } else { Action flick = (new Actions(driver)).dragAndDropBy(element, xOffset, yOffsetByDevice).build(); flick.perform(); } }
From source file:org.auraframework.integration.test.util.WebDriverTestCase.java
License:Apache License
public void flick(int xOffset, int yOffset) { WebDriver driver = getDriver();//from w ww .ja v a 2 s . c o m driver = augmentDriver(); // for iPhone int yOffsetByDevice = yOffset; if (this.getBrowserType() == BrowserType.IPAD) { yOffsetByDevice = yOffset * 2; } Action flick = (new TouchActions(driver)).flick(xOffset, yOffsetByDevice).build(); flick.perform(); }
From source file:org.craftercms.web.basic.ComponentTest.java
@Test public void testDragAndDrop() throws InterruptedException { String image = "/requiredImage.png"; // Navigate to About page //driver.navigate().to(seleniumProperties.getProperty("craftercms.base.url") + aboutPage); CStudioSeleniumUtil.navigateToAndWaitForPageToLoad(driver, seleniumProperties.getProperty("craftercms.base.url") + aboutPage); CStudioSeleniumUtil.clickOn(driver, By.cssSelector("#acn-preview-tools-container")); new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() { @Override// w ww.ja va 2 s .c o m public Boolean apply(WebDriver d) { return d.findElement(By.cssSelector("#preview-tools-panel-container")).isDisplayed(); } }); List<WebElement> options = (new WebDriverWait(driver, 10)).until(ExpectedConditions .presenceOfAllElementsLocatedBy(By.cssSelector("#preview-tools-panel-container .contracted"))); options.get(1).click(); new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { return d.findElement(By.id("placeholder-zone-bottomPromos1")).isDisplayed(); } }); WebElement source = driver.findElement(By.id("yui-gen4")); WebElement target = driver.findElement(By.id("bottomPromos1")); Actions builder = new Actions(driver); Action dragAndDrop = builder.dragAndDrop(source, target).build(); dragAndDrop.perform(); WebElement element = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("in-context-edit-editor"))); //Check the modal window assertTrue(element != null); driver.switchTo().frame(element); //Upload an Image CStudioSeleniumUtil.clickOn(driver, By.cssSelector("#image input[value='Add']")); element = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#cstudio-wcm-popup-div"))); //Check the modal window assertTrue(element != null); driver.findElement(By.cssSelector("#uploadFileNameId")).sendKeys(assetsPath + image); driver.findElement(By.cssSelector("#uploadButton")).click(); new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { return !d.findElement(By.cssSelector("#image .datum")).getAttribute("value").isEmpty(); } }); driver.findElement(By.cssSelector("#cstudioSaveAndClose")).click(); driver.switchTo().defaultContent(); }