Giter VIP home page Giter VIP logo

webdrivermanager-examples's Introduction

Maven Central Build Status badge-jdk License badge Backers on Open Collective Sponsors on Open Collective Support badge Twitter Follow

WebDriverManager Examples

This repository contains JUnit examples to automate the Selenium WebDriver driver management using WebDriverManager. These examples are open-source, released under the terms of Apache 2.0 License.

Usage

In order to use WebDriverManager from tests in a Maven project, you need to add the following dependency in your pom.xml:

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>${wdm.version}</version>
    <scope>test</scope>
</dependency>

... or in a Gradle project:

dependencies {
    testImplementation("io.github.bonigarcia:webdrivermanager:${wdm.version}")
}

Then you can let WebDriverManager to manage the drivers required by Selenium WebDriver (e.g., chromedriver, geckodriver). For example, as a JUnit test using Chrome browser:

class ChromeTest {

    WebDriver driver;

    @BeforeAll
    static void setupClass() {
        WebDriverManager.chromedriver().setup();
    }

    @BeforeEach
    void setupTest() {
        driver = new ChromeDriver();
    }

    @AfterEach
    void teardown() {
        driver.quit();
    }

    @Test
    void test() {
        // Your test code here
    }

}

... or using Firefox:

class FirefoxTest {

    WebDriver driver;

    @BeforeAll
    static void setupClass() {
        WebDriverManager.firefoxdriver().setup();
    }

    @BeforeEach
    void setupTest() {
        driver = new FirefoxDriver();
    }

    @AfterEach
    void teardown() {
        driver.quit();
    }

    @Test
    void test() {
        // Your test code here
    }

}

Help

If you have questions on how to use WebDriverManager properly with a special configuration or suchlike, please consider asking a question on Stack Overflow and tag it with webdrivermanager-java.

Support

WebDriverManager is part of OpenCollective, an online funding platform for open and transparent communities. You can support the project by contributing as a backer (i.e., a personal donation or recurring contribution) or as a sponsor (i.e., a recurring contribution by a company).

Backers

Sponsors

About

WebDriverManager (Copyright © 2015-2023) is a personal project of Boni Garcia licensed under Apache 2.0 License.

webdrivermanager-examples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webdrivermanager-examples's Issues

Unable to launch edge browser

public class takeScreenshot4 {

public static void main(String[] args) throws InterruptedException {
   
	System.setProperty("webdriver.edge.driver","C:\\Automation\\msedgedriver.exe");
	WebDriver driver = null;
	WebDriverManager.edgedriver().setup();
	driver = new EdgeDriver();
	driver.manage().window().maximize();
	 	

    driver.get("https://www.google.com");

    System.out.println("Test Passed!");


    driver.close();

}

Error:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:181)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:163)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:154)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:130)
at io.github.bonigarcia.wdm.HttpClient.(HttpClient.java:132)
at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:501)
at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:260)
at screenShot.takeScreenshot4.main(takeScreenshot4.java:25)

java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ClassicHttpRequest with new version

Just upgraded from webdrivermanager 3.8.1 to 4.2.2 in order to pick up the Edge fixes. However, I'm running into issues. I had to upgrade several other pieces because I think the new webdrivermanager requires them (commons-io from 2.6 to 2.8.0, new commons-lang3 to 3.11, new httpclient5 to 5.0.1, new jarchivelib to 1.1.0.

Here is the relevant versions from my POM now:

	<commons-io.version>2.8.0</commons-io.version>
	<commons-lang3.version>3.11</commons-lang3.version>
	<commons-text.version>1.6</commons-text.version>
	<httpclient.version>4.5.12</httpclient.version>
	<httpclient5.version>5.0.1</httpclient5.version>
	<jarchivelib.version>1.1.0</jarchivelib.version>
	<selenium-java.version>3.141.59</selenium-java.version>
	<testng.version>6.14.3</testng.version>
	<webdrivermanager.version>4.2.2</webdrivermanager.version>

The line(s) that are causing this are:

        WebDriverManager.chromedriver().clearResolutionCache().setup();

or any WebDriverManager.edgedriver().setup();

The error I'm now getting is (this occurs trying to :)

java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ClassicHttpRequest

at framework.DriverFactory.getDriver(DriverFactory.java:257)
at tests.BaseTest.launchDriver(BaseTest.java:1081)
at tests.BaseTest.beforeSuite(BaseTest.java:798)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:401)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)

