Download Browser driver binding from Maven repository

997 views
Skip to first unread message

Vimal Kumar

unread,
Mar 28, 2019, 7:21:12 AM3/28/19
to Selenium Users
Hi All,

Like Jars file, is it possible to download various browser drivers like Chrome, Firefox, Edge using Maven dependency pom xml

Thanks
Vimal

Message has been deleted

Ragnor

unread,
Mar 28, 2019, 8:09:38 AM3/28/19
to Selenium Users
Hello,

Yes you can do by using "webdriver-manager". 
Refr:- https://github.com/bonigarcia/webdrivermanager

Simpy add dependency in POM xml:
mvnrepository URL- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager/3.4.0

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.4.0</version>
</dependency>



Sample Code:-

public class Test1 {
 
private WebDriver driver;
 
@BeforeClass
 
public void setUp() {
 
WebDriverManager.chromedriver().setup();
 driver 
= new ChromeDriver();
 
}
 
@Test
 
public void Mytest() {
 driver
.get("https://www.google.com");
 
}
 
@AfterClass
 
public void tearDown() {
 
if(driver!=null)
 driver
.quit();
 
}


}


Note:- Here we are not passing browser driver location where we usually put the all drivers in project directory.
e.g:

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\Drivers\\chromedriver.exe");
Instead we using "setup()" function of webdriver-manager

Similarly  we can call other browsers.

WebDriverManager.chromedriver().setup();
WebDriverManager.firefoxdriver().setup();
WebDriverManager.operadriver().setup();
WebDriverManager.phantomjs().setup();
WebDriverManager.edgedriver().setup();
WebDriverManager.iedriver().setup();

If you wanted to use any specific version of browser then simply use "version()" function.

WebDriverManager.chromedriver().version("2.26").setup();

Thanks,
Sanket

Mark Collin

unread,
Mar 29, 2019, 6:17:44 AM3/29/19
to Selenium Users

Vimal Kumar

unread,
Apr 8, 2019, 3:24:08 PM4/8/19
to Selenium Users
Sanket, 

Actually i have added maven dependency in pom xml and when trying running the script, im getting below error.  (In fact, we are not using SLF4j Logger. we have used log4j logger in the framework)

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
Apr 08, 2019 3:05:17 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.

Mark Collin

unread,
Apr 8, 2019, 3:34:02 PM4/8/19
to Selenium Users
That’s a warning, not an error.

Don’t worry about it

Vimal Kumar

unread,
Apr 8, 2019, 4:18:11 PM4/8/19
to Selenium Users
Mark,

Below is the actual error. 


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
Apr 08, 2019 4:07:00 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.

FAILED CONFIGURATION: @BeforeClass setUp
io.github.bonigarcia.wdm.WebDriverManagerException: org.apache.http.conn.HttpHostConnectException: Connect to npm.taobao.org:80 [npm.taobao.org/114.55.80.225] failed: Connection timed out: connect

Thanks,
Vimal

Mark Collin

unread,
Apr 8, 2019, 4:22:08 PM4/8/19
to Selenium Users
Looks like the package it’s referencing no longer exists

https://npm.taobao.org/package/114.55.80.225

I’d raise a bug with the maintainer (check you are using the latest version first)

Vimal Kumar

unread,
Apr 8, 2019, 4:29:08 PM4/8/19
to Selenium Users
Mark, 

Not sure which latest version you are referring. i dont have much idea about it, 

i have used this one which is latest.

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.4.0</version>
</dependency>

I have tried even lower version, but pom.xml itself giving error (Failed to read artifact descriptor for io.gitub.nonigarcia:webdrivermanager.jar )

Mark Collin

unread,
Apr 9, 2019, 3:47:58 AM4/9/19
to Selenium Users
It looks like you are using the latest version, I'm not sure why it's trying to pull down something that doesn't seem to exist.  I would raise an issue at https://github.com/bonigarcia/webdrivermanager/issues

Of course you can give this a go instead and see if it works for you ;) :

Vimal Kumar

unread,
Jul 7, 2019, 11:47:09 AM7/7/19
to Selenium Users

Hi Sanket,

Using WebDriver Manager, trying to star hub using selenium java

 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.<init>(SelfRegisteringRemote.java:83)
at org.openqa.grid.internal.utils.SelfRegisteringRemote.<init>(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)
Reply all
Reply to author
Forward
0 new messages