Example usage for org.openqa.selenium By partialLinkText

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

Introduction

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

Prototype

public static By partialLinkText(String partialLinkText) 

Source Link

Usage

From source file:com.github.mfriedenhagen.phantomjstest.JenkinsHomePage.java

public JobPage gotoJobPage(String name) {
    driver.findElement(By.partialLinkText(name)).click();
    return JobPage.create(driver, name);
}

From source file:com.hotwire.selenium.desktop.paypal.PayPalSandboxPage.java

License:Open Source License

private WebElement getClickHereLink() {
    return getWebDriver().findElement(By.partialLinkText("click here"));
}

From source file:com.hotwire.selenium.desktop.row.HomePage.java

License:Open Source License

public String getTopDestinationUrl(String topDestination) {
    return topDestinations.findElement(By.partialLinkText(topDestination)).getAttribute("href");
}

From source file:com.hotwire.selenium.tools.myAccount.ChoseLocalSiteDropdown.java

License:Open Source License

public void selectCountry(String locale) {
    new WebDriverWait(getWebDriver(), 1)
            .until(ExpectedConditions.presenceOfElementLocated(By.partialLinkText(locale))).click();
}

From source file:com.hotwire.test.steps.account.AccountAccessRowWebApp.java

License:Open Source License

@Override
public void cancelPastPurchase(String tripType, String location, String tripStatus,
        SearchParameters searchParameters) {

    AccountTripsPage tripsPage = new AccountTripsPage(getWebdriverInstance());

    tripsPage.cancelRecentlyBookedTrip(tripType, location, tripStatus,
            (new SimpleDateFormat(TRIP_DATE_FORMAT)).format(searchParameters.getStartDate()),
            (new SimpleDateFormat(TRIP_DATE_FORMAT)).format(searchParameters.getEndDate()));

    getWebdriverInstance().findElement(By.partialLinkText("Yes")).click();
    confirmRecentlyBookedTripDetails(tripType, location, "cancelled", searchParameters);
}

From source file:com.hotwire.test.steps.seo.SeoModelWebApp.java

License:Open Source License

@Override
public void getDestinationLinks(String set, String country) {
    waitForElementToBeVisible(By.xpath(hotelsInfo.getSeeAllLinkLocator()));
    if (set.trim().equals("all")) {
        LOGGER.info("Link set is 'all'. Going to see all destinations page.");
        hotelsInfo.clickSeeAllLink();/*from   w  w w . j a  v a2s.c  o  m*/
        if (country == null) {
            throw new RuntimeException("Expected non-null country for doing all destinations.");
        }
        webdriver.findElement(By.partialLinkText(country)).click();
        destinationListPage = PageFactory.initElements(webdriver, DestinationListPage.class);
        waitForElementToBeVisible(By.xpath(destinationListPage.getCityListLocator()));
        destinationList = destinationListPage.getDestinationUrls();

    } else {
        LOGGER.info("Link set is top 100.");
        top100 = hotelsInfo.getDestinationUrls("Hotel");
    }
}

From source file:com.ibm.watson.movieapp.dialog.fvt.webui.BaseUI.java

License:Open Source License

/**
 * Converts a locator string with a known prefix to a By object
 * @param myLocator// w w w  . ja va 2 s  .c  o  m
 *       Supported locators:
 *          xpath - "//"
 *             id - "id="
 *     css selector - "css="
 *          xpath - "xpath="
 *         linktext - "link="
 *            name - "name="
 *linkpartialtext - "linkpartial="
 * @return By object extracted from given string locator
 */
private static By byFromLocator(String locator) {
    if (locator.startsWith("//")) {
        return By.xpath(locator);
    }
    if (locator.startsWith("id=")) {
        return By.id(locator.replaceFirst("id=", ""));
    }
    if (locator.startsWith("css=")) {
        return By.cssSelector(locator.replaceFirst("css=", ""));
    }
    if (locator.startsWith("xpath=")) {
        return By.xpath(locator.replaceFirst("xpath=", ""));
    }
    if (locator.startsWith("name=")) {
        return By.name(locator.replaceFirst("name=", ""));
    }
    if (locator.startsWith("link=")) {
        return By.linkText(locator.replaceFirst("link=", ""));
    }
    if (locator.startsWith("linkpartial=")) {
        return By.partialLinkText(locator.replaceFirst("linkpartial=", ""));
    }
    throw new IllegalArgumentException("Locator not supported: " + locator);
}

From source file:com.jase.knife.BrowserEmulator.java

License:Apache License

/**
 * Click the element by the link text./*from   w  w w.j  ava  2s  .  co m*/
 * @param text, the element's link text
 */
public void clickText(String text) {

    WebElement we = browser.findElement(By.partialLinkText(text));
    try {
        we.click();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.java.AppTestType_18_11_2015.java

public void MYOPERATION(WebDriver driver, String fieldText, String value) {
    //It is used where framework actions doesn't work 
    //We need to proviede SND<Text to enter> in the value fields to perform "Sendkeys"
    //We need to proviede CLK in the value fields to perform "Click"
    try {/*from   w  w  w  .j  a  va2  s.c o m*/
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        String f = fieldText;
        String oper = value;

        String attribute = f.substring(0, 3);
        String locator = f.substring(3, f.length());

        String operation = oper.substring(0, 3);
        String val = oper.substring(3, oper.length());

        if (operation.equalsIgnoreCase("CLK")) {
            switch (attribute) {
            case "IDI":
                driver.findElement(By.id(locator)).click();
                resultDetails.setFlag(true);
                break;
            case "XPH":
                driver.findElement(By.xpath(locator)).click();
                resultDetails.setFlag(true);
                break;
            case "LNK":
                driver.findElement(By.linkText(locator)).click();
                resultDetails.setFlag(true);
                break;
            case "PLK":
                driver.findElement(By.partialLinkText(locator)).click();
                resultDetails.setFlag(true);
                break;
            default:
                System.out.println("Invalid Locator attribute");
                break;
            }

        }

        else if (operation.equalsIgnoreCase("SND")) {

            switch (attribute) {
            case "IDI":
                driver.findElement(By.id(locator)).clear();
                driver.findElement(By.id(locator)).sendKeys(val);
                resultDetails.setFlag(true);
                break;
            case "XPH":
                driver.findElement(By.xpath(locator)).clear();
                driver.findElement(By.xpath(locator)).sendKeys(val);
                resultDetails.setFlag(true);
                break;
            case "LNK":
                driver.findElement(By.linkText(locator)).clear();
                driver.findElement(By.linkText(locator)).sendKeys(val);
                resultDetails.setFlag(true);
                break;
            default:
                System.out.println("Invalid Locator attribute");
                break;
            }

        } else if (operation.equalsIgnoreCase("MTE")) {
            switch (attribute) {
            case "IDI":
                new Actions(driver).moveToElement(driver.findElement(By.id(locator))).perform();
                break;
            case "XPH":
                new Actions(driver).moveToElement(driver.findElement(By.xpath(locator))).perform();
                resultDetails.setFlag(true);
                break;
            case "LNK":
                new Actions(driver).moveToElement(driver.findElement(By.linkText(locator))).perform();
                resultDetails.setFlag(true);
                break;
            default:
                System.out.println("Invalid Locator attribute");
                break;
            }

        } else if (operation.equalsIgnoreCase("SEL")) {
            switch (attribute) {

            case "XPH":
                new Select(driver.findElement(By.xpath(locator))).selectByVisibleText(val);
                resultDetails.setFlag(true);
                break;

            }

        }

    } catch (Exception e) {
        resultDetails.setFlag(false);
        e.printStackTrace();
    }
}

From source file:com.java.AppTestType_18_11_2015.java

public void WAITFORTHIS(WebDriver driver, String fieldText, String value) {
    //Used to verify the text in any specific Loctor or Message
    //<XPH or LNK or IDI or TXT or MSG><Locator> in fieldText 
    //Time in milliseconds in Value
    try {/*from  w ww  .  j  a v  a2 s. c o  m*/

        String f = fieldText;
        String time = value;
        String locatorType = f.substring(0, 3);
        String locatorValue = f.substring(3, f.length());
        int timevalue = Integer.parseInt(time);
        driver.manage().timeouts().implicitlyWait(timevalue, TimeUnit.MILLISECONDS);

        if (locatorType.equalsIgnoreCase("XPH")) {

            if (driver.findElements(By.xpath(locatorValue)).size() > 0)
                resultDetails.setFlag(true);
        } else if (locatorType.equalsIgnoreCase("LNK")) {

            if (driver.findElements(By.linkText(locatorValue)).size() > 0)
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("IDI") || locatorType.equalsIgnoreCase("TXT")) {

            if (driver.findElements(By.id(locatorValue)).size() > 0)
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("MSG")) {

            int j = 0;
            int t = timevalue / 1000;
            for (int i = 0; i < t; i++) {
                if (driver.findElement(By.xpath("//*[contains(text(),'" + locatorValue + "')]"))
                        .isDisplayed()) {
                    j = 1;
                    break;
                }
                Thread.sleep(1000);

            }
            if (j == 1)
                resultDetails.setFlag(true);

        } else if (locatorType.equalsIgnoreCase("PLK")) {

            if (driver.findElements(By.partialLinkText(locatorValue)).size() > 0)
                resultDetails.setFlag(true);

        }

    }

    catch (Exception e) {
        resultDetails.setErrorMessage(fieldText + "Locator Not Found");
        resultDetails.setFlag(false);
        e.printStackTrace();
    }
}