Java 类org.openqa.selenium.remote.LocalFileDetector 实例源码

项目:automation-test-engine    文件:MyRemoteDriver.java   
/**
 * {@inheritDoc}
 */
@Override
public WebDriver getWebDriverInstance() {
    WebDriver retVal = getWebDriver();
    if (null == retVal || !(((EventFiringWebDriver)retVal).getWrappedDriver() instanceof RemoteWebDriver)) {

        try {
            RemoteWebDriver remoteVal = new RemoteWebDriver(new URL(url), caps.get());
            remoteVal.setFileDetector(new LocalFileDetector());
            retVal = remoteVal;
        } catch (MalformedURLException e) {
            //TODO add handling for bad url
            e.printStackTrace();
        }

        setWebDriver(retVal);
    }
    return retVal;

}
项目:seletest    文件:WebDriverController.java   
@Override
@Monitor
@RetryFailure(retryCount=3)
@JSHandle
public WebDriverController uploadFile(Object locator, String path) {
    LocalFileDetector detector = new LocalFileDetector();
    File localFile = detector.getLocalFile(path);
    ((RemoteWebElement)waitController().waitForElementPresence(locator)).setFileDetector(detector);
    waitController().waitForElementPresence(locator).sendKeys(localFile.getAbsolutePath());
    return this;
}
项目:willtest    文件:FileDetectorConfigurator.java   
@Override
public void postConstruct(D webDriver) {
    if (webDriver instanceof RemoteWebDriver) {
        try {
            ((RemoteWebDriver) webDriver).setFileDetector(new LocalFileDetector());
        } catch (WebDriverException e) {
            String message = e.getMessage();
            if (message != null &&
                    !message.contains(NO_FILE_DETECTOR_NEEDED)) {
                throw e;
            }
        }
    }
}
项目:fitnesse-selenium-slim    文件:SeleniumFixture.java   
/**
 * When send keys is being executed in a input file=type {@link LocalFileDetector} must be configured for remote drivers. Additionally,
 * the file path is expanded to be absolute
 *
 * @param driver used to run commands
 * @param element receiving keys
 * @param value to be set to input file type
 * @return value expanded to absolute path if for input file type.
 */
private String cleanValueToSend(WebDriver driver, WebElement element, String value) {
    if (!StringUtils.equals(element.getAttribute(SeleniumFixture.INPUT_TYPE_ATTRIBUTE), SeleniumFixture.INPUT_TYPE_FILE_VALUE)) {
        return this.fitnesseMarkup.clean(value);
    }
    // set file detector for remote web elements. Local FirefoxDriver uses RemoteWebElement and
    if (element instanceof RemoteWebElement && !ClassUtils.isAssignable(driver.getClass(), FirefoxDriver.class)) {
        ((RemoteWebElement) element).setFileDetector(new LocalFileDetector());
    }
    return this.fitnesseMarkup.cleanFile(value).getAbsolutePath();
}
项目:XBDD    文件:XbddDriver.java   
private static WebDriver getSeleniumGridRemoteDriver() throws MalformedURLException {
    final DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setBrowserName(System.getProperty("selenium.grid.browser", "firefox"));
    desiredCapabilities.setVersion(System.getProperty("selenium.grid.version", ""));
    desiredCapabilities.setPlatform(Platform.ANY);

    final URL url = new URL("http", System.getProperty("selenium.grid"), Integer.valueOf(System.getProperty(
            "selenium.grid.port", "4444")), "/wd/hub");

    final RemoteWebDriver remoteWebDriver = new RemoteWebDriver(url,
            desiredCapabilities);
    remoteWebDriver.setFileDetector(new LocalFileDetector());
    return new Augmenter().augment(remoteWebDriver);
}
项目:selenium-tinafw    文件:WebDriverFactoryRemote.java   
@Override
public WebDriver getWebDriver(SupportedBrowser browserType) {
    RemoteWebDriver remoteDriver = new RemoteWebDriver(gridHubURL,
            desiredCapabilities, browserType.toCapabilities());
    remoteDriver.setFileDetector(new LocalFileDetector());
    return remoteDriver;
}
项目:hsac-fitnesse-fixtures    文件:RemoteDriverFactory.java   
@Override
public T createDriver() {
    T remoteWebDriver = constr.apply(url, capabilities);
    FileDetector fd = remoteWebDriver.getFileDetector();
    if (fd == null || fd instanceof UselessFileDetector) {
        remoteWebDriver.setFileDetector(new LocalFileDetector());
    }
    Environment.getInstance().setSymbol(REMOTE_URL_KEY, url.toString());
    return remoteWebDriver;
}
项目:cylus    文件:AcceptanceTestConfig.java   
@Bean
public WebDriver webDriver() {
    PhantomJsDriverManager.getInstance().version("2.1.1").arch64().setup();

    final PhantomJSDriver phantomJSDriver = new PhantomJSDriver();
    phantomJSDriver.setFileDetector(new LocalFileDetector());
    return phantomJSDriver;
}
项目:minium    文件:WebDriverFactory.java   
public WebDriver create(WebDriverProperties webDriverProperties) throws IOException {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities(webDriverProperties.getDesiredCapabilities());
    desiredCapabilities.merge(browserSpecificCapabilities(webDriverProperties));

    WebDriver webDriver = null;
    if (webDriverProperties.getUrl() != null) {
        RemoteWebDriver remoteDriver = new RemoteWebDriver(webDriverProperties.getUrl(), desiredCapabilities);
        remoteDriver.setFileDetector(new LocalFileDetector());
        webDriver = remoteDriver;
    } else {
        String browserName = desiredCapabilities == null ? null : desiredCapabilities.getBrowserName();
        if (Strings.isNullOrEmpty(browserName)) browserName = BrowserType.CHROME;
        webDriver = WebDriverType.typeFor(browserName).create(this, desiredCapabilities);
    }

    WindowProperties window = webDriverProperties.getWindow();
    if (window != null) {
        DimensionProperties size = window.getSize();
        PointProperties position = window.getPosition();
        if (size != null) webDriver.manage().window().setSize(new Dimension(size.getWidth(), size.getHeight()));
        if (position != null) webDriver.manage().window().setPosition(new Point(position.getX(), position.getY()));
        if (window.isMaximized()) {
            webDriver.manage().window().maximize();
        }
    }

    webDriver = webDriver instanceof TakesScreenshot ? webDriver : new Augmenter().augment(webDriver);
    for (WebDriverTransformer transformer : driverServices.getWebDriverTranformers()) webDriver = transformer.transform(webDriver);
    return webDriverProperties.isStateful() ? new StatefulWebDriver(webDriver) : webDriver;
}
项目:Testy    文件:HtmlUnitConfigReader.java   
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
    if (isRemoteDriver()) {
        RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, DesiredCapabilities.htmlUnit());
        driver.setFileDetector(new LocalFileDetector());
        return driver;
    } else {
        return createDriver();
    }
}
项目:Testy    文件:FirefoxConfigReader.java   
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
    FirefoxOptions options = getFirefoxOptions();
    if (isRemoteDriver()) {
        RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, options);
        driver.setFileDetector(new LocalFileDetector());
        return driver;
    } else {
        return new FirefoxDriver(options);
    }
}
项目:Testy    文件:ChromeConfigReader.java   
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
    ChromeOptions options = getChromeOptions();
    if (isRemoteDriver()) {
        RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, options);
        driver.setFileDetector(new LocalFileDetector());
        return driver;
    } else {
        return new ChromeDriver(options);
    }
}
项目:Testy    文件:IExplorerConfigReader.java   
@Override
public WebDriver createDriver(URL remoteUrl) throws IOException {
    InternetExplorerOptions capabilities = getOptions();
    if (isRemoteDriver()) {
        RemoteWebDriver driver = new RemoteWebDriver(remoteUrl, capabilities);
        driver.setFileDetector(new LocalFileDetector());
        return driver;
    } else {
        return new InternetExplorerDriver(capabilities);
    }
}
项目:seauto    文件:AbstractConfigurableDriverProvider.java   
/**
 * Helper method to launch remote web driver.
 *
 * At times there are issues with starting the remote web driver. For firefox,
 * problems with locking port 7054 can arise.
 *
 * See the Selenium <a
 * href="https://code.google.com/p/selenium/issues/detail?id=4790">bug</a> for
 * more info
 *
 * A special case needs to be performed for the Android browser, since it can not be cast to {@link RemoteWebDriver}
 *
 * @param capabilities web driver capabilities.
 * @return {@link WebDriver} instance of the remote web driver
 *
 */
protected WebDriver initRemoteWebDriver(DesiredCapabilities capabilities)
{
  URL remoteUrl = getRemoteSeleniumUrl();
  LOG.debug("Remote Selenium URL: {}", remoteUrl.toString());
  WebDriver driver = null;
  boolean isAndroid = false;
  int tries = 1;

  if(capabilities.getCapability(CapabilityType.BROWSER_NAME).equals(ANDROID_BROWSER_NAME)) {
    isAndroid = true;
  }

  while (driver == null) {
    LOG.debug("Try {} {}", tries, capabilities.toString());

    try {

      if(isAndroid) {
        driver = new AndroidDriver(remoteUrl, capabilities);
      }
      else {
        driver = new RemoteWebDriver(remoteUrl, capabilities);
      }

    } catch (WebDriverException e) {
      LOG.error("Remote WebDriver was unable to start! " + e.getMessage(), e);

      if (tries >= Integer.getInteger(REMOTE_WEBDRIVER_RETRY_ATTEMPTS, 10)) {
        throw e;
      }

      sleep(Integer.getInteger(REMOTE_WEBDRIVER_RETRY_PAUSE_MILLIS, 5000) * tries);
      tries++;
      driver = null;
    }
  }

  if(!isAndroid) {
    // allow screenshots to be taken
    driver = new Augmenter().augment(driver);
  }

  // Allow files from the host to be uploaded to a remote browser
  ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());

  return driver;
}
项目:Testy    文件:WebDriverConfig.java   
public static WebDriver getWebDriver(URL remoteUrl, DesiredCapabilities capabilities) throws IOException {
    driver = new RemoteWebDriver(remoteUrl, capabilities);
    ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
    init(driver);
    return driver;
}