List of usage examples for org.openqa.selenium.interactions Actions Actions
public Actions(WebDriver driver)
From source file:com.hack23.cia.systemintegrationtest.UserPageVisit.java
License:Apache License
/** * Instantiates a new user page visit.//from ww w.j av a 2 s .c o m * * @param driver * the driver * @param browser * the browser */ public UserPageVisit(final WebDriver driver, final String browser) { super(); this.driver = driver; this.browser = browser; action = new Actions(driver); }
From source file:com.hotwire.test.steps.search.air.AirSearchModelWebApp.java
License:Open Source License
@Override public void clickOutOfDisambiguationLayer() { AirSearchFragment airSearchFragment = new AirSearchFragment(getWebdriverInstance()); Actions action = new Actions(getWebdriverInstance()); action.moveToElement(airSearchFragment.getFareFinderForm(), 500, 500).click().perform(); }
From source file:com.hotwire.test.steps.search.SearchModelTemplate.java
License:Open Source License
@Override public void pressKeyOnAutocomplete(String keyName, int numberOfClicks) { Actions action = new Actions(getWebdriverInstance()); int i = 0;//from ww w . j av a 2 s. co m while (i < numberOfClicks) { action.sendKeys(Keys.valueOf(keyName)).perform(); i++; } }
From source file:com.hp.test.framework.jelly.PressKeyonBrowserTag.java
@Override public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException { logger.info("Started Execution of PressKeyonBrowserTag"); WebDriver driver = getSelenium();//from w w w . j av a2 s .c o m try { Actions action = new Actions(driver); if (value.contains("+")) { String[] temp = value.split("\\+"); switch (temp[0].toUpperCase()) { case "CONTROL": action.sendKeys(Keys.chord(Keys.CONTROL, temp[1].toLowerCase())).build().perform(); break; case "ALT": action.sendKeys(Keys.chord(Keys.ALT, temp[1].toLowerCase())).build().perform(); break; } } else { action.sendKeys(Keys.valueOf(value)).build().perform(); } } catch (Exception e) { logger.error("Exception in the Pres Key on Browser" + "\n" + e.getMessage()); } logger.info("End of Execution of PressKeyonBrowserTag"); }
From source file:com.ibm.sbt.automation.core.test.pageobjects.VCardResultPage.java
License:Open Source License
/** * This method hovers over the card's attach point and then clicks the hover menu which appears. This should bring up the VCard. * /*from w w w . j a v a2 s .co m*/ * @return True if the ProfileCard appeared, false if not. */ public boolean isProfileCardDisplayable(WebElement cardAttachPoint) { WebDriver driver = getWebDriver(); new Actions(driver).moveToElement(cardAttachPoint).perform(); // hover over the attachpoint to make the semtagmenu appear. WebDriverWait wait = new WebDriverWait(driver, 5); WebElement semtagmenu = wait.until(ExpectedConditions.elementToBeClickable(By.id("semtagmenu"))); // wait until the hover menu is clickable. WebElement semTagHoverMenu = semtagmenu.findElement(By.xpath(".//a")); new Actions(driver).click(semTagHoverMenu).perform(); // click the hovering menu WebElement vCardDiv = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("cardDiv"))); return vCardDiv.isDisplayed(); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Ignore @Test/*w w w . j a v a 2s . c om*/ public void clickMenuIconThenAwayFromMenuIconHidesMenuList() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); // Clicking away from the menu icon should also close the menu menuIconImg.click(); WebElement menuList = driver.findElement(By.tagName("menu-list")); assertTrue("After clicking the menu icon, the menu list is visible", menuList.isDisplayed()); Actions action = new Actions(driver); action.moveToElement(driver.findElement(By.tagName("body")), 0, 0); action.click().build().perform(); assertFalse("After clicking outside the menu icon, the menu list is gone", menuList.isDisplayed()); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void closeMenuOverlayByClickingOutsideOfContent() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();//from w w w . j av a2 s . co m WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Click outside of the content WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement menuContent = menuOverlay.findElement(By.xpath(".//div[@id='menu']")); Actions action = new Actions(driver); action.moveToElement(menuContent, -1, -1); action.click().build().perform(); assertTrue("Clicking outside of the content closes the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 0); }
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickingOnMenuContentDoesNotCloseOverlay() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();// ww w . j a v a2s . c o m WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Click inside of the content WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement menuContent = menuOverlay.findElement(By.xpath(".//div[@id='menu']")); Actions action = new Actions(driver); action.moveToElement(menuContent, 1, 1); action.click().build().perform(); assertTrue("Clicking inside of the content does not close the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 1); }
From source file:com.induscorp.prime.testing.ui.core.objects.DOMObjectValidator.java
License:Open Source License
/** * Copy text into clipboard from the current cursor position. Applicable * only for editable fields i.e textbox, textarea etc. First it will click * on that element and then select all text and copy into clipboard. * /* w ww. java 2 s . c o m*/ * @return */ public void copyTextToClipboard(int numRetries) { try { for (int i = 0; i < 5; i++) { try { WebElement webElem = findElement(numRetries); webElem.click(); Actions webActions = new Actions(browser.getSeleniumWebDriver()); webActions.sendKeys(Keys.CONTROL + "a").sendKeys(Keys.CONTROL + "c"); break; } catch (MoveTargetOutOfBoundsException | ElementNotVisibleException ex) { browser.waitForSeconds(2); } } } catch (Throwable th) { Assert.fail("Failed to copy contents into clipboard. Element '" + domObject.getDisplayName() + "'.", th); } }
From source file:com.induscorp.prime.testing.ui.core.objects.DOMObjectValidator.java
License:Open Source License
/** * Replace the content of the element with the clipboard contents. * Applicable only for editable fields i.e textbox, textarea etc. * /*from w w w. ja va2s . c om*/ * @return */ public void pasteTextFromClipboard(int numRetries) { try { for (int i = 0; i < 5; i++) { try { WebElement webElem = findElement(numRetries); webElem.click(); Actions webActions = new Actions(browser.getSeleniumWebDriver()); webActions.sendKeys(Keys.CONTROL + "a").sendKeys(Keys.CONTROL + "v").build().perform(); break; } catch (MoveTargetOutOfBoundsException | ElementNotVisibleException ex) { browser.waitForSeconds(2); } } } catch (Throwable th) { Assert.fail("Failed to paste clipboard contents into field '" + domObject.getDisplayName() + "'.", th); } }