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:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive uncheck(By by) {
    if (isChecked(by)) {
        waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
                .waitForCondition(ExpectedConditions.elementToBeClickable(by));
        waitForElement(by).click();//from w  w  w . j a  v a  2 s.c  om
        assertFalse(by.toString() + " did not uncheck!", isChecked(by));
    }
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive validatePresent(By by) {
    waitForElement(by);//from  w w  w.  j  a  v a  2s .c o m
    assertTrue("Element " + by.toString() + " does not exist!", isPresent(by));
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive validateNotPresent(By by) {
    assertFalse("Element " + by.toString() + " exists!", isPresent(by));
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive validateChecked(By by) {
    assertTrue(by.toString() + " is not checked!", isChecked(by));
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive validateUnchecked(By by) {
    assertFalse(by.toString() + " is not unchecked!", isChecked(by));
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive validateAttribute(By by, String attr, String regex) {
    String actual = null;//w ww  .jav a 2  s.  c om
    try {
        actual = getAttribute(by, attr);
        if (actual.equals(regex))
            return this; // test passes.
    } catch (NoSuchElementException e) {
        fail("No such element [" + by.toString() + "] exists.");
    } catch (Exception x) {
        fail("Cannot validate an attribute if an element doesn't have it!");
    }

    p = Pattern.compile(regex);
    m = p.matcher(actual);

    assertTrue(String.format(
            "Attribute doesn't match! [Selector: %s] [Attribute: %s] [Desired value: %s] [Actual value: %s]",
            by.toString(), attr, regex, actual), m.find());

    return this;
}

From source file:io.github.seleniumquery.by.SeleniumQueryInvalidBy.java

License:Apache License

public SeleniumQueryInvalidBy(By sourceBy, String suffix) {
    super(sourceBy.toString());
    this.sourceString = sourceBy.toString();
    this.suffix = suffix;
}

From source file:jhc.redsniff.webdriver.finders.ByFinder.java

License:Apache License

public static Locator<WebElement, SearchContext> locatorFor(final By by) {
    String byAsString = by.toString();
    Pattern pattern = Pattern.compile("^By\\.(\\w+)\\: (.*?)$");
    Matcher regexMatcher = pattern.matcher(byAsString);
    if (!regexMatcher.matches())
        throw new IllegalArgumentException("didn't match By.xxx: <arg>");

    final String byType = regexMatcher.group(1);
    final String byArg = regexMatcher.group(2);

    if (byType.equals("id"))
        return hasId(byArg);
    else if (byType.equals("name"))
        return hasName(byArg);
    else if (byType.equals("className"))
        return hasCssClass(byArg);
    else if (byType.equals("tagName"))
        return TagNameMatcher.hasTagName(byArg);
    else/*from  ww w. j  a v  a 2  s .  c om*/
        return new Locator<WebElement, SearchContext>() {

            @Override
            public void describeLocatorTo(Description description) {
                description.appendText("found " + by.toString());
            }

            @Override
            public CollectionOf<WebElement> findElementsFrom(SearchContext context) {
                return collectionOf(by.findElements(context));
            }

            @Override
            public String nameOfAttributeUsed() {
                return byType;
            }
        };
}

From source file:net.codestory.simplelenium.text.Text.java

License:Apache License

public static String toString(By selector) {
    return selector.toString().replace("By.selector: ", "").replace("By.cssSelector: ", "");
}

From source file:nz.co.testamation.core.client.SeleniumBrowserDriver.java

License:Apache License

@Override
public void select(By by) {
    System.out.println("clicking " + by.toString());
    waitBeforeClick(by);
}