Example usage for org.openqa.selenium By toString

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

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.constellio.sdk.tests.selenium.adapters.base.WebElementAdapter.java

License:Open Source License

public WE findElementAtIndex(final By by, final int index) {
    WebElementFinder<WebElement> factory = new WebElementFinder<WebElement>() {

        @Override/*from  w ww.j  a  v  a  2s.c  om*/
        public WebElement get() {
            webDriver.ensureNoApplicationException();
            return getAdaptedElement().findElements(by).get(index);
        }

        @Override
        public String getOperationDescription() {
            return WebElementAdapter.this.toString() + ".findElements(" + by.toString() + ")";
        }
    };
    factory.getUsingCache();
    return adapt(factory, webDriver);
}

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

License:Apache License

public void selectFrame(final By by) {
    TestLogging.logWebStep(null, "select frame, locator={\"" + by.toString() + "\"}", false);
    driver.switchTo().frame(driver.findElement(by));
}

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

License:Apache License

public void waitForElementPresent(final By by) {
    TestLogging.logWebStep(null, "wait for " + by.toString() + " to be present.", false);

    WebDriverWait wait = new WebDriverWait(driver, explictWaitTimeout);
    wait.until(ExpectedConditions.presenceOfElementLocated(by));
}

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

License:Apache License

public void waitForElementPresent(final By by, final int timeout) {
    TestLogging.logWebStep(null, "wait for " + by.toString() + " to be present.", false);

    WebDriverWait wait = new WebDriverWait(driver, timeout);
    wait.until(ExpectedConditions.presenceOfElementLocated(by));
}

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

License:Apache License

public final void selectFrame(final By by) {
    TestLogging.logWebStep(null, "select frame, locator={\"" + by.toString() + "\"}", false);
    driver.switchTo().frame(driver.findElement(by));
    frameFlag = true;//  w w w. j  ava 2 s .  c o m
}

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

License:Apache License

public WebElement getElement(final By by, final String elementName) {
    WebElement element = null;/*from   ww  w . ja va2 s . c o  m*/
    try {
        element = driver.findElement(by);
    } catch (ElementNotFoundException e) {
        TestLogging.errorLogger(elementName + " is not found with locator - " + by.toString());
        throw e;
    }

    return element;
}

From source file:com.epam.jdi.uitests.mobile.appium.driver.WebDriverByUtils.java

License:Open Source License

public static Function<String, By> getByFunc(By by) {
    return first(getMapByTypes(), key -> by.toString().contains(key));
}

From source file:com.epam.jdi.uitests.mobile.appium.driver.WebDriverByUtils.java

License:Open Source License

public static boolean containsRoot(By by) {
    return by != null && by.toString().contains(": *root*");
}

From source file:com.epam.jdi.uitests.mobile.appium.driver.WebDriverByUtils.java

License:Open Source License

public static String getByLocator(By by) {
    String byAsString = by.toString();
    int index = byAsString.indexOf(": ") + 2;
    return byAsString.substring(index);
}

From source file:com.epam.jdi.uitests.mobile.appium.driver.WebDriverByUtils.java

License:Open Source License

public static String getByName(By by) {
    Matcher m = Pattern.compile("By\\.(?<locator>.*):.*").matcher(by.toString());
    if (m.find())
        return m.group("locator");
    throw new RuntimeException("Can't get By name for: " + by);
}