List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:XKCDNavigationTest.java
License:Open Source License
@Test public void testBlag() { String url = "http://blog.xkcd.com/"; driver.findElement(By.linkText("Blag")).click(); String curr = driver.getCurrentUrl(); assertEquals(url, curr);//from ww w. j ava2s. c om }
From source file:XKCDNavigationTest.java
License:Open Source License
@Test public void testStore() { String url = "http://store.xkcd.com/"; driver.findElement(By.linkText("Store")).click(); String curr = driver.getCurrentUrl(); assertEquals(url, curr);//from ww w. j a va2 s . com }
From source file:XKCDNavigationTest.java
License:Open Source License
@Test public void testAbout() { String url = "http://www.xkcd.com/about/"; driver.findElement(By.linkText("About")).click(); String curr = driver.getCurrentUrl(); assertEquals(url, curr);/* w w w. jav a2s .c om*/ }
From source file:XKCDNavigationTest.java
License:Open Source License
@Test public void testMoreDetails() { String url = "http://www.xkcd.com/license.html"; driver.findElement(By.linkText("More details")).click(); String curr = driver.getCurrentUrl(); assertEquals(url, curr);/*ww w . j a v a 2s. co m*/ }
From source file:WebTestSelenium11.java
public void testTagNameByLinkText() { assertEquals(driver.findElement(By.linkText("RESEARCH")).getTagName(), "a"); }
From source file:ExpiredLicenseSelenium.java
@Test public void testAddLicenseWebDriver() throws Exception { Date now = new java.util.Date(); String ts = new Timestamp(now.getTime()).toString(); String validTill = addDays(now, 15); driver.get(baseUrl + "#/"); driver.findElement(By.linkText("Start licensing process")).click(); driver.findElement(By.id("nameOrganization")).clear(); driver.findElement(By.id("nameOrganization")).sendKeys(ts); driver.findElement(By.id("applicationArea")).clear(); driver.findElement(By.id("applicationArea")).sendKeys("ApplicationAreaTest"); driver.findElement(By.id("nameContact")).clear(); driver.findElement(By.id("nameContact")).sendKeys("NameTest"); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys("email@test"); driver.findElement(By.id("skype")).clear(); driver.findElement(By.id("skype")).sendKeys("SkypeTest"); driver.findElement(By.id("phone")).clear(); driver.findElement(By.id("phone")).sendKeys("PhoneTest"); driver.findElement(By.cssSelector("div.form-group > button.btn.btn-default")).click(); new Select(driver.findElement(By.id("product"))).selectByVisibleText("i-Voting 11.2"); driver.findElement(/*from w ww . jav a2 s. co m*/ By.cssSelector("form[name=\"chooseProductForm\"] > div.form-group > button.btn.btn-default")) .click(); driver.findElement(By.id("validFrom")).clear(); driver.findElement(By.id("validFrom")).sendKeys("1900-01-01"); driver.findElement(By.id("validTill")).clear(); driver.findElement(By.id("validTill")).sendKeys(validTill); driver.findElement(By.id("addLicenseSubmit")).click(); //Check if license is expiring driver.findElement(By.xpath("//div[@id='bs-example-navbar-collapse-1']/ul[2]/li[2]/a/span/i[2]")).click(); //TODO Add a check based on id instead of validFrom/validTill dates List<WebElement> list = driver.findElements(By.xpath("//*[contains(text(),'" + "1900-01-01" + "')]")); Assert.assertTrue("License not found!", list.size() > 0); List<WebElement> list2 = driver.findElements(By.xpath("//*[contains(text(),'" + validTill + "')]")); Assert.assertTrue("License not found!", list2.size() > 0); }
From source file:WebTestSelenium1.java
public void testTagNameByLinkText() { assertEquals(driver.findElement(By.linkText("Future Students")).getTagName(), "a"); }
From source file:LoginScreenGrapheneTest.java
@Test @RunAsClient// w w w. j av a2 s .c om public void ShouldBePosibleToSearchTestowkaAtGoogle() throws InterruptedException { browser.get("http://google.pl"); WebElement searchField = browser.findElement(By.name("q")); searchField.sendKeys("testowka.pl"); WebElement searchButton = browser.findElement(By.id("sblsbb")); searchButton.click(); for (int second = 0;; second++) { if (second >= 60) fail("timeout"); try { if (browser.findElement(By.linkText("Testowka.pl")).isDisplayed()) { break; } } catch (Exception e) { } Thread.sleep(1000); } WebElement linkToTestowka = browser.findElement(By.linkText("Testowka.pl")); linkToTestowka.click(); }
From source file:LoginScreenGrapheneTest.java
@Test @RunAsClient/*from w w w . j av a2 s. c o m*/ public void should_return_sport_news() { browser.get("http://sportowefakty.pl"); WebElement footballLink = browser.findElement(By.linkText("Pika nona")); footballLink.click(); WebElement ekstraklasaLink = browser.findElement(By.linkText("Ekstraklasa")); ekstraklasaLink.click(); System.out.println(); }
From source file:StateContentTest.java
public void testFAQPage(String state) throws InterruptedException { driver.findElement(By.linkText("FAQs")).click(); /*Test "How Long is this course" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[6]/div/h3/span")).click(); Thread.sleep(300);// w w w.j a v a 2s .co m assertEquals(copyMatrix.get(state)[1].trim(), driver.findElement(By.cssSelector("#collapse6 > div.panel-body > p")).getText().trim()); /*Test "Can I start the online version of the AARP Smart Driver course at a computer in one location and continue at another?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[7]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[2].trim(), driver.findElement(By.cssSelector("#collapse7 > div.panel-body > p")).getText().trim()); /*Test "How do I navigate the online course?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[8]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[7].trim(), driver.findElement(By.cssSelector("#collapse8 > div.panel-body")).getText().trim()); /*Test "Is this online version of the AARP Smart Driver course narrated or just text?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[9]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[8].trim(), driver.findElement(By.cssSelector("#collapse9 > div.panel-body > p")).getText().trim()); /*Test "Quizzes and Exams: Will those be recorded and graded? Can I fail the course?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[10]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[9].trim(), driver.findElement(By.cssSelector("#collapse10 > div.panel-body")).getText().trim()); /*Test "What is the cost of the course and how do I pay" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[1]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[13].trim(), driver.findElement(By.cssSelector("#collapse1 > div.panel-body")).getText().trim()); /*Test "Is it safe to send my credit card information over the internet?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[2]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[14].trim(), driver.findElement(By.cssSelector("#collapse2 > div.panel-body")).getText().trim()); /*Test "What information do I need handy for registering?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[4]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[15].trim(), driver.findElement(By.cssSelector("#collapse4 > div.panel-body")).getText().trim()); /*Test "Why does AARP Driver Safety ask for my driver's license number and date of birth when I register for the AARP Smart Driver course?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[5]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[16].trim(), driver.findElement(By.cssSelector("#collapse5 > div.panel-body")).getText().trim()); /*Test "If I can't finish the course or don't wish to continue it, will I be able to receive a refund?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[3]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[17].trim(), driver.findElement(By.cssSelector("#collapse3 > div.panel-body")).getText().trim()); /*Test "System Requirements for taking the AARP Smart Driver course online:" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[13]/div/h3/span")).click(); Thread.sleep(300); driver.findElement(By.cssSelector("span.sys-link")).click(); assertEquals(copyMatrix.get(state)[18].trim(), driver.findElement(By.cssSelector("#collapse13 > div.panel-body")).getText().trim()); /*Test "What happens if I get disconnected?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[11]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[19].trim(), driver.findElement(By.cssSelector("#collapse11 > div.panel-body")).getText().trim()); /*Test "What happens if I have problems while taking the course or the system malfunctions for any reason?" content*/ driver.findElement(By.xpath("//div[@id='accordion']/div[12]/div/h3/span")).click(); Thread.sleep(300); assertEquals(copyMatrix.get(state)[20].trim(), driver.findElement(By.cssSelector("#collapse12 > div.panel-body")).getText().trim()); }