Caused by: java.lang.ClassNotFoundException: org.apache.hc.core5.http.ClassicHttpRequest
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 more

Unable to launch chrome or firefox driver

hi ,

I tried launching chrome /FF driver, got exception. Below logs and exception stacktrace.:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/skoleti.ORADEV/.m2/repository/org/slf4j/slf4j-simple/1.7.21/slf4j-simple-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/skoleti.ORADEV/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[2017-10-16 09:38:10:013] [main] INFO BrowserManager - Reading https://api.github.com/repos/mozilla/geckodriver/releases to seek [wires, geckodriver]
[2017-10-16 09:38:10:734] [main] INFO BrowserManager - Latest version of [wires, geckodriver] is 0.19.0
[2017-10-16 09:38:10:795] [main] INFO BrowserManager - Exporting webdriver.gecko.driver as C:\Users\skoleti.ORADEV.m2\repository\webdriver\geckodriver\win64\0.19.0\geckodriver.exe
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/io/CircularOutputStream
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
at com.he.executionlayer.ApiProcessor.getDriver(ApiProcessor.java:723)
at com.he.executionlayer.ApiProcessor.main(ApiProcessor.java:201)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.io.CircularOutputStream
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more

Error when running FireFox tests on Windows

Hi,
can you help me with following issue? Manager correctly gets the driver and then it fails when JVM cannot find class org/openqa/selenium/os/WindowsUtils. I tried to Google this class, but was not able to find out what Maven dependency am I missing.
Thanks,
Karel

2019-09-17 11:52:48 [main] DEBUG io.github.bonigarcia.wdm.Preferences - Preference found firefox69=0.25.0 (valid until 2019-09-18 11:21:47)
2019-09-17 11:52:48 [main] INFO  i.g.bonigarcia.wdm.WebDriverManager - Using geckodriver 0.25.0 (since Mozilla Firefox 69 is installed in your machine)
2019-09-17 11:52:48 [main] DEBUG i.g.bonigarcia.wdm.WebDriverManager - Driver geckodriver 0.25.0 found in cache
2019-09-17 11:52:48 [main] INFO  i.g.bonigarcia.wdm.WebDriverManager - Exporting webdriver.gecko.driver as C:\Users\kfrajtak\.m2\repository\webdriver\geckodriver\win64\0.25.0\geckodriver.exe

java.lang.NoClassDefFoundError: org/openqa/selenium/os/WindowsUtils

	at org.openqa.selenium.firefox.FirefoxBinary.locateFirefoxBinariesFromPlatform(FirefoxBinary.java:403)
	at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:109)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:216)
	at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:165)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
	at io.github.bonigarcia.wdm.test.FirefoxTest.setupTest(FirefoxTest.java:52)

How to set Firefox options

Hello,

I would like to get some advice, on where I can set firefox options using webdrivermanage?
e.g. setting
options.setPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf;text/plain;application/text;text/xml;application/xml");
options.setPreference("pdfjs.disabled", true); // disable the built-in PDF viewer

Thanks a lot.

java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/ChromeDriverManager

I cloned this examples project.
I did mvn test, and got the following errors

Running io.github.bonigarcia.wdm.test.CanvasTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.244 sec <<< FAILURE!
io.github.bonigarcia.wdm.test.CanvasTest Time elapsed: 0.24 sec <<< ERROR!
java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/ChromeDriverManager

Running io.github.bonigarcia.wdm.test.ChromeAndFirefoxTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.002 sec <<< FAILURE!
io.github.bonigarcia.wdm.test.ChromeAndFirefoxTest Time elapsed: 0.002 sec <<< ERROR!
java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/ChromeDriverManager

Help on Selenium Grid execution

Hi Team,

i would like to start Hub and Node (in VM) using Web driver manager. Please help me on how to use Web Driver on Selenium Grid execution.

Thanks,
Vimal

Does not works with M1 out of the box

When I used M1 Mac to run any of the test case, the manager downloaded the intel version of chromedriver instead of m1.

It should check CPU arch automatically and get the correct driver or have an option to download it incase it's failed.

WebDriverManager versions and their corresponding browser versions

