List of usage examples for org.openqa.selenium WebElement findElements
@Override List<WebElement> findElements(By by);
From source file:dk.dma.ais.abnormal.web.StatisticDataIT.java
License:Open Source License
private void checkStatisticDataDisplayedCorrectlyForClickedCell() { // Check that a tab is shown for each statistic List<WebElement> tabs = browser.findElements(By.cssSelector("div#cell-data-tabs.tabs li")); assertNotNull(tabs);//from w w w . j ava 2 s . c om assertEquals(3, tabs.size()); assertEquals("CourseOverGround", tabs.get(0).getText()); assertEquals("ShipTypeAndSize", tabs.get(1).getText()); assertEquals("SpeedOverGround", tabs.get(2).getText()); // Check course over ground data browser.findElement(By.cssSelector("a#tab-CourseOverGround.ui-tabs-anchor")).click(); WebElement cogTab = browser.findElement(By.cssSelector("div[aria-labelledby=\"tab-CourseOverGround\"]")); List<WebElement> cogTabDivs = cogTab.findElements(By.tagName("div")); assertEquals("Total ship count is 8.", cogTabDivs.get(1).getText()); // Check ship type and size data browser.findElement(By.cssSelector("a#tab-ShipTypeAndSize.ui-tabs-anchor")).click(); WebElement stsTab = browser.findElement(By.cssSelector("div[aria-labelledby=\"tab-ShipTypeAndSize\"]")); List<WebElement> stsTabDivs = stsTab.findElements(By.tagName("div")); assertEquals("Total ship count is 8.", stsTabDivs.get(1).getText()); // Check speed over ground data browser.findElement(By.cssSelector("a#tab-SpeedOverGround.ui-tabs-anchor")).click(); WebElement sogTab = browser.findElement(By.cssSelector("div[aria-labelledby=\"tab-SpeedOverGround\"]")); List<WebElement> sogTabDivs = sogTab.findElements(By.tagName("div")); assertEquals("Total ship count is 8.", sogTabDivs.get(1).getText()); }
From source file:dk.netarkivet.systemtest.functional.HarvestHistoryForDomainPageTest.java
License:Open Source License
private void assertColumnIsSorted(int column, boolean ascending) { List<WebElement> rows = PageHelper.getWebDriver() .findElements(By.xpath("//table[@class='selection_table']/tbody/tr[position()>1]")); String previousValue = null;//from www . j ava 2s . c o m for (WebElement rowElement : rows) { List<WebElement> rowCells = rowElement.findElements(By.xpath("td")); String value = rowCells.get(column).getText(); if (previousValue != null) { if (ascending) { assertTrue(value.compareTo(previousValue) <= 0, value + " should be listed after " + previousValue + " for ascending"); } else { assertTrue(value.compareTo(previousValue) >= 0, value + " should be listed after " + previousValue + " for descending"); } } } }
From source file:dk.netarkivet.systemtest.functional.SelectiveHarvestTest.java
License:Open Source License
/** * Test creates 8 distinct harvest configurations corresponding to two different values for each of 3 * parameters defined in the EAV model (2=8). In addition, there are created 3 configurations using the * same cxml and attribute values as 3 of the previous 8 jobs. So there should be * eight jobs created./* www . j a v a 2 s . c o m*/ */ @Test(groups = { "guitest", "functest" }) public void jobSplittingTest() { final String domainRandomString = RandomStringUtils.random(6, true, true); final String configRandomString = RandomStringUtils.random(6, true, true); final String configName = "newconf_" + configRandomString; List<String> domainList = new ArrayList<String>(); for (int i = 0; i <= 10; i++) { domainList.add("d" + i + "-" + domainRandomString + ".dk"); } createDomainAndConfiguration(domainList.get(0), configName, 10, false, false); createDomainAndConfiguration(domainList.get(1), configName, 10, false, true); createDomainAndConfiguration(domainList.get(2), configName, 10, true, false); createDomainAndConfiguration(domainList.get(3), configName, 10, true, true); createDomainAndConfiguration(domainList.get(4), configName, 20, false, false); createDomainAndConfiguration(domainList.get(5), configName, 20, false, true); createDomainAndConfiguration(domainList.get(6), configName, 20, true, false); createDomainAndConfiguration(domainList.get(7), configName, 20, true, true); //The next three configs are identical to three of the above so they should //not generate new jobs - so only 8 jobs expected. createDomainAndConfiguration(domainList.get(8), configName, 20, true, true); createDomainAndConfiguration(domainList.get(9), configName, 20, true, false); createDomainAndConfiguration(domainList.get(10), configName, 20, false, true); final String harvestName = "splitharvest_" + RandomStringUtils.random(6, true, true); SelectiveHarvestPageHelper.createSelectiveHarvest(harvestName, "", (String[]) domainList.toArray(new String[] {})); SelectiveHarvestPageHelper.editHarvest(harvestName); WebElement table = PageHelper.getWebDriver().findElement(By.className("selection_table")); List<WebElement> selects = table.findElements(By.tagName("select")); for (WebElement select : selects) { Select dropdown = new Select(select); dropdown.selectByVisibleText(configName); } PageHelper.getWebDriver().findElement(By.name("save")).click(); SelectiveHarvestPageHelper.activateHarvest(harvestName); HarvestUtils.waitForJobGeneration(harvestName); List<WebElement> links = PageHelper.getWebDriver().findElements(By.partialLinkText(harvestName)); assertEquals(links.size(), 8, "Expected to generate one job per distinct configuration."); }
From source file:dk.netarkivet.systemtest.functional.SystemOverviewTest.java
License:Open Source License
/** * Test specification: http://netarchive.dk/suite/It23JMXMailCheck . *//*from w ww. ja v a 2 s . c o m*/ @Test(groups = { "guitest", "functest" }) public void generalTest() throws Exception { addDescription("Test specification: http://netarchive.dk/suite/It23JMXMailCheck"); Set<Application> expectedApplicationSet = new HashSet<Application>( Arrays.asList(NASSystemUtil.getApplications())); int numberOfApps = expectedApplicationSet.size(); int MAX_SECONDS_TO_WAIT = 120; int WAIT_INTERVAL = 10; addStep("Goto the Systemstate page and wait for the extected number of applications to appear.", expectedApplicationSet.size() + " should appear within " + MAX_SECONDS_TO_WAIT); for (int waitedSeconds = 0; waitedSeconds <= MAX_SECONDS_TO_WAIT; waitedSeconds = waitedSeconds + WAIT_INTERVAL) { PageHelper.reloadSubPage("Status/Monitor-JMXsummary.jsp"); int numberOfAppsInOverview = retrieveSystemOverviewRows().size(); log.debug(retrieveSystemOverviewRows().size() + "/" + numberOfApps + " apps appeared " + "in " + waitedSeconds + " seconds"); if (numberOfAppsInOverview >= numberOfApps) { break; } Thread.sleep(WAIT_INTERVAL * 1000); } // We need to click the 'Instance id' link to differentiate between // instances of the same application running on the same machine addStep("Click the 'Instance id' link (We need to do this to differentiate between " + "instances of the same application running on the same machine)", "Verify that the the expected applications are running as they should."); driver.findElement(By.linkText("Instance id")).click(); PageHelper.waitForPageToLoad(); Set<Application> displayedApplicationSet = new HashSet<Application>(); Thread.sleep(5000); WebElement table = PageHelper.getWebDriver().findElement(By.id("system_state_table")); List<WebElement> tr_collection = table.findElements(By.tagName("tr")); int rowCounter = 1; for (WebElement row : retrieveSystemOverviewRows()) { List<WebElement> rowCells = row.findElements(By.xpath("td")); String machine = rowCells.get(0).getText(); String application = rowCells.get(1).getText(); String instance_Id = rowCells.get(2).getText(); String channel = rowCells.get(3).getText(); String replica = rowCells.get(4).getText(); log.debug("Checking row " + rowCounter + ", value is: " + machine + ": " + application); rowCounter++; displayedApplicationSet.add(new Application(machine, application, instance_Id, channel, replica)); } NASAssert.assertEquals(expectedApplicationSet, displayedApplicationSet); }
From source file:dk.netarkivet.systemtest.functional.SystemOverviewTest.java
License:Open Source License
/** * Reads and return the rows of the system overview table excluding the headers. * * @return The rows of the system overview table. *//*from ww w .ja va 2s . co m*/ private List<WebElement> retrieveSystemOverviewRows() { WebElement table = PageHelper.getWebDriver().findElement(By.id("system_state_table")); List<WebElement> tr_collection = table.findElements(By.tagName("tr")); tr_collection.remove(0); return tr_collection; }
From source file:dk.netarkivet.systemtest.HarvestUtils.java
License:Open Source License
public static List<WebElement> getRunningJobRow() { PageHelper.gotoPage(PageHelper.MenuPages.RunningJobs); List<WebElement> rows = PageHelper.getWebDriver() .findElements(By.xpath("//table[@class='selection_table']/tbody/tr[position()>1]")); for (WebElement rowElement : rows) { List<WebElement> rowCells = rowElement.findElements(By.xpath("td")); if (rowCells.size() > 1) { if (rowCells.get(1).findElement(By.xpath("Crawler er igang")) != null) { return rowCells; }/* ww w .j a v a2s . c o m*/ } } return null; }
From source file:dk.netarkivet.systemtest.page.DomainConfigurationPageHelper.java
License:Open Source License
public static void gotoConfigurationPage(String domainName, String configurationName) { TestEventManager.getInstance().addStimuli("Updating configuration " + configurationName); DomainWebTestHelper.editDomain(domainName); PageHelper.getWebDriver().findElement(By.linkText("Show unused configurations")).click(); WebElement table = PageHelper.getWebDriver().findElement(By.className("selection_table")); List<WebElement> tr_collection = table.findElements(By.tagName("tr")); for (WebElement webElement : tr_collection) { List<WebElement> rowCells = webElement.findElements(By.xpath("td")); if (rowCells.size() > 0 && // none header rowCells.get(0).getText().contains(configurationName)) { webElement.findElement(By.linkText("Edit")).click(); break; }// w ww . ja v a 2 s . c om } PageHelper.getWebDriver().findElement(By.name(MAX_OBJECTS_FIELD)); // Ensure page is loaded. }
From source file:dk.netarkivet.systemtest.page.SelectiveHarvestPageHelper.java
License:Open Source License
public static void activateHarvest(String name) { TestEventManager.getInstance().addStimuli("Activating harvest " + name); PageHelper.gotoPage(PageHelper.MenuPages.SelectiveHarvests); if (PageHelper.getWebDriver().getPageSource().contains("Show inactive harvest definitions")) { PageHelper.getWebDriver().findElement(By.linkText("Show inactive harvest definitions")).click(); }/* ww w . j a v a 2 s.co m*/ WebElement table = PageHelper.getWebDriver().findElement(By.className("selection_table")); List<WebElement> tr_collection = table.findElements(By.tagName("tr")); for (WebElement webElement : tr_collection) { if (webElement.getText().contains(name)) { webElement.findElement(By.linkText("Activate")).click(); break; } } }
From source file:dk.netarkivet.systemtest.page.SelectiveHarvestPageHelper.java
License:Open Source License
public static void editHarvest(String name) { TestEventManager.getInstance().addStimuli("Activating harvest " + name); PageHelper.gotoPage(PageHelper.MenuPages.SelectiveHarvests); if (PageHelper.getWebDriver().getPageSource().contains("Show inactive harvest definitions")) { PageHelper.getWebDriver().findElement(By.linkText("Show inactive harvest definitions")).click(); }/*from www . j av a 2s. c o m*/ WebElement table = PageHelper.getWebDriver().findElement(By.className("selection_table")); List<WebElement> tr_collection = table.findElements(By.tagName("tr")); for (WebElement webElement : tr_collection) { if (webElement.getText().contains(name)) { webElement.findElement(By.linkText("Edit")).click(); break; } } }