Java Code Examples for org.openqa.selenium.remote.RemoteWebDriver#setFileDetector()

The following examples show how to use org.openqa.selenium.remote.RemoteWebDriver#setFileDetector() . 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: CustomDriverProvider.java    From akita with Apache License 2.0 6 votes vote down vote up
/**
 * Задает capabilities для запуска Remote драйвера для Selenoid
 *
 * @param capabilities - capabilities для установленного браузера
 * @param remoteUrl    - url для запуска тестов, например http://remoteIP:4444/wd/hub
 * @return WebDriver
 */
private WebDriver getRemoteDriver(MutableCapabilities capabilities, String remoteUrl) {
    log.info("---------------run Remote Driver---------------------");
    Boolean isSelenoidRun = loadSystemPropertyOrDefault(SELENOID, true);
    if (isSelenoidRun) {
        capabilities.setCapability("enableVNC", true);
        capabilities.setCapability("screenResolution", String.format("%sx%s", loadSystemPropertyOrDefault(WINDOW_WIDTH, DEFAULT_WIDTH),
                loadSystemPropertyOrDefault(WINDOW_HEIGHT, DEFAULT_HEIGHT)));
        String sessionName = loadSystemPropertyOrDefault(SELENOID_SESSION_NAME, "");
        if (!sessionName.isEmpty()) {
            capabilities.setCapability("name", String.format("%s %s", sessionName, AkitaScenario.getInstance().getScenario().getName()));
        }
    }
    try {
        RemoteWebDriver remoteWebDriver = new RemoteWebDriver(
            URI.create(remoteUrl).toURL(),
            capabilities
        );
        remoteWebDriver.setFileDetector(new LocalFileDetector());
        return remoteWebDriver;
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
 
Example 2
Source File: TestSuite.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
    final DesiredCapabilities capabilities = new DesiredCapabilities ();
    capabilities.setBrowserName ( browser );
    if ( version != null )
    {
        capabilities.setVersion ( version );
    }
    capabilities.setCapability ( CapabilityType.PLATFORM, os );
    capabilities.setCapability ( CapabilityType.SUPPORTS_FINDING_BY_CSS, true );
    capabilities.setCapability ( "name", "Eclipse Package Drone Main Test" );

    if ( System.getenv ( "TRAVIS_JOB_NUMBER" ) != null )
    {
        capabilities.setCapability ( "tunnel-identifier", System.getenv ( "TRAVIS_JOB_NUMBER" ) );
        capabilities.setCapability ( "build", System.getenv ( "TRAVIS_BUILD_NUMBER" ) );
        capabilities.setCapability ( "tags", new String[] { "CI" } );
    }

    final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%s@%s/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY, SAUCE_URL ) ), capabilities );

    driver.setFileDetector ( new LocalFileDetector () );

    return driver;
}
 
Example 3
Source File: RemoteBrowserFactory.java    From aquality-selenium-java with Apache License 2.0 5 votes vote down vote up
private RemoteWebDriver createRemoteDriver(Capabilities capabilities) {
    AqualityServices.getLocalizedLogger().info("loc.browser.grid");

    ClientFactory clientFactory = new ClientFactory();
    CommandExecutor commandExecutor = new HttpCommandExecutor(
            ImmutableMap.of(),
            browserProfile.getRemoteConnectionUrl(),
            clientFactory);

    RemoteWebDriver driver = getDriver(RemoteWebDriver.class, commandExecutor, capabilities);
    driver.setFileDetector(new LocalFileDetector());
    return driver;
}
 
Example 4
Source File: StandaloneDriverFactory.java    From teasy with MIT License 5 votes vote down vote up
private WebDriver safariTechnologyPreview() {
    DriverHolder.setDriverName(SAFARI_TECH_PREVIEW_DIVER_NAME);
    RemoteWebDriver driver = new RemoteWebDriver(
            this.gridUrl,
            new SafariTechPreviewCaps(customCaps).get());
    driver.setFileDetector(new LocalFileDetector());
    return driver;
}
 
Example 5
Source File: UploadClassesTest.java    From CodeDefenders with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Helper function to login and enable file upload.
 */
private void setLocalFileDetectorAndLogin() {
    /* Set LocalFileDetector if not set already. */
	RemoteWebDriver localDriver = ((RemoteWebDriver) driver);
	if (!(localDriver.getFileDetector() instanceof LocalFileDetector)) {
		localDriver.setFileDetector(new LocalFileDetector());
	}

	SeleniumTestUtils.login(driver, codeDefendersHome, "codedefenders", "codedefenderspw");

	driver.findElement(By.id("headerUploadButton")).click();
}
 
Example 6
Source File: GridSupplier.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public WebDriver get() {
  if (desired == null || !Boolean.getBoolean("selenium.browser.grid")) {
    return null;
  }

  if (!started) {
    startServers();
  }

  RemoteWebDriver driver = new RemoteWebDriver(hub.getWebDriverUrl(), desired);
  driver.setFileDetector(new LocalFileDetector());
  return driver;
}
 
Example 7
Source File: ExternalDriverSupplier.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public WebDriver get() {
  RemoteWebDriver driver = new RemoteWebDriver(url, desiredCapabilities);
  driver.setFileDetector(new LocalFileDetector());
  return driver;
}
 
Example 8
Source File: SessionLogsTest.java    From selenium with Apache License 2.0 4 votes vote down vote up
private void startDriver() {
  Capabilities caps = WebDriverBuilder.getStandardCapabilitiesFor(Browser.detect());
  localDriver = new RemoteWebDriver(server.getWebDriverUrl(), caps);
  localDriver.setFileDetector(new LocalFileDetector());
}
 
Example 9
Source File: RemoteDriverFactory.java    From teasy with MIT License 2 votes vote down vote up
/**
 * Final tuning for a driver
 * <p>
 * Setting a file detector for a driver
 * and setting a driver name to SeleniumHolder
 *
 * @param driver - instance of a RemoteWebDriver
 * @param name   - driver name
 * @return driver with LocalFileDetector as a fileDetector
 */
private RemoteWebDriver tuneDriver(RemoteWebDriver driver, String name) {
    DriverHolder.setDriverName(name);
    driver.setFileDetector(new LocalFileDetector());
    return driver;
}