We have built a framework in our company and I have suggested to use WebDriverManager. The latest version of WebDriverManager works like a charm with all the browsers that are up-to-date. If we are working on an old version of browser, we need to know which version of the WebDriverManager supports it. In other words, I need the information of which version of WebDriverManager supports the corresponding version of the browsers.

Issue with EdgeBrowser

When i run code in edge browser i am getting below errors

DevTools listening on ws://127.0.0.1:51229/devtools/browser/8ac692d0-9e42-4800-b343-7713ed881345
[14040:7180:0207/133128.733:ERROR:chrome_browser_main_extra_parts_metrics.cc(251)] START: GetDefaultBrowser(). If you don't see the END: message, this is crbug.com/1216328.
[14040:7180:0207/133128.810:ERROR:chrome_browser_main_extra_parts_metrics.cc(255)] END: GetDefaultBrowser()

[9904:11572:0207/140027.094:ERROR:file_io_win.cc(181)] CreateFile C:\Users\SEKHAMX\AppData\Local\Temp\scoped_dir15924_195172586\Crashpad\settings.dat: The system cannot find the path specified. (0x3)
[9904:11572:0207/140027.109:ERROR:file_io_win.cc(181)] CreateFile C:\Users\SEKHAMX\AppData\Local\Temp\scoped_dir15924_195172586\Crashpad\settings.dat: The system cannot find the path specified. (0x3)
[9904:11572:0207/140027.668:ERROR:file_io_win.cc(181)] CreateFile C:\Users\SEKHAMX\AppData\Local\Temp\scoped_dir15924_195172586\Crashpad\settings.dat: The system cannot find the path specified. (0x3)

DevTools listening on ws://127.0.0.1:50269/devtools/browser/f46558c9-790f-4bd9-8fde-aef59f451a24
[10412:13640:0207/140029.550:ERROR:file_io_win.cc(181)] CreateFile settings.dat: Access is denied. (0x5)

DevTools listening on ws://127.0.0.1:61346/devtools/browser/17cc67c0-3bc6-4361-971e-4c0a663fb32a
[5248:11588:0207/144513.859:ERROR:chrome_browser_main_extra_parts_metrics.cc(251)] START: GetDefaultBrowser(). If you don't see the END: message, this is crbug.com/1216328.
[5248:11588:0207/144514.668:ERROR:chrome_browser_main_extra_parts_metrics.cc(255)] END: GetDefaultBrowser()
[640:12496:0207/144707.931:ERROR:gpu_init.cc(469)] Passthrough is not supported, GL is disabled, ANGLE is

[10692:7476:0207/145322.398:ERROR:file_io_win.cc(181)] CreateFile C:\Users\SEKHAMX\AppData\Local\Temp\scoped_dir8672_746580622\Crashpad\settings.dat: The system cannot find the path specified. (0x3)
[10692:7476:0207/145322.403:ERROR:file_io_win.cc(181)] CreateFile C:\Users\SEKHAMX\AppData\Local\Temp\scoped_dir8672_746580622\Crashpad\settings.dat: The system cannot find the path specified. (0x3)
[10692:7476:0207/145322.810:ERROR:file_io_win.cc(181)] CreateFile C:\Users\SEKHAMX\AppData\Local\Temp\scoped_dir8672_746580622\Crashpad\settings.dat: The system cannot find the path specified. (0x3)

DevTools listening on ws://127.0.0.1:61752/devtools/browser/88536fea-7cb6-4feb-8fc5-e369967cac44
[11584:1216:0207/145325.073:ERROR:file_io_win.cc(181)] CreateFile settings.dat: Access is denied. (0x5)
[10692:7476:0207/145325.412:ERROR:fallback_task_provider.cc(123)] Every renderer should have at least one task provided by a primary task provider. If a "Renderer" fallback task is shown, it is a bug. If you have repro steps, please file a new bug and tag it as a dependency of crbug.com/739782.
[10692:224:0207/145327.968:ERROR:chrome_browser_main_extra_parts_metrics.cc(251)] START: GetDefaultBrowser(). If you don't see the END: message, this is crbug.com/1216328.
[10692:224:0207/145328.258:ERROR:chrome_browser_main_extra_parts_metrics.cc(255)] END: GetDefaultBrowser()
[6888:15692:0207/145329.054:ERROR:file_io_win.cc(181)] CreateFile settings.dat: Access is denied. (0x5)

Error : java.lang.ClassNotFoundException: io.github.bonigarcia.wdm.WebDriverManager

Using java version 1.8, Please update on how this issue can be resolved.

Error screenshots

WebDriverManagerError

WebDriverManager program

Complete error description

Exception in thread "main" java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/WebDriverManager
at com.InProgress.WebDriverManagerAPI.initializeMethod(WebDriverManagerAPI.java:17)
at com.InProgress.WebDriverManagerAPI.main(WebDriverManagerAPI.java:35)
Caused by: java.lang.ClassNotFoundException: io.github.bonigarcia.wdm.WebDriverManager
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

[Headless] This version of ChromeDriver only supports Chrome version 102 Current browser version is 107.0.5304.89

Can't start ChromeDriver in headless mode, however in UI mode it starts without issues.

These are my options:

var chromeOptions = new ChromeOptions();
                        chromeOptions.AddExtension(Path.Combine(Config.pathToRegression, "disablevisibilityapi.crx"));
                        chromeOptions.UnhandledPromptBehavior = UnhandledPromptBehavior.AcceptAndNotify;
                        chromeOptions.AddArgument("--headless");
                        chromeOptions.AddArgument("--window-size=1920,1080");
                        chromeOptions.AddArgument("--safebrowsing-disable-download-protection");
                        chromeOptions.AddArgument("safebrowsing-disable-extension-blacklist");                   
                        chromeOptions.AddUserProfilePreference("download.default_directory", Config.pathToDownloads);
                        chromeOptions.AddUserProfilePreference("profile.default_content_setting_values.automatic_downloads", 1);
                        chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true");
                        chromeOptions.AddUserProfilePreference("safebrowsing.enabled", true);
                        chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);

                        new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.Latest);
                        var service = ChromeDriverService.CreateDefaultService();
                        webDriverInstance = new ChromeDriver(service, chromeOptions);
                        break;
Stack Trace:
WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
WebDriver.StartSession(ICapabilities desiredCapabilities)
WebDriver.ctor(ICommandExecutor executor, ICapabilities capabilities)
ChromiumDriver.ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
ChromeDriver.ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
ChromeDriver.ctor(ChromeDriverService service, ChromeOptions options)

webdrivermanager is typing very slow in text field on IE browser

I am using below dependencies to implement webdrivermanager in my project and it works fine on FF and Chrome. But on it IE sendkeys is typing very slow.

IE version is 11.0.96

	<dependency>
		<groupId>io.github.bonigarcia</groupId>
		<artifactId>webdrivermanager</artifactId>
		<version>3.0.0</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>io.github.bonigarcia</groupId>
		<artifactId>selenium-jupiter</artifactId>
		<version>2.2.0</version>
	</dependency>

		// DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
		// // this line of code is to resolve protected mode issue
		// capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
		// true);
		// capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
		// capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
		// capabilities.setCapability("requireWindowFocus", true);
		//
		//
		//// capabilities.setCapability("nativeEvents", false);
		//// capabilities.setCapability("unexpectedAlertBehaviour", "accept");
		//// capabilities.setCapability("ignoreProtectedModeSettings", true);
		//// capabilities.setCapability("disable-popup-blocking", true);
		//// capabilities.setCapability("enablePersistentHover", true);
		//
		// String IEexePath =
		// "src\\\\main\\\\resources\\\\driver\\\\IEDriverServer.exe";
		// System.setProperty("webdriver.ie.driver", IEexePath);
		// driver = new InternetExplorerDriver(capabilities);
		DesiredCapabilities IEcapabilities = DesiredCapabilities.internetExplorer();
		IEcapabilities.setCapability("requireWindowFocus", true);
		WebDriverManager.iedriver().setup();
		driver = new InternetExplorerDriver(IEcapabilities);
		driver.manage().window().maximize();
		driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);

IE11: webdriver doesn't execute driver.close()

@Test public void launchSite() { WebDriverManager.iedriver().setup(); // WebDriverManager.iedriver().arch64().setup(); driver = new InternetExplorerDriver(); driver.manage().window().maximize(); try { driver.get("https://www.wikipedia.org/"); } catch (TimeoutException e) { System.out.println("TimeoutException error is thrown and later handled"); } driver.close(); }

For the above test method, the IE11 browser was up and was loaded the page. But the problem is, the browser doesn't get closed and remains open. Later, it throws timeOutError.

java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/WebDriverManager

Hi, I am getting the following error. I am new to Maven and selenium. Some one please help me.

C:\Users\win10\vilcart\vilcart-app>java -cp target\vilcart-app-1.0-SNAPSHOT.jar com.vilcart.app.App
Exception in thread "main" java.lang.NoClassDefFoundError: io/github/bonigarcia/wdm/WebDriverManager
at com.vilcart.app.App.main(App.java:16)
Caused by: java.lang.ClassNotFoundException: io.github.bonigarcia.wdm.WebDriverManager
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more

package com.vilcart.app;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

/**

  • Hello world!

*/
public class App
{
public static void main( String[] args )
{
WebDriverManager.chromedriver().setup();
ChromeDriver driver = new ChromeDriver();
System.out.println( "Hello World!" );
driver.quit();
}
}

My pom.xml file is.


4.0.0

com.vilcart.app
vilcart-app
1.0-SNAPSHOT

vilcart-app

http://www.example.com

UTF-8 18 18 junit junit 4.13.2 org.testng testng 7.6.0 compile
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.2.2</version>
</dependency>
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>5.2.0</version>
</dependency> 
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-shade-plugin -->
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.3.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-api -->
<dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-api</artifactId>
	<version>4.2.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-chrome-driver</artifactId>
	<version>4.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<dependency>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>3.0.0-M7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<dependency>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.10.1</version>
</dependency>
maven-clean-plugin 3.2.0 maven-resources-plugin 3.2.0 maven-compiler-plugin 3.8.0 maven-surefire-plugin 3.0.0-M7 org.apache.maven.plugins maven-shade-plugin 3.3.0 package shade com.vilcart.app.App maven-install-plugin 3.0.0-M1 maven-deploy-plugin 3.0.0-M2 maven-site-plugin 4.0.0-M1 maven-project-info-reports-plugin 3.3.0 org.apache.maven.plugins maven-source-plugin 3.2.1

Tests Don't Work

None of these tests work. Getting the below error running them

java.lang.NoClassDefFoundError: com/typesafe/config/ConfigFactory
at io.github.bonigarcia.wdm.WdmConfig.(WdmConfig.java:37)
at io.github.bonigarcia.wdm.WdmConfig.getInstance(WdmConfig.java:43)
at io.github.bonigarcia.wdm.WdmConfig.getString(WdmConfig.java:51)
at io.github.bonigarcia.wdm.BrowserManager.getDriverVersion(BrowserManager.java:99)
at io.github.bonigarcia.wdm.BrowserManager.setup(BrowserManager.java:659)
at io.github.bonigarcia.wdm.test.PhatomJsTest.setupClass(PhatomJsTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: com.typesafe.config.ConfigFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more

WebDriverManager doesnt run headless for Chrome

Hi,

I have just started using WebDriverManager and think it's great. One issue I have come across is that is doesn't seem to run Chrome headless.

Please see examples below, one where I'm using WebDriverManager and one where I'm specifying a ChromeDriver location on my pc. When the pc location is specified the test is run in headless mode. I am using WebDriverManager version 3.7.1.

I'm sure there's something I'm missing, would appreciate any help.

Thanks

WDM code

public class SimpleWDMChrome_Test {

private WebDriver driver;

@BeforeClass
public static void setupClass() {
    WebDriverManager.chromedriver().setup();
}

@Before
public void setupTest() {
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless");
    options.addArguments("--disable-gpu");
    driver = new ChromeDriver(options);
}

@After
public void teardown() {
    if (driver != null) {
        driver.quit();
    }
}

@Test
public void test() {
    driver.get("https://www.bbc.co.uk/sport/football");
    String title = driver.getTitle();
    System.out.println(title);
}

Chromedriver on PC code

public class SimpleWDMChrome_Test {

private WebDriver driver;

@BeforeClass
public static void setupClass() {
    WebDriverManager.chromedriver().setup();
    System.setProperty("webdriver.chrome.driver", "C:\\Drivers\\Chrome\\chromedriver_win32\\chromedriver.exe");
}

@Before
public void setupTest() {
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless");
    options.addArguments("--disable-gpu");
    driver = new ChromeDriver(options);
}

@After
public void teardown() {
    if (driver != null) {
        driver.quit();
    }
}

@Test
public void test() {
    driver.get("https://www.bbc.co.uk/sport/football");
    String title = driver.getTitle();
    System.out.println(title);
}

Initializing Edge Driver Question

Hi Mr. Garcia,

I am trying to figure out how to drive the EdgeDriver for my Windows 10 computer.

At this point, I have tried the following (Java) code to initiate Edge:

EdgeDriverManager.getInstance().version("3.14393").setup();

On the basis that EdgeDriver is enacted by the OS Build (14393.1480) and not so much by the Driver version, please advise on what I could be doing wrong.

Thanks!

-Henry C.

[Question] How use option for headless mode of browser ?

Hello community,
I have simple question - how i run my browser using your dependency with headless mode ?

in standard for selenium, in method to 'init webdriver' something like this :

ChromeOptions opts = new ChromeOptions();
opts.addArguments("--headless");

or ff

opts.addArguments("--headless");
return webdriver = new FirefoxDriver();

how have this in this driver manager ?

Connection Refuse error for Firefox 52.9.0 (32-bit)

Hi Sir ,
I am getting below error while trying to run test in firefox through webdrivermanager .Could you please take a look and reply whats issue . I have 32 bit firefox installed however geckodriver is of 64 bit .Is that the root cause ?
org.openqa.selenium.WebDriverException: connection refused
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'VDF-SYNDEV10', ip: '10.177.225.71', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_112'
Driver info: driver.version: FirefoxDriver

Issue on GridLauncherV3

need to launch the Selenium Hub and Node via direct a Java Program, I saw examples online for launching it via GridLauncherV3 from Selenium.

(already imported all required library)
import io.github.bonigarcia.wdm.WebDriverManager;

public static void main(String[] args) throws Exception {
WebDriverManager.chromedriver().setup();
GridLauncherV3.main(new String[] { "-role", "node", "-hub", "http://localhost:4444/grid/register", "-browser",
"browserName=chrome", "-port", "5555" });
}

But getting below error.

11:29:55.499 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
11:29:55.704 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 5555
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.openqa.grid.internal.utils.SelfRegisteringRemote.(SelfRegisteringRemote.java:83)
at org.openqa.grid.internal.utils.SelfRegisteringRemote.(SelfRegisteringRemote.java:72)
at org.openqa.grid.selenium.GridLauncherV3.lambda$buildLaunchers$7(GridLauncherV3.java:281)
at org.openqa.grid.selenium.GridLauncherV3.lambda$launch$0(GridLauncherV3.java:86)
at java.util.Optional.map(Optional.java:215)
at org.openqa.grid.selenium.GridLauncherV3.launch(GridLauncherV3.java:86)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:70)
at Demo.StartHub.main(StartHub.java:24)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

ChromeDriver not working

For any Chrome-related test of this project, I am getting an exception

org.openqa.selenium.SessionNotCreatedException: session not created exception: 
Chrome version must be >= 58.0.3029.0

Steps to reproduce

$ git clone [email protected]:bonigarcia/webdrivermanager-examples.git
$ cd webdrivermanager-examples/
webdrivermanager-examples $ mvn clean verify

Full exception is (from ChromeTest):

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running io.github.bonigarcia.wdm.test.ChromeTest
[2017-06-12 11:29:22:956] [main] INFO BrowserManager - Reading https://chromedriver.storage.googleapis.com/ to seek [chromedriver]
[2017-06-12 11:29:23:573] [main] INFO BrowserManager - Latest version of [chromedriver] is 2.30
[2017-06-12 11:29:23:580] [main] INFO BrowserManager - Exporting webdriver.chrome.driver as /home/markus-tarent/.m2/repository/webdriver/chromedriver/linux64/2.30/chromedriver
Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 29370
Only local connections are allowed.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.904 sec <<< FAILURE! - in io.github.bonigarcia.wdm.test.ChromeTest
test(io.github.bonigarcia.wdm.test.ChromeTest)  Time elapsed: 0.59 sec  <<< ERROR!
org.openqa.selenium.SessionNotCreatedException: session not created exception: Chrome version must be >= 58.0.3029.0
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.0-79-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 326 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'markus-Aspire-VN7-592G', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-79-generic', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
	at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
	at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
	at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$22(ProtocolHandshake.java:365)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
	at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
	at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:368)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
	at io.github.bonigarcia.wdm.test.ChromeTest.setupTest(ChromeTest.java:49)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.