org.openqa.selenium.remote.LocalFileDetector Java Examples
The following examples show how to use
org.openqa.selenium.remote.LocalFileDetector.
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: ElementSteps.java From vividus with Apache License 2.0 | 6 votes |
/** * This step uploads a file with the given relative path * <p>A <b>relative path</b> starts from some given working directory, * avoiding the need to provide the full absolute path * (i.e. <i>'about.jpeg'</i> is in the root directory * or <i>'/story/uploadfiles/about.png'</i>)</p> * @param locator The locator for the upload element * @param filePath relative path to the file to be uploaded * @see <a href="https://en.wikipedia.org/wiki/Path_(computing)#Absolute_and_relative_paths"> <i>Absolute and * relative paths</i></a> * @throws IOException If an input or output exception occurred */ @When("I select element located `$locator` and upload file `$filePath`") public void uploadFile(SearchAttributes locator, String filePath) throws IOException { Resource resource = resourceLoader.getResource(ResourceLoader.CLASSPATH_URL_PREFIX + filePath); if (!resource.exists()) { resource = resourceLoader.getResource(ResourceUtils.FILE_URL_PREFIX + filePath); } File fileForUpload = ResourceUtils.isFileURL(resource.getURL()) ? resource.getFile() : unpackFile(resource, filePath); if (highlightingSoftAssert.assertTrue("File " + filePath + " exists", fileForUpload.exists())) { String fullFilePath = fileForUpload.getAbsolutePath(); if (isRemoteExecution()) { webDriverProvider.getUnwrapped(RemoteWebDriver.class).setFileDetector(new LocalFileDetector()); } locator.getSearchParameters().setVisibility(Visibility.ALL); WebElement browse = baseValidations.assertIfElementExists(AN_ELEMENT, locator); if (browse != null) { browse.sendKeys(fullFilePath); } } }
Example #2
Source File: CustomDriverProvider.java From akita with Apache License 2.0 | 6 votes |
/** * Задает 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 #3
Source File: TestSuite.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
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 #4
Source File: UploadUncompilableClassTest.java From CodeDefenders with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { ChromeOptions options = new ChromeOptions(); // This is hardcoded but we cannot do otherwise. The alternative would // be to run a docker grid driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // Many suggests to define the size, but if you tests requires a // different setting, change this driver.manage().window().setSize(new Dimension(1024, 768)); // ((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector()); // This is important: docker-compose randomly assign ports and names to // those logical entities so we get them from the rule String codeDefendersHome = "http://frontend:8080/codedefenders"; // // driver.get(codeDefendersHome); }
Example #5
Source File: RemoteBrowserFactory.java From aquality-selenium-java with Apache License 2.0 | 5 votes |
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 #6
Source File: StandaloneDriverFactory.java From teasy with MIT License | 5 votes |
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 #7
Source File: UploadClassesTest.java From CodeDefenders with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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 #8
Source File: RemoteDriverFactory.java From hsac-fitnesse-fixtures with Apache License 2.0 | 5 votes |
@Override public T createDriver() { if (capabilities instanceof MutableCapabilities) { DriverFactory.addDefaultCapabilities((MutableCapabilities) capabilities); } 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; }
Example #9
Source File: GridSupplier.java From selenium with Apache License 2.0 | 5 votes |
@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 #10
Source File: RemoteDriverConfigTest.java From jmeter-plugins-webdriver with Apache License 2.0 | 4 votes |
@Test public void shouldProduceLocalFileLocator() { config.setFileDetectorOption(FileDetectorOption.LOCAL); assertTrue(config.createFileDetector() instanceof LocalFileDetector); }
Example #11
Source File: ExternalDriverSupplier.java From selenium with Apache License 2.0 | 4 votes |
@Override public WebDriver get() { RemoteWebDriver driver = new RemoteWebDriver(url, desiredCapabilities); driver.setFileDetector(new LocalFileDetector()); return driver; }
Example #12
Source File: SessionLogsTest.java From selenium with Apache License 2.0 | 4 votes |
private void startDriver() { Capabilities caps = WebDriverBuilder.getStandardCapabilitiesFor(Browser.detect()); localDriver = new RemoteWebDriver(server.getWebDriverUrl(), caps); localDriver.setFileDetector(new LocalFileDetector()); }
Example #13
Source File: RemoteDriverFactory.java From teasy with MIT License | 2 votes |
/** * 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; }