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.ecofactor.qa.automation.platform.action.impl.AndroidUIAction.java

License:Open Source License

/**
 * Reject alert.//  w  w  w. ja  v  a2s. c  o  m
 * @see com.ecofactor.qa.automation.platform.action.UIAction#rejectAlert()
 */
@Override
public void rejectAlert() {

    setLogString(Marker.START, "Close Native alerts", true);
    setLogString("Check and close alert if any.", true);
    try {
        driverOps.switchToNative();
        if (driverOps.getDeviceDriver().findElement(By.linkText("Cancel")) != null) {
            setLogString("Click Cancel button", true);
            driverOps.getDeviceDriver().findElement(By.linkText("Cancel")).click();
        }
    } catch (Exception ex) {
        setLogString("No alert popup.", true);
    } finally {

        driverOps.switchToWebView();
    }
    setLogString(Marker.END, "Completed", true);
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Check according to the link text./*w  w  w. java 2  s .  com*/
 * @param driver the driver
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isDisplayedByLinkText(final WebDriver driver, final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            WebElement element = driver.findElement(By.linkText(fieldname));
            return element.isDisplayed();
        }
    });
    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Retrieve Element according to the Text provided.
 * @param driver the driver/*from   w w w. java 2s  . com*/
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static WebElement retrieveElementByLinkText(final WebDriver driver, final String fieldname,
        final int timeOut) {

    isDisplayedByLinkText(driver, fieldname, timeOut);
    WebElement element = driver.findElement(By.linkText(fieldname));
    return element;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Retrieve Element according to the Text provided for particular Form or Sub Element.
 * @param driver the driver/*from w ww. j a  va2 s. c om*/
 * @param subElement the sub element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static WebElement retrieveElementByLinkTextForSubElement(final WebDriver driver,
        final WebElement subElement, final String fieldname, final int timeOut) {

    WebElement element = subElement.findElement(By.linkText(fieldname));
    return element;
}

From source file:com.elastica.webelements.HtmlElement.java

License:Apache License

private By getLocatorBy(final String locator, final LocatorType locatorType) {
    switch (locatorType) {

    case ID://  w  ww  . j  av a 2  s  . c  o m
        return By.id(locator);

    case NAME:
        return By.name(locator);

    case CLASS_NAME:
        return By.className(locator);

    case LINK_TEXT:
        return By.linkText(locator);

    case PARTIAL_LINK_TEXT:
        return By.partialLinkText(locator);

    case CSS_SELECTOR:
        return By.cssSelector(locator);

    case TAG_NAME:
        return By.tagName(locator);

    default:
        return By.xpath(locator);
    }
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.pageobjects.annotations.AppiumAnnotationsUtil.java

License:Open Source License

public static By getFrame(Frame frame) {
    if (frame == null)
        return null;
    if (!"".equals(frame.id()))
        return By.id(frame.id());
    if (!"".equals(frame.className()))
        return By.className(frame.className());
    if (!"".equals(frame.xpath()))
        return By.xpath(frame.xpath());
    if (!"".equals(frame.css()))
        return By.cssSelector(frame.css());
    if (!"".equals(frame.linkText()))
        return By.linkText(frame.linkText());
    if (!"".equals(frame.name()))
        return By.name(frame.name());
    if (!"".equals(frame.partialLinkText()))
        return By.partialLinkText(frame.partialLinkText());
    if (!"".equals(frame.tagName()))
        return By.tagName(frame.tagName());
    return null;//from ww  w.j av  a 2 s. com
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.pageobjects.annotations.AppiumAnnotationsUtil.java

License:Open Source License

public static By findByToBy(FindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;/*ww w  .ja  v  a2s  . c  o  m*/
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.pageobjects.annotations.AppiumAnnotationsUtil.java

License:Open Source License

public static By getFindByLocator(JFindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;/*w  w w  .j  a  v  a2  s.  c o  m*/
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.pageobjects.annotations.WebAnnotationsUtil.java

License:Open Source License

public static By findByToBy(JFindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;//from  ww  w  .j  a v  a 2 s .  c om
}

From source file:com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.WebAnnotationsUtil.java

License:Open Source License

public static By findByToBy(FindBy locator) {
    if (locator == null)
        return null;
    if (!locator.id().isEmpty())
        return By.id(locator.id());
    if (!locator.className().isEmpty())
        return By.className(locator.className());
    if (!locator.xpath().isEmpty())
        return By.xpath(locator.xpath());
    if (!locator.css().isEmpty())
        return By.cssSelector(locator.css());
    if (!locator.linkText().isEmpty())
        return By.linkText(locator.linkText());
    if (!locator.name().isEmpty())
        return By.name(locator.name());
    if (!locator.partialLinkText().isEmpty())
        return By.partialLinkText(locator.partialLinkText());
    if (!locator.tagName().isEmpty())
        return By.tagName(locator.tagName());
    return null;//from  www .j  a va  2  s  .co  m
}