List of usage examples for org.openqa.selenium WebElement getText
String getText();
From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java
@Then("^'SNlabadmin', 'SPhyOne', 'SPhyTwo', 'labuserone' values should be displayed in the User drop down$") public void check_valid_values_in_user_drop_down() { int i, j, k, m; i = j = k = m = 0;/*from www . j a v a 2 s.c o m*/ if (userOptions != null) { for (WebElement option : userOptions) { String text = option.getText(); switch (text) { case "SNlabadmin": i++; break; case "SPhyOne": j++; break; case "SPhyTwo": k++; break; case "labuserone": m++; break; } } Assert.assertTrue(i > 0); Assert.assertTrue(j > 0); Assert.assertTrue(k > 0); Assert.assertTrue(m > 0); } else { Assert.fail("userOptions is null!"); } }
From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java
@Then("^No other values should be displayed in the User drop down$") public void no_other_values_in_user_drop_down() { if (userOptions != null) { for (WebElement option : userOptions) { String text = option.getText(); if (!text.equals("SNlabadmin") && !text.equals("SPhyOne") && !text.equals("SPhyTwo") && !text.equals("labuserone") && !text.equals("Select User")) { Assert.fail(text + " is other value in User Drop Down"); }//from w w w . j a v a2 s .c o m } } else { Assert.fail("userOptions is null!"); } }
From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java
@Then("^a text message 'Showing x to y of z entries' should be displayed on the bottom left corner of the list$") public void check_message() { WebElement el = MyWebDriverUtils.findElement(driver, MESSAGE_LOCATOR, LocatorType.CSS); if (el != null) { String message = el.getText(); Assert.assertTrue(message.contains("Showing")); Assert.assertTrue(message.contains("to")); Assert.assertTrue(message.contains("of")); Assert.assertTrue(message.contains("entries")); }//from ww w. j a v a2s .co m }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Add Lab Client screen is displayed$") public void add_lab_client_scrren_is_displayed() { WebElement el = MyWebDriverUtils.findPresenceElement(driver, WIDGET_ADD_LOCATOR, LocatorType.CSS); if (el != null) { String title = el.getText(); Assert.assertEquals(title, WIDGET_ADD_VALUE); }// w ww.ja v a 2 s . com WebElement form = MyWebDriverUtils.findPresenceElement(driver, FORM_LOCATOR, LocatorType.ID); if (form != null) { String method = form.getAttribute(FORM_METHOD_ATTRIBUTE); Assert.assertEquals(method, FORM_METHOD_VALUE); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^New lab client is added successfully and newly added lab client is listed in the Lab Client List screen$") public void check_added_lab_client() throws InterruptedException { if (count == 0) { WebElement el = MyWebDriverUtils.findElement(driver, DROP_DOWN_SELECT_LOCATOR, LocatorType.CSS); if (el != null) { new Select(el).selectByVisibleText(DROP_DOWN_ALL_VALUE); }//from w ww . j av a2s. co m } try { count++; final WebElement table = MyWebDriverUtils.findElement(driver, TABLE_LOCATOR, LocatorType.ID); if (table != null) { List<WebElement> listRows = MyWebDriverUtils.findElements(driver, ROWS_LOCATOR, LocatorType.TAG, table); if (listRows != null) { int size = listRows.size(); List<WebElement> listCells = MyWebDriverUtils.findElements(driver, CELL_LOCATOR, LocatorType.TAG, listRows.get(size - 1)); if (listCells != null && listCells.size() == 9) { Assert.assertEquals(listCells.get(2).getText(), CITY_VALUE); Assert.assertEquals(listCells.get(3).getText(), STATE_VALUE); Assert.assertEquals(listCells.get(4).getText(), ZIP_VALUE); Assert.assertEquals(listCells.get(5).getText(), CONTACT_PERSON_VALUE); Assert.assertEquals(listCells.get(6).getText(), CONTACT_NUMBER_REAL_VALUE); Assert.assertEquals(listCells.get(7).getText(), CONTACT_EMAIL_VALUE); } else { throw new StaleElementReferenceException("listCells size is not equal 9"); } } else { Assert.fail("listRows is null!"); } } else { Assert.fail("table is null!"); } } catch (StaleElementReferenceException ex) { check_added_lab_client(); } WebElement el = MyWebDriverUtils.findPresenceElement(driver, SUCCESS_LOCATOR, LocatorType.CSS); if (el != null) { String elValue = el.getText(); Assert.assertEquals(elValue, SUCCESS_VALUE); count = 0; } else { Assert.fail("el is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Following values should be populated: Address - it should populate entered Address lines 1 and 2 Lab - it should populate Lab name$") public void check_populate_fields() { try {/*from w ww.ja v a 2 s . com*/ final WebElement table = MyWebDriverUtils.findElement(driver, TABLE_LOCATOR, LocatorType.ID); if (table != null) { List<WebElement> listRows = MyWebDriverUtils.findElements(driver, ROWS_LOCATOR, LocatorType.TAG, table); if (listRows != null) { int size = listRows.size(); List<WebElement> listCells = MyWebDriverUtils.findElements(driver, CELL_LOCATOR, LocatorType.TAG, listRows.get(size - 1)); if (listCells != null && listCells.size() == 2) { WebElement labCell = listCells.get(1); Assert.assertEquals(labCell.getText(), LAB_CLIENT_VALUE); } else { throw new StaleElementReferenceException("listCells size is not equal 2"); } List<WebElement> addressCells = MyWebDriverUtils.findElements(driver, CELL_LOCATOR, LocatorType.TAG, listRows.get(size - 2)); if (addressCells != null && addressCells.size() == 2) { WebElement addressCell = addressCells.get(1); String[] address = addressCell.getText().split(REGEX); Assert.assertEquals(address[0], ADDRESS_1_VALUE); Assert.assertEquals(address[1], ADDRESS_2_VALUE); } else { throw new StaleElementReferenceException("addressCells size is not equal 2"); } } else { Assert.fail("listRows is null!"); } } else { Assert.fail("table is null!"); } } catch (StaleElementReferenceException ex) { check_populate_fields(); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Update Lab Client screen is displayed$") public void update_lab_client_screen_is_displayed() { WebElement el = MyWebDriverUtils.findPresenceElement(driver, WIDGET_UPDATE_LOCATOR, LocatorType.CSS); if (el != null) { String title = el.getText(); Assert.assertEquals(title, WIDGET_UPDATE_VALUE); }//from ww w . j av a 2 s. c o m WebElement form = MyWebDriverUtils.findPresenceElement(driver, FORM_LOCATOR, LocatorType.ID); if (form != null) { String method = form.getAttribute(FORM_METHOD_ATTRIBUTE); Assert.assertEquals(method, FORM_METHOD_VALUE); } String currentUrl = driver.getCurrentUrl(); Assert.assertEquals(currentUrl, EDIT_LAB_CLIENT_URL); }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Lab client is updated successfully$") public void lab_client_is_updated_successfully() { WebElement el = driver.findElement(By.cssSelector(MESSAGE_LOCATOR)); Assert.assertTrue(el.isDisplayed()); WebElement el1 = MyWebDriverUtils.findPresenceElement(driver, SUCCESS_LOCATOR, LocatorType.CSS); if (el1 != null) { String elValue = el1.getText(); Assert.assertEquals(elValue, SUCCESS_VALUE); } else {// ww w.ja v a 2 s. c o m Assert.fail("el is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Following values should be updated with changed data: Address - it should populate entered Address lines 1 and 2 Lab - it should populate Lab name$") public void check_updated_data() { try {//from ww w . j a v a 2 s.c o m final WebElement table = MyWebDriverUtils.findElement(driver, TABLE_LOCATOR, LocatorType.ID); if (table != null) { List<WebElement> listRows = MyWebDriverUtils.findElements(driver, ROWS_LOCATOR, LocatorType.TAG, table); if (listRows != null) { List<WebElement> listCells = MyWebDriverUtils.findElements(driver, CELL_LOCATOR, LocatorType.TAG, listRows.get(4)); if (listCells != null && listCells.size() == 2) { WebElement labCell = listCells.get(1); Assert.assertEquals(labCell.getText(), LAB_CLIENT_VALUE); } else { throw new StaleElementReferenceException("listCells size is not equal 2"); } List<WebElement> addressCells = MyWebDriverUtils.findElements(driver, CELL_LOCATOR, LocatorType.TAG, listRows.get(3)); if (addressCells != null && addressCells.size() == 2) { WebElement addressCell = addressCells.get(1); String[] address = addressCell.getText().split(REGEX); Assert.assertEquals(address[0], ADDRESS_1_VALUE); Assert.assertEquals(address[1], ADDRESS_2_VALUE); } else { throw new StaleElementReferenceException("addressCells size is not equal 2"); } } else { Assert.fail("listRows is null!"); } } else { Assert.fail("table is null!"); } } catch (StaleElementReferenceException ex) { check_updated_data(); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Add Lab Location' page should be displayed$") public void add_lab_location_page_should_be_displayed() { String currentUrl = driver.getCurrentUrl(); Assert.assertEquals(currentUrl, ADD_LAB_LOCATION_URL); WebElement el = MyWebDriverUtils.findPresenceElement(driver, WIDGET_ADD_LAB_LOCATION_LOCATOR, LocatorType.CSS);// ww w .j av a 2 s . co m if (el != null) { String title = el.getText(); Assert.assertEquals(title, WIDGET_ADD_LAB_LOCATION_VALUE); } }