List of usage examples for org.openqa.selenium WebElement findElements
@Override List<WebElement> findElements(By by);
From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java
@Then("^Records should be displayed based on the descending order of the selected column$") public void check_descending_order() { int j;/*from ww w . j a v a 2 s . c om*/ WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); j = getSortDescColumn(allRows, 8); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); for (int i = 2; i < allRows.size(); i++) { int order = temp.toLowerCase() .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase()); Assert.assertTrue(order >= 0); temp = allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); } }
From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java
@Then("^Records should be displayed based on the ascending order of the selected column.$") public void check_ascending_order_of_the_selected_column() { while (true) { try {//ww w.j a v a 2 s .co m WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); int j; j = getSortColumn(allRows, 6); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); checkData(temp, allRows, 2, j); break; } catch (StaleElementReferenceException ex) { System.out.println("element is not attached to the page document"); } } }
From source file:com.easytox.automation.steps.AuditAndUserLogImpl.java
@Then("^Records should be displayed based on the descending order of the selected column.$") public void check_descending_order_of_the_selected_column() { int j;//from w ww . jav a 2 s . co m WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); j = getSortDescColumn(allRows, 6); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); for (int i = 2; i < allRows.size(); i++) { int order = temp.toLowerCase() .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase()); Assert.assertTrue(order >= 0); temp = allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^user should be able to view and select the options from the list and the corresponding (.*) of records should be displayed on the page$") public void check_number_of_records(String number) { WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); int size = table.findElements(By.tagName(ROWS_LOCATOR)).size() - 1; WebElement element = driver.findElement(By.id(PAGINATE_LOCATOR)); List<WebElement> list = element.findElements(By.tagName(LIST_LOCATOR)); if (number.equals(ALL_NUMBER_OF_RECORDS)) { Assert.assertEquals(list.size(), 2); } else {/*from www .j a va 2s. c o m*/ int num = Integer.parseInt(number); if (num <= size) { Assert.assertEquals(num, size); } else { Assert.assertEquals(list.size(), 3); } } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Records should be displayed based on the ascending order of the selected field$") public void check_ascending_order() { try {/* www.j a v a2s.com*/ int j; WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); j = getSortColumn(allRows); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); for (int i = 2; i < allRows.size(); i++) { if (temp.toLowerCase().contains( allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase())) { Assert.assertTrue(true); } else { int order = temp.toLowerCase().compareTo( allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase()); Assert.assertTrue(order <= 0); } } } catch (StaleElementReferenceException ex) { check_ascending_order(); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Records should be displayed based on the descending order of the selected field$") public void check_descending_order() { int j;// w w w.j a va2 s .c o m WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); j = getSortDescColumn(allRows); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); for (int i = 2; i < allRows.size(); i++) { int order = temp.toLowerCase() .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase()); Assert.assertTrue(order >= 0); } }
From source file:com.easytox.automation.steps.LabPhysicianImpl.java
@Then("^User should be able to view and select the options from the list and the corresponding (.*) of records should be displayed on the page$") public void check_number_of_records(String number) { WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); int size = table.findElements(By.tagName(ROWS_LOCATOR)).size() - 1; WebElement element = driver.findElement(By.id(PAGINATE_LOCATOR)); List<WebElement> list = element.findElements(By.tagName(LIST_LOCATOR)); if (number.equals(ALL_NUMBER_OF_RECORDS)) { Assert.assertEquals(list.size(), 2); } else {/*from ww w .j a v a 2 s .c o m*/ int num = Integer.parseInt(number); if (num > size) { Assert.assertEquals(list.size(), 3); } else { Assert.assertEquals(num, size); } } }
From source file:com.easytox.automation.steps.LabPhysicianImpl.java
@Then("^Records should be displayed on the ascending order of the selected field$") public void records_should_be_displayed_on_the_ascending_order() { try {//from www. j a v a 2 s . c o m WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); int j; j = getSortColumn(allRows); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); for (int i = 2; i < allRows.size(); i++) { if (temp.toLowerCase().contains( allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase())) { Assert.assertTrue(true); } else { int order = temp.toLowerCase().compareTo( allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase()); Assert.assertTrue(order <= 0); } } } catch (StaleElementReferenceException ex) { records_should_be_displayed_on_the_ascending_order(); } }
From source file:com.easytox.automation.steps.LabPhysicianImpl.java
@Then("^Records should be displayed on the descendig order of the selected field$") public void records_should_be_displayed_on_the_descending_order() { int j;/* w w w . ja v a2s.co m*/ WebElement table = driver.findElement(By.id(TABLE_LOCATOR)); List<WebElement> allRows = table.findElements(By.tagName(ROWS_LOCATOR)); j = getSortDescColumn(allRows); String temp = allRows.get(1).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText(); for (int i = 2; i < allRows.size(); i++) { int order = temp.toLowerCase() .compareTo(allRows.get(i).findElements(By.xpath(CELLS_LOCATOR)).get(j).getText().toLowerCase()); Assert.assertTrue(order >= 0); } }
From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java
License:Open Source License
private boolean processSelect(String elementType, MethodParameterNode methodParameterNode, String argument) { if (!NodePropertyDefElemType.isSelect(elementType)) { return false; }//from w ww. j av a 2s.co m WebElement webElement = findWebElement(methodParameterNode); if (!isElementOkForInput(webElement)) { reportExceptionUnavailableElement(methodParameterNode); } String tagName = webElement.getTagName(); if (!StringHelper.isEqual(tagName, TAG_SELECT)) { return false; } List<WebElement> allOptions = webElement.findElements(By.tagName(TAG_OPTION)); for (WebElement option : allOptions) { String text = option.getText(); if (StringHelper.isEqual(text, argument)) { option.click(); return true; } } reportException("Option with text: '" + argument + "' not found.", methodParameterNode); return true; }