Example usage for org.openqa.selenium By linkText

List of usage examples for org.openqa.selenium By linkText

Introduction

In this page you can find the example usage for org.openqa.selenium By linkText.

Prototype

public static By linkText(String linkText) 

Source Link

Usage

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_Advice() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Advicepage advicepage = new Advicepage();

        System.out.println(lnk_TopNav.getText());

        if ("Advice".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();/*from  w w  w  .  j ava 2s.  c  om*/

            fetchnClick.ClickTopNavLinks(we);

            advicepage.validateAdvicepageTitle();

            advicepage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_Buy() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Buypage buypage = new Buypage();

        System.out.println(lnk_TopNav.getText());

        if ("Buy".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();//www.  j  a  v  a  2  s.  c om

            fetchnClick.ClickTopNavLinks(we);

            buypage.validateBuypageTitle();

            buypage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_Rent() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Rentpage rentpage = new Rentpage();

        System.out.println(lnk_TopNav.getText());

        if ("Rent".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();//from w  ww . j a  va2 s  .  c  om

            fetchnClick.ClickTopNavLinks(we);

            rentpage.validateRentpageTitle();

            rentpage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_NewHomes() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        NewHomespage newHomespage = new NewHomespage();

        System.out.println(lnk_TopNav.getText());

        if ("New Homes".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();//ww  w.ja va2 s.com

            fetchnClick.ClickTopNavLinks(we);

            newHomespage.validateNewHomespageTitle();

            newHomespage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_Sold() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Soldpage soldpage = new Soldpage();

        System.out.println(lnk_TopNav.getText());

        if ("Sold".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();//from w  w  w  . j av  a  2 s  . c  om

            fetchnClick.ClickTopNavLinks(we);

            soldpage.validateSoldpageTitle();

            soldpage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_Commercial() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Commercialpage commercialpage = new Commercialpage();

        System.out.println(lnk_TopNav.getText());

        if ("Commercial".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();/*from   w  ww .ja  v a2 s. c  o  m*/

            fetchnClick.ClickTopNavLinks(we);

            commercialpage.validateCommercialpageTitle();

            commercialpage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_News() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Newspage newspage = new Newspage();

        System.out.println(lnk_TopNav.getText());

        if ("News".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();//from   w  w  w. j  av  a  2 s. c  om

            fetchnClick.ClickTopNavLinks(we);

            newspage.validateNewspageTitle();

            newspage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thomas.domain.testcases.VerifyTopNavlnks.java

@Test
public void VerifyTopNavlnks_Agents() throws IOException, InterruptedException {

    FetchnClick fetchnClick = new FetchnClick(driver);

    List<String> links = fetchnClick.FetchTopNavLinks();

    for (String we : links) {

        WebElement lnk_TopNav = driver.findElement(By.linkText(we));

        Agentspage agentspage = new Agentspage();

        System.out.println(lnk_TopNav.getText());

        if ("Agents".equals(lnk_TopNav.getText())) {

            lnk_TopNav.click();/*from  ww  w  .  j  a  v  a2  s . c  om*/

            fetchnClick.ClickTopNavLinks(we);

            agentspage.validateAgentspageTitle();

            agentspage.VerifyAllLinks(driver);

            fetchnClick.NavBack();

            fetchnClick.pageLoadWait(5);

        } else {

            fetchnClick.pageLoadWait(1);

        }
    }
}

From source file:com.thoughtworks.twistexamples.ofbiztest.AdvancedSearch.java

public void performSearch() throws Exception {
    browser.findElements(By.linkText("Find")).get(0).click();

}

From source file:com.ts.commons.TSPageFactory.TSAnnotations.java

License:Apache License

protected By buildByFromLongFindBy(FindBy findBy) {
    How how = findBy.how();//from  w ww .j a v  a2 s .c  o  m
    String using = findBy.using();

    switch (how) {
    case CLASS_NAME:
        return (By) By.className(using);

    case CSS:
        return (By) By.cssSelector(using);

    case ID:
        return (By) By.id(using);

    case ID_OR_NAME:
        return (By) ((org.openqa.selenium.By) new ByIdOrName(using));

    case LINK_TEXT:
        return (By) By.linkText(using);

    case NAME:
        return (By) By.name(using);

    case PARTIAL_LINK_TEXT:
        return (By) By.partialLinkText(using);

    case TAG_NAME:
        return (By) By.tagName(using);

    case XPATH:
        return (By) By.xpath(using);

    default:
        // Note that this shouldn't happen (eg, the above matches all
        // possible values for the How enum)
        throw new IllegalArgumentException("Cannot determine how to locate element " + field);
    }
}