List of usage examples for org.openqa.selenium WebDriver findElement
@Override WebElement findElement(By by);
From source file:com.formkiq.web.SeleniumTestBase.java
License:Apache License
/** * Wait for Page Text./*from ww w . ja v a2 s . c o m*/ * @param by {@link By} * @param className {@link String} */ protected void waitUntilClassName(final By by, final String className) { waitUntil(new Predicate<WebDriver>() { @Override public boolean apply(final WebDriver d) { return d.findElement(by).getAttribute("class").equals(className); } }); }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * testAddWorkflow22().//www . jav a 2s. c o m * add/remove static text * * @throws Exception Exception */ @Test public void testAddWorkflow22() throws Exception { // given ImmutableMap<String, String> values1 = ImmutableMap.of("20", "Sample Label123", "40", "Immediate[immediate]", "25", "Currency"); ImmutableMap<String, String> values2 = ImmutableMap.of("70", "this is sample text"); // when - add step clickAddNewWorkflow(); addBlankForm(); menuDragAndDrop("menu-textbox"); addField(FormJSONFieldType.STATIC_TEXT); editField("1", values1); editField("2", values2); // then assertTrue(getPageSource().contains("this is sample text")); // when - delete field clickDeleteFieldButton("2"); // then waitUntil(new Predicate<WebDriver>() { @Override public boolean apply(final WebDriver d) { return !d.getPageSource().contains("this is sample text"); } }); // when clickDeleteFieldButton("1"); // then waitUntil(new Predicate<WebDriver>() { @Override public boolean apply(final WebDriver d) { try { By by = getBy("button", "data-uuid", "1"); d.findElement(by); return false; } catch (NoSuchElementException e) { return true; } } }); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.ApplicationCreationPage.java
License:Apache License
public ApplicationCreationPage(WebDriver wd) { super(wd);//www . j av a2s . c om logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page SeleniumUtils.waitForElement(wd, "addAppButton", DEFAULT_AJAX_TIMEOUT); if (!wd.findElement(By.tagName("html")).getText().contains("create application")) { throw new IllegalStateException("this is not the new application page"); } logger.debug("you are in application creation page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.EnvironmentCreationPage.java
License:Apache License
public EnvironmentCreationPage(WebDriver wd) throws InterruptedException { super(wd);//from w w w . j a va 2 s . co m logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("page title : " + wd.getTitle()); // assert that we are on the right page create environment SeleniumUtils.waitForElement(wd, "addEnvButton", DEFAULT_AJAX_TIMEOUT); if (!wd.findElement(By.tagName("html")).getText().contains("create environment")) { logger.error( "This should contains 'create environment'" + wd.findElement(By.tagName("html")).getText()); throw new IllegalStateException("this is not the new environment page"); } logger.debug("you are in create environment page"); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.pages.EnvironmentDetailsPageSeleniumImpl.java
License:Apache License
private void assertWeAreInTheRequiredPage(WebDriver wd) { try {//from w w w . j a v a 2 s. c om wd.findElement(By.xpath("//title[contains(.,'orange paas - environment details')]")); } catch (NoSuchElementException e) { logger.error( "you are not in environment details page because current page title does not contain [orange paas - environment details]"); logger.error("current page title is : " + wd.getTitle()); logger.error("current url is : " + wd.getCurrentUrl()); logger.error("current page source is: " + wd.getPageSource()); throw new IllegalStateException("this is not the environment detail page"); } logger.debug("current url is : " + wd.getCurrentUrl()); logger.debug("current page title is : " + wd.getTitle()); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.utils.SeleniumUtils.java
License:Apache License
/*** * Gets an element by name or id//from w w w. j ava 2 s. co m * * @param driver * @param nameOrID * @return */ public static WebElement getByNameOrID(WebDriver driver, String nameOrID) { WebElement element = null; // try getting the element by name try { element = driver.findElement(By.name(nameOrID)); } catch (Exception ex) { } if (null == element) { try { element = driver.findElement(By.id(nameOrID)); } catch (Exception ex) { } } return element; }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.utils.SeleniumUtils.java
License:Apache License
/*** * Gets input type by type/* w w w.j a v a 2s . c o m*/ * * @param driver * @param type * @return */ public static WebElement getInputItemByType(WebDriver driver, String type) { String xpath = "//input[@type='" + type + "']"; return driver.findElement(By.xpath(xpath)); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.utils.SeleniumUtils.java
License:Apache License
public static WebElement getRadioWithIndex(WebDriver driver, String nameOrId, String index) { // String xpath = // "//input[@id='"+nameOrId+"' and @type='radio']["+index.trim()+"]"; String xpath = "//input[@id='" + nameOrId + "' and @type='radio'][1]"; WebElement radio = null;//from ww w .j a v a 2s . c om try { radio = driver.findElement(By.xpath(xpath)); } catch (Exception ex) { } // try with name now // xpath = // "//input[@name='"+nameOrId+"' and @type='radio']["+index.trim()+"]"; xpath = "//input[@name='" + nameOrId + "' and @type='radio']/[2]"; try { radio = driver.findElement(By.xpath(xpath)); } catch (Exception ex) { } return radio; }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.utils.SeleniumUtils.java
License:Apache License
/*** * Gets input type by value// w ww .ja v a 2 s . c om * * @param driver * @param type * @return */ public static WebElement getInputItemByValue(WebDriver driver, String value) { String xpath = "//input[@value='" + value + "']"; return driver.findElement(By.xpath(xpath)); }
From source file:com.francetelecom.clara.cloud.webapp.acceptancetest.utils.SeleniumUtils.java
License:Apache License
/*** * Gets input type by type and value/*from www. j a va2s . co m*/ * * @param driver * @param type * @param value * @return */ public static WebElement getInputItemByTypeAndValue(WebDriver driver, String type, String value) { String xpath = "//input[@type='" + type + "' and @value='" + value + "']"; return driver.findElement(By.xpath(xpath)); }