org.openqa.selenium.internal.FindsByCssSelector Java Examples

The following examples show how to use org.openqa.selenium.internal.FindsByCssSelector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RobustElementWrapper.java    From Selenium-Foundation with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"squid:S3776", "squid:MethodCyclomaticComplexity"})
public RobustElementWrapper(
                final WebElement element, final WrapsContext context, final By locator, final int index) {
    
    // if specified element is already robust
    if (element instanceof RobustWebElement) {
        RobustElementWrapper wrapper = ((InterceptionAccessor) element).getInterceptor();
        this.acquiredAt = wrapper.acquiredAt;
        
        this.wrapped = wrapper.wrapped;
        this.context = wrapper.context;
        this.locator = wrapper.locator;
        this.index = wrapper.index;
    } else {
        Objects.requireNonNull(context, "[context] must be non-null");
        Objects.requireNonNull(locator, "[locator] must be non-null");
        if (index < OPTIONAL) {
            throw new IndexOutOfBoundsException("Specified index is invalid");
        }
        
        this.wrapped = element;
        this.context = context;
        this.locator = locator;
        this.index = index;
    }
    
    driver = WebDriverUtils.getDriver(this.context.getWrappedContext());
    
    findsByCssSelector = (driver instanceof FindsByCssSelector);
    findsByXPath = (driver instanceof FindsByXPath);
    
    if ((this.index == OPTIONAL) || (this.index > 0)) {
        if (findsByXPath && ( ! (this.locator instanceof By.ByCssSelector))) {
            selector = ByType.xpathLocatorFor(this.locator);
            if (this.index > 0) {
                selector += "[" + (this.index + 1) + "]";
            }
            strategy = Strategy.JS_XPATH;
            
            this.locator = By.xpath(this.selector);
        } else if (findsByCssSelector) {
            selector = ByType.cssLocatorFor(this.locator);
            if (selector != null) {
                strategy = Strategy.JS_CSS;
            }
        }
    }
    
    if (this.wrapped == null) {
        if (this.index == OPTIONAL) {
            acquireReference(this);
        } else {
            refreshReference(null);
        }
    } else if (acquiredAt == 0) {
        acquiredAt = System.currentTimeMillis();
    }
}
 
Example #2
Source File: WebDriverWrapper.java    From bobcat with Apache License 2.0 4 votes vote down vote up
/**
 * Finds element by css selector.
 */
@Override
public WebElement findElementByCssSelector(String cssSelector) {
  return ((FindsByCssSelector) super.getWrappedDriver()).findElementByCssSelector(cssSelector);
}
 
Example #3
Source File: WebDriverWrapper.java    From bobcat with Apache License 2.0 4 votes vote down vote up
/**
 * Finds elements by css selector.
 */
@Override
public List<WebElement> findElementsByCssSelector(String cssSelector) {
  return ((FindsByCssSelector) super.getWrappedDriver()).findElementsByCssSelector(cssSelector);
}
 
Example #4
Source File: TargetedWebElement.java    From darcy-webdriver with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WebElement findElementByCssSelector(String using) {
    return targetedWebElement(((FindsByCssSelector) element()).findElementByCssSelector(using));
}
 
Example #5
Source File: TargetedWebElement.java    From darcy-webdriver with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<WebElement> findElementsByCssSelector(String using) {
    return targetedWebElements(((FindsByCssSelector) element()).findElementsByCssSelector(using));
}
 
Example #6
Source File: ForwardingTargetedWebDriver.java    From darcy-webdriver with GNU General Public License v3.0 4 votes vote down vote up
@Override
public WebElement findElementByCssSelector(String using) {
    return targetedWebElement(((FindsByCssSelector) driver()).findElementByCssSelector(using));
}
 
Example #7
Source File: ForwardingTargetedWebDriver.java    From darcy-webdriver with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<WebElement> findElementsByCssSelector(String using) {
    return targetedWebElements(((FindsByCssSelector) driver()).findElementsByCssSelector(using));
}