Say GoodBye to Driver.exe !!


Say GoodBye to Driver.exe !!

As we all know, while using Selenium WebDriver for each browser such as Chrome, Firefox, MS Edge or IE, we need to first separately download its binary file which allows, WebDriver to handle browsers then we need to provide the absolute path of this binary in the system properties to launch the respective browsers.

It is actually quite frustrating as we need to manually check for a different version, install and use this binary files in our automation scripts.

WebDriver Manager is a solution to all these problems. WebDriver Manager allows us to:
ü  It checks the version of the browser installed in your machine (e.g. Chrome, Firefox).
ü  It checks the version of the driver (e.g. chrome driver, geckodriver). If unknown, it uses the latest version of the driver.
ü  It downloads the WebDriver binary if it is not present on the WebDriverManager cache (~/.m2/repository/webdriver by default).
ü  It exports the proper WebDriver Java environment variables required by Selenium (not done when using WebDriverManager from the CLI or as a Server)


To Know more about WebDriver Manager. Please click on this link.

To use WebDriver Manager we need to download its maven dependency by using this link.

In this blog for demo purposes, I am using below maven dependency.



Now in our automation script instead of writing the below line of code
System.setProperty("webdriver.chrome.driver", "/absolute/path/to/binary/chromedriver");

System.setProperty("webdriver.gecko.driver", "/absolute/path/to/binary/geckodriver");

We can use below code to launch chrome browser
WebDriverManager.chromedriver().setup();

Below code to launch FireFox browser
WebDriverManager.firefoxdriver().setup();

Full Code would be something like:






SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
April 16, 2019 at 8:01 AM

I got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at io.github.bonigarcia.wdm.WebDriverManager.(WebDriverManager.java:93)
at test.TestDriverManager.main(TestDriverManager.java:10)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 2 more

I using the same WebDriverManager version and the run the same Full Code

Reply
avatar
Anonymous
April 16, 2019 at 8:39 AM

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I got this issue:
Apr 16, 2019 10:04:54 AM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

Reply
avatar
April 24, 2019 at 11:20 AM

we are getting error:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.io.IOUtils.toString(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Ljava/lang/String;

Do we need to add any dependency in pom.xml apart from webdrivermanager dependency ?

Reply
avatar
April 24, 2019 at 11:22 AM

Hi Ankura,

We are getting error:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.io.IOUtils.toString(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Ljava/lang/String;

Do we need to add any dependency in pom.xml apart from webdrivermanager dependency ?

Reply
avatar
May 24, 2019 at 6:11 PM

Hi Ankur jain,
What is your approach to resolve if the multiple builds fail and jenkins slave is not responding like take longer time for execution than required?

Reply
avatar
June 29, 2019 at 10:43 PM

it is seriously not working. I am really impressed by your other blogs but not this one.

Reply
avatar
June 30, 2019 at 9:12 AM

Hi Abhishek ,Can you please share exact error message screenshot,code and issue you are facing while implementing this on my email id ankur.jain.cs@gmail.com.

Till now lot of people have implemented this without any issue and the issue that might have reported out is due to other incorrect dependencies in their pom.xml.

Happy to help you out in case of any issue..

Reply
avatar