List of usage examples for org.openqa.selenium.interactions Actions Actions
public Actions(WebDriver driver)
From source file:com.cisco.dbds.utils.primewidgets.primewidgetsStepDef.java
License:Open Source License
@Given("^Hover over the tooltip icon and verify tooltip content$") public void hover_over_tooltip_icon_and_verify_content(DataTable table) { for (String label : table.topCells()) { try {/* w w w. j a v a 2s . c o m*/ List<Map<String, String>> map = table.asMaps(String.class, String.class); try { Actions action = new Actions(SeleniumUtilities.getDriver()); action.moveToElement( SeleniumUtilities.findElement(Identifier.XPATH, String.format(IMAGE_ICON, label))) .perform(); } catch (WebDriverException | NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Assert.assertTrue("Page Object not found on VCS Console", false); } SeleniumUtilities.wait(2); String actual_text = primewuipf.TOOLTIP_RIGHT_WE_XPATH.getText().trim(); actual_text = actual_text.replaceAll("\\r|\\n", ""); actual_text = actual_text.trim(); //System.out.println(actual_text); Assert.assertTrue("Actual tooltip " + actual_text + "does not match with expected tooltip " + map.get(0).get(label), actual_text.equals(map.get(0).get(label))); SeleniumUtilities.wait(4); } catch (WebDriverException e) { Assert.assertTrue("Page Object TOOLTIP_RIGHT_WE_XPATH not found on VCS Console", false); } } }
From source file:com.cisco.dbds.utils.primewidgets.primewidgetsStepDef.java
License:Open Source License
@Given("^Hover over the tooltip icon and verify tooltip content \"(.*?)\" for field \"(.*?)\"$") public void hover_over_tooltip_icon_and_verify_content(String tooltip, String label) { //for (String label : table.topCells()) //{//from w w w . j av a 2 s .c o m try { // List<Map<String, String>> map = table // .asMaps(String.class, String.class); try { Actions action = new Actions(SeleniumUtilities.getDriver()); action.moveToElement( SeleniumUtilities.findElement(Identifier.XPATH, String.format(IMAGE_ICON, label))) .perform(); } catch (WebDriverException | NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Assert.assertTrue("Page Object not found on VCS Console", false); } SeleniumUtilities.wait(2); String actual_text = primewuipf.TOOLTIP_RIGHT_WE_XPATH.getText().trim(); actual_text = actual_text.replaceAll("\\r|\\n", ""); actual_text = actual_text.trim(); //System.out.println(actual_text); Assert.assertTrue("Actual tooltip " + actual_text + "does not match with expected tooltip " + tooltip, actual_text.equals(tooltip)); SeleniumUtilities.wait(4); } catch (WebDriverException e) { Assert.assertTrue("Page Object TOOLTIP_RIGHT_WE_XPATH not found on VCS Console", false); } // } }
From source file:com.cisco.dbds.utils.primewidgets.primewidgetsStepDef.java
License:Open Source License
@Given("^Hover over popover icon and verify PopOver title and content \"(.*?)\"$") public void hover_over_popover_icon_and_verify_popover_title_content(String exp_popovercontent, DataTable table) {/*from w ww . j a v a 2 s. c o m*/ LogHandler.info("hover_over_popover_icon_and_verify_popover_title_content(DataTable table)"); List<Map<String, String>> widgetlst = table.asMaps(String.class, String.class); String popover_content; for (Map<String, String> widgetvalue : widgetlst) { try { try { Actions action = new Actions(SeleniumUtilities.getDriver()); action.moveToElement(SeleniumUtilities.findElement(Identifier.XPATH, String.format(IMAGE_ICON, widgetvalue.get("Field")))).perform(); } catch (WebDriverException | NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Assert.assertTrue("Page Object not found on VCS Console", false); } Assert.assertTrue( "Actual popover title " + primewuipf.POPOVER_TITLE_WE_XPATH.getText().trim() + "does not match expected popover title " + widgetvalue.get("PopOverTitle"), primewuipf.POPOVER_TITLE_WE_XPATH.getText().trim().equals(widgetvalue.get("PopOverTitle"))); LogHandler.info("Verified popover title " + widgetvalue.get("PopOverTitle") + "for field" + widgetvalue.get("Field")); popover_content = primewuipf.POPOVER_CONTENT_WE_XPATH.getText().trim(); popover_content = popover_content.replaceAll("\\r|\\n", ""); popover_content = popover_content.trim(); Assert.assertTrue("Actual popover content " + popover_content + "does not match expected popover content " + exp_popovercontent, popover_content.equals(exp_popovercontent)); } catch (WebDriverException e) { Assert.assertTrue("Page Object POPOVER_TITLE_WE_XPATH not found on VCS Console", false); } } }
From source file:com.cisco.dbds.utils.primewidgets.primewidgetsStepDef.java
License:Open Source License
@Given("^Hover over popover icon and verify PopOver title and content$") public void hover_over_popover_icon_and_verify_popover_title_content(DataTable table) { LogHandler.info("hover_over_popover_icon_and_verify_popover_title_content(DataTable table)"); List<Map<String, String>> widgetlst = table.asMaps(String.class, String.class); String popover_content;/* w w w . j a v a 2 s . c o m*/ for (Map<String, String> widgetvalue : widgetlst) { try { try { Actions action = new Actions(SeleniumUtilities.getDriver()); action.moveToElement(SeleniumUtilities.findElement(Identifier.XPATH, String.format(IMAGE_ICON, widgetvalue.get("Field")))).perform(); } catch (WebDriverException | NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Assert.assertTrue("Page Object not found on VCS Console", false); } Assert.assertTrue( "Actual popover title " + primewuipf.POPOVER_TITLE_WE_XPATH.getText().trim() + "does not match expected popover title " + widgetvalue.get("PopOverTitle"), primewuipf.POPOVER_TITLE_WE_XPATH.getText().trim().equals(widgetvalue.get("PopOverTitle"))); LogHandler.info("Verified popover title " + widgetvalue.get("PopOverTitle") + "for field" + widgetvalue.get("Field")); popover_content = primewuipf.POPOVER_CONTENT_WE_XPATH.getText().trim(); popover_content = popover_content.replaceAll("\\r|\\n", ""); popover_content = popover_content.trim(); Assert.assertTrue( "Actual popover content " + popover_content + "does not match expected popover content " + widgetvalue.get("PopOverContent"), popover_content.equals(widgetvalue.get("PopOverContent"))); LogHandler.info("Verified popover content " + widgetvalue.get("PopOverContent") + "for field" + widgetvalue.get("Field")); } catch (WebDriverException e) { Assert.assertTrue("Page Object POPOVER_TITLE_WE_XPATH not found on VCS Console", false); } } }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Scroll.//from ww w . j av a2s. c o m * * @param selectableWebelementforScroll * the selectable webelementfor scroll * @param stepsize * the stepsize */ public static void scroll(WebElement selectableWebelementforScroll, int stepsize) { click(selectableWebelementforScroll); for (int i = 0; i < stepsize; i++) { Actions actionObject = new Actions(driver); actionObject.sendKeys(Keys.ARROW_DOWN).build().perform(); } }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Move to a given WebElement.//from w w w. j a v a2 s .c om * * @param element * the element */ public static void moveToElement(WebElement element) { Actions builder = new Actions(driver); builder.moveToElement(element).build().perform(); }
From source file:com.cloudbees.workflow.ui.AbstractPhantomJSTest.java
License:Open Source License
protected void moveMouseToElement(WebDriver webdriver, WebElement element) { Actions actions = new Actions(webdriver); actions.moveToElement(element).build().perform(); }
From source file:com.cloudbees.workflow.ui.AbstractPhantomJSTest.java
License:Open Source License
protected void clickOnElement(WebDriver webdriver, WebElement element) { Actions actions = new Actions(webdriver); actions.moveToElement(element).click().perform(); }
From source file:com.cloudbees.workflow.ui.AbstractPhantomJSTest.java
License:Open Source License
protected void moveMouseOffElement(WebDriver webdriver) { Actions actions = new Actions(webdriver); actions.moveToElement(webdriver.findElement(By.cssSelector("html"))).build().perform(); }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
public String getVersion(Enum<Modules> portal) { String response = null;/* w w w .j a v a 2s .c om*/ 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; }