Java 类org.openqa.selenium.internal.FindsByCssSelector 实例源码

项目:grid-refactor-remote-server    文件:DefaultSession.java   
private DesiredCapabilities getDescription(WebDriver instance, Capabilities capabilities) {
  DesiredCapabilities caps = new DesiredCapabilities(capabilities.asMap());
  caps.setJavascriptEnabled(instance instanceof JavascriptExecutor);
  if (instance instanceof TakesScreenshot) {
    caps.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
  }
  if (instance instanceof LocationContext) {
    caps.setCapability(CapabilityType.SUPPORTS_LOCATION_CONTEXT, true);
  }
  if (instance instanceof ApplicationCache) {
    caps.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true);
  }
  if (instance instanceof NetworkConnection) {
    caps.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, true);
  }
  if (instance instanceof WebStorage) {
    caps.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, true);
  }
  if (instance instanceof FindsByCssSelector) {
    caps.setCapability(CapabilityType.SUPPORTS_FINDING_BY_CSS, true);
  }
  if (instance instanceof Rotatable) {
    caps.setCapability(CapabilityType.ROTATABLE, true);
  }
  if (instance instanceof HasTouchScreen) {
    caps.setCapability(CapabilityType.HAS_TOUCHSCREEN, true);
  }
  return caps;
}
项目:Selenium-Foundation    文件:RobustElementFactory.java   
/**
 * Main robust web element constructor
 * 
 * @param element element reference to be wrapped (may be 'null')
 * @param context element search context
 * @param locator element locator
 * @param index element index
 */
public RobustElementWrapper(WebElement element, WrapsContext context, By locator, 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();
    }
}
项目:bobcat    文件:WebDriverWrapper.java   
/**
 * Finds element by css selector.
 */
@Override
public WebElement findElementByCssSelector(String cssSelector) {
  return ((FindsByCssSelector) super.getWrappedDriver()).findElementByCssSelector(cssSelector);
}
项目:bobcat    文件:WebDriverWrapper.java   
/**
 * Finds elements by css selector.
 */
@Override
public List<WebElement> findElementsByCssSelector(String cssSelector) {
  return ((FindsByCssSelector) super.getWrappedDriver()).findElementsByCssSelector(cssSelector);
}
项目:darcy-webdriver    文件:TargetedWebElement.java   
@Override
public WebElement findElementByCssSelector(String using) {
    return targetedWebElement(((FindsByCssSelector) element()).findElementByCssSelector(using));
}
项目:darcy-webdriver    文件:TargetedWebElement.java   
@Override
public List<WebElement> findElementsByCssSelector(String using) {
    return targetedWebElements(((FindsByCssSelector) element()).findElementsByCssSelector(using));
}
项目:darcy-webdriver    文件:ForwardingTargetedWebDriver.java   
@Override
public WebElement findElementByCssSelector(String using) {
    return targetedWebElement(((FindsByCssSelector) driver()).findElementByCssSelector(using));
}
项目:darcy-webdriver    文件:ForwardingTargetedWebDriver.java   
@Override
public List<WebElement> findElementsByCssSelector(String using) {
    return targetedWebElements(((FindsByCssSelector) driver()).findElementsByCssSelector(using));
}