Example usage for org.openqa.selenium.support.ui Quotes escape

List of usage examples for org.openqa.selenium.support.ui Quotes escape

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui Quotes escape.

Prototype

@SuppressWarnings("JavaDoc")
public static String escape(String toEscape) 

Source Link

Document

Convert strings with both quotes and ticks into a valid xpath component For example,

foo will be converted to "foo" ,

f"oo will be converted to 'f"oo' ,

foo'"bar will be converted to concat("foo'", '"', "bar")

Usage

From source file:com.atanas.kanchev.testframework.selenium.handlers.Finder.java

License:Apache License

/**
 * {@inheritDoc}//from ww  w . j  a  v a 2  s  .  c om
 */
@Override
public Finder containingText(final String text) {

    if (text == null)
        throw new CustomExceptions.Common.NullArgumentException();
    else
        ((SeleniumContext) context().getCurrentContext()).setCurrentElement(findElement(
                By.xpath(".//*/text()[contains(normalize-space(.), " + Quotes.escape(text) + ")]/parent::*")));
    return this;

}

From source file:com.atanas.kanchev.testframework.selenium.handlers.Finder.java

License:Apache License

/**
 * {@inheritDoc}//  w  w w  . j av  a2 s .c o  m
 */
@Override
public Finder havingText(final String text) {

    if (text == null)
        throw new CustomExceptions.Common.NullArgumentException();
    else
        ((SeleniumContext) context().getCurrentContext()).setCurrentElement(findElement(
                By.xpath(".//*/text()[normalize-space(.) = " + Quotes.escape(text) + "]/parent::*")));
    return this;

}

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

License:Open Source License

public static By findByToBy(Text locator) {
    if (locator == null)
        return null;
    return By.xpath(".//*/text()[normalize-space(.) = " + Quotes.escape(locator.value()) + "]/parent::*");
}

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

License:Open Source License

public static By findByToBy(JFindBy locator) {
    if (locator == null)
        return null;

    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.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());

    if (!"".equals(locator.text()))
        return By.xpath(".//*/text()[normalize-space(.) = " + Quotes.escape(locator.text()) + "]/parent::*");

    if (!"".equals(locator.attribute().name()))
        return getAttribute(locator.attribute().name(), locator.attribute().value());
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.value()))
        return getAttribute("value", locator.value());
    if (!"".equals(locator.title()))
        return getAttribute("title", locator.title());
    if (!"".equals(locator.type()))
        return getAttribute("type", locator.title());
    if (!"".equals(locator.model()))
        return getAttribute("ng-model", locator.model());
    if (!"".equals(locator.binding()))
        return getAttribute("ng-binding", locator.binding());
    if (!"".equals(locator.repeat()))
        return getAttribute("ng-repeat", locator.repeat());
    return null;/*from w w  w.  j a v a2 s.co  m*/
}