List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:dk.netarkivet.systemtest.functional.HarvestHistoryForDomainPageTest.java
License:Open Source License
@Test(priority = 10, groups = { "guitest", "functest", "slow" }) public void historySortedTablePagingTest() throws Exception { addDescription("Tests that sorting is maintained when paging through " + "the harvest history"); addStep("Ensure that at least harvests have finished for the default domain", ""); //Note that this would be more efficient if we ran SelectiveHarvestTest first as there would already be //enough harvest history of pligtaflevering.dk to do this test straight away. HarvestUtils.ensureNumberOfHarvestsForDefaultDomain(3); addStep("Click the 'End time' header link twice", "The table should now be sorted descending according to" + " End time. Remember the full list"); HarvestUtils.gotoHarvestHistoryForDomain(HarvestUtils.DEFAULT_DOMAIN); PageHelper.clickLink(HarvestHistoryPageHelper.END_TIME_HEADER); PageHelper.clickLink(HarvestHistoryPageHelper.END_TIME_HEADER); PageHelper.waitForPageToLoad();// w ww . ja va2 s . c o m List<HarvestHistoryPageHelper.HarvestHistoryEntry> harvestHistory = HarvestHistoryPageHelper .readHarvestHistory(); int PAGE_SIZE = 2; setHarvestStatusPageSize(PAGE_SIZE); addStep("Set the page size to " + PAGE_SIZE, ""); addStep("Goto the harvest history for the default domain", "Only 2 harvests should be listed and the next link should be enabled."); HarvestUtils.gotoHarvestHistoryForDomain(HarvestUtils.DEFAULT_DOMAIN); assertEquals("Didn't find the expected 2 harvests on the first page", PageHelper.getWebDriver() .findElements(By.xpath("//table[@class='selection_table']/tbody/tr[position()>1]")).size(), 2); addStep("Click the 'End time' header link twice", "The table should now again be sorted descending according to End time."); HarvestUtils.gotoHarvestHistoryForDomain(HarvestUtils.DEFAULT_DOMAIN); PageHelper.clickLink(HarvestHistoryPageHelper.END_TIME_HEADER); PageHelper.clickLink(HarvestHistoryPageHelper.END_TIME_HEADER); PageHelper.waitForPageToLoad(); addStep("Click the next link until the next link disappears", "All the pages should have been listed, " + "in the same order as when the full list was show."); int harvestCounter = 0; int numberOfPages = (int) Math.ceil((float) harvestHistory.size() / PAGE_SIZE); for (int pageNumber = 1; pageNumber <= numberOfPages; pageNumber++) { List<WebElement> rows = PageHelper.getWebDriver().findElement(By.className("selection_table")) .findElements(By.tagName("tr")); rows.remove(0); // Skip headers for (int rowNumber = 0; rowNumber < rows.size(); rowNumber++) { WebElement row = rows.get(rowNumber); assertEquals(new HarvestHistoryPageHelper.HarvestHistoryEntry(row), harvestHistory.get(harvestCounter++)); } boolean lastPage = pageNumber == numberOfPages; if (!lastPage) { driver.findElement(By.linkText("next")).click(); PageHelper.waitForPageToLoad(); } else { assertEquals("Not all harvests were found in the pages.", harvestCounter, harvestHistory.size()); assertTrue(driver.findElements(By.linkText("next")).isEmpty()); } } addStep("Click the previous link until the previous link disappears.", "All the pages should have been listed, " + "2 at a time backwards."); for (int pageNumber = numberOfPages; pageNumber >= 1; pageNumber--) { List<WebElement> rows = PageHelper.getWebDriver().findElement(By.className("selection_table")) .findElements(By.tagName("tr")); rows.remove(0); // Skip headers for (int rowNumber = rows.size() - 1; rowNumber >= 0; rowNumber--) { WebElement row = rows.get(rowNumber); assertEquals(new HarvestHistoryPageHelper.HarvestHistoryEntry(row), harvestHistory.get(--harvestCounter)); } boolean firstPage = pageNumber == 1; if (!firstPage) { driver.findElement(By.linkText("previous")).click(); PageHelper.waitForPageToLoad(); } else { assertEquals("Not all harvests where found in the pages.", harvestCounter, 0); assertTrue(driver.findElements(By.linkText("previous")).isEmpty()); } } }
From source file:dk.netarkivet.systemtest.functional.SelectiveHarvestTest.java
License:Open Source License
/** * Test specification: http://netarchive.dk/suite/It23JMXMailCheck . *///from w w w .ja va2 s. c om @Test(groups = { "guitest", "functest" }) public void selectiveHarvestListingTest() throws Exception { addDescription("Verify the functionality of the harvest listings."); addReference("http://netarchive.dk/suite/TEST1"); addStep("Create a selective harvest", "The harvest should be created successfully a be listed in the HD list"); String harvest1ID = createHarverstID(); SelectiveHarvestPageHelper.createSelectiveHarvest(harvest1ID); assertTrue(driver.getPageSource().contains(harvest1ID), harvest1ID + " not found in harvest list after creation"); addStep("Create a second harvest and active it", "The second harvest also be listed in the HD list"); String harvest2ID = createHarverstID(); SelectiveHarvestPageHelper.createSelectiveHarvest(harvest2ID); SelectiveHarvestPageHelper.activateHarvest(harvest2ID); assertTrue(driver.getPageSource().contains(harvest2ID), harvest2ID + " not found in harvest list after creation"); addStep("Hide inactive harvests", "The harvest first harvest should disappear from the HD list, " + "the second should remain"); driver.findElement(By.linkText("Hide inactive harvest definitions")).click(); NASAssert.assertFalse(driver.getPageSource().contains(harvest1ID), "Inactive harvest " + harvest1ID + " show in harvest list after 'hide inactive harvests' was clicked"); assertTrue(driver.getPageSource().contains(harvest2ID), harvest2ID + " not found in harvest list after creation"); addStep("Show inactive harvests", "The harvest first harvest should reappear from the HD list, " + "the second should remain"); driver.findElement(By.linkText("Show inactive harvest definitions")).click(); assertTrue(driver.getPageSource().contains(harvest1ID), "Inactive harvest " + harvest1ID + " show in harvest list after 'hide inactive harvests' was clicked"); assertTrue(driver.getPageSource().contains(harvest2ID), harvest2ID + " not found in harvest list after creation"); }
From source file:dk.netarkivet.systemtest.functional.SelectiveHarvestTest.java
License:Open Source License
/** * In this test we first set the cfg for every known domain to be identical. Then we make changes in * a number of them and check that the right number of jobs is generated. */// w ww. j a va 2 s . c o m @Test(groups = { "guitest", "functest" }) public void snapshotTest() { List<String> editDomainLinks = DomainWebTestHelper.getAllEditDomainLinks(); for (String link : editDomainLinks) { driver.get(link); WebElement editAnchor = driver.findElement(By.id("configuration")).findElement(By.linkText("Edit")); driver.get(editAnchor.getAttribute("href")); Select order_xml = new Select(driver.findElement(By.name("order_xml"))); order_xml.selectByVisibleText("default_orderxml"); driver.findElement(By.name("maxObjects")).clear(); driver.findElement(By.name("maxObjects")).sendKeys("10"); driver.findElement(By.name("maxBytes")).clear(); driver.findElement(By.name("maxBytes")).sendKeys("100000"); DomainConfigurationPageHelper.setMaxHops(10); DomainConfigurationPageHelper.setHonorRobots(true); DomainConfigurationPageHelper.setExtractJavascript(true); DomainConfigurationPageHelper.submitChanges(); } driver.get(editDomainLinks.get(0)); WebElement editAnchor = driver.findElement(By.id("configuration")).findElement(By.linkText("Edit")); driver.get(editAnchor.getAttribute("href")); DomainConfigurationPageHelper.setMaxHops(20); DomainConfigurationPageHelper.submitChanges(); driver.get(editDomainLinks.get(1)); editAnchor = driver.findElement(By.id("configuration")).findElement(By.linkText("Edit")); driver.get(editAnchor.getAttribute("href")); DomainConfigurationPageHelper.setHonorRobots(false); DomainConfigurationPageHelper.submitChanges(); driver.get(editDomainLinks.get(2)); editAnchor = driver.findElement(By.id("configuration")).findElement(By.linkText("Edit")); driver.get(editAnchor.getAttribute("href")); DomainConfigurationPageHelper.setExtractJavascript(false); DomainConfigurationPageHelper.submitChanges(); //So now a snapshot harvest should create four jobs PageHelper.gotoPage(PageHelper.MenuPages.SnapshotHarvests); final String harvestName = "snapshot_" + RandomStringUtils.random(3, true, true); driver.findElement(By.partialLinkText("Create new snapshot harvest definition")).click(); driver.findElement(By.name("harvestname")).sendKeys(harvestName); driver.findElement(By.name("snapshot_byte_limit")).clear(); driver.findElement(By.name("snapshot_byte_limit")).sendKeys("1000000"); driver.findElement(By.name("snapshot_byte_limit")).submit(); driver.findElement(By.cssSelector("input[value=\"" + harvestName + "\"]")).submit(); HarvestUtils.waitForJobGeneration(harvestName); List<WebElement> links = PageHelper.getWebDriver().findElements(By.partialLinkText(harvestName)); assertEquals(links.size(), 4, "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 . *//* w w w .j av a2 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.page.DomainConfigurationPageHelper.java
License:Open Source License
public static void createConfiguration(String domainName, String configurationName) { TestEventManager.getInstance().addStimuli("Creating configuration" + configurationName); WebDriver driver = PageHelper.getWebDriver(); DomainWebTestHelper.editDomain(domainName); driver.findElement(By.linkText(NEW_CONFIGURATION)).click(); driver.findElement(By.name("configName")).sendKeys(configurationName); driver.findElement(By.cssSelector("input[type=\"submit\"]")).click(); }
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; }/*from ww w . j a v a 2 s.co m*/ } PageHelper.getWebDriver().findElement(By.name(MAX_OBJECTS_FIELD)); // Ensure page is loaded. }
From source file:dk.netarkivet.systemtest.page.DomainWebTestHelper.java
License:Open Source License
public static void createSeedList(String domainName, String seedListName, String[] seeds) { TestEventManager.getInstance().addStimuli("Creating configuration" + seedListName + "(" + seeds + ")"); WebDriver driver = PageHelper.getWebDriver(); editDomain(domainName);// ww w . j a v a2 s .c om driver.findElement(By.linkText(NEW_SEED_LIST)).click(); driver.findElement(By.name(SEED_LIST_NAME)).sendKeys(seedListName); driver.findElement(By.name("seedList")).clear(); for (String seed : seeds) { driver.findElement(By.name("seedList")).sendKeys(seed + "\n"); } driver.findElement(By.cssSelector("input[type=\"submit\"]")).click(); }
From source file:dk.netarkivet.systemtest.page.SelectiveHarvestPageHelper.java
License:Open Source License
public static void createSelectiveHarvest(String name, String comments, String... domains) { TestEventManager.getInstance().addStimuli("Creating harvest " + name); WebDriver driver = PageHelper.getWebDriver(); PageHelper.gotoPage(PageHelper.MenuPages.SelectiveHarvests); driver.findElement(By.linkText("Create new selective harvest definition")).click(); driver.findElement(By.name("harvestname")).clear(); driver.findElement(By.name("harvestname")).sendKeys(name); driver.findElement(By.name("comments")).clear(); if (comments != null) { driver.findElement(By.name("comments")).sendKeys(comments); }// ww w. j av a2s .c o m driver.findElement(By.name("domainlist")).clear(); for (String domain : domains) { driver.findElement(By.name("domainlist")).sendKeys(domain + "\n"); } driver.findElement(By.cssSelector("input[type=\"submit\"]")).click(); driver.findElement(By.name("save")).click(); }
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(); }/* w w w . ja v a 2 s . c om*/ 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 ww w. j av a2 s . com*/ 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; } } }