0

We can run our tests in different browsers in selenium Webdriver, previously we need to executable files to run our test in any browser. But now we can achieve without using exe files & with the help of WebDriverManager following below syntax to open chrome browser.

 WebDriverManager.iedriver().setup();
 driver = new ChromeDriver();

Driver class I have defined below code:

public static WebDriver getDriver(){
 try{
 if(driver == null) {
 /* PropertiesFileReader obj=new PropertiesFileReader(); 
 Properties properties=obj.getproperty();
 openBrowser(properties.getProperty("browserName"), properties.getProperty("URL")); */
 WebDriverManager.iedriver().setup();
 driver = new ChromeDriver();
 }
 }catch(Exception e) {
 e.printStackTrace();
 }
 return driver;
 }

I have login page and logintestcase, I am calling getDriver() method from logintest class using below code:

public LoginPage loginpage=PageFactory.initElements(Driver.getDriver(), LoginPage.class);

But I am getting exception :

 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.
 java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
 at com.google.common.base.Preconditions.checkState(Preconditions.java:843)
 at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:135)
 at org.openqa.selenium.chrome.ChromeDriverService.access000ドル(ChromeDriverService.java:35)

and same code is working with .exe files but not when we are loading through WebDriverManager.

Bharat Mane
6,78512 gold badges42 silver badges69 bronze badges
asked May 3, 2019 at 6:00
2
  • your test failed just because you are using iedriver().setup(); which is used for IE Browser but below you declare the instance of ChromeDriver. Commented May 3, 2019 at 6:49
  • The thing I am observed is chrome is updating quietly from behind most of the times if I change the chrome driver to updated version my program start working normally. Commented Feb 27, 2020 at 6:01

1 Answer 1

0

Try this may this code help you-

 WebDriver driver;
public static WebDriver getDriver(){
 try{
 if(driver == null) { 
 WebDriverManager.chromedriver().setup();
 driver = new ChromeDriver();
 }
 }catch(Exception e) {
 e.printStackTrace();
 }
 return driver;
 } 

If you want to add more capabilities in webdrivermanager try this too-

WebDriverManager.chromedriver()
 .version("2.40")
 .arch32()
 .proxy("myproxyhostname:80")
 .proxyUser("myusername")
 .proxyPass("myawesomePassword")
.setup();
answered May 3, 2019 at 6:37
8
  • SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See slf4j.org/codes.html#StaticLoggerBinder for further details. io.github.bonigarcia.wdm.WebDriverManagerException: io.github.bonigarcia.wdm.WebDriverManagerException: chromedriver 66.0.3359.181 for WIN64 not found in npm.taobao.org/mirrors/chromedriver Commented May 3, 2019 at 7:14
  • You need to add following jar file in your classpath: slf4j-simple-1.6.2.jar and for chromedriver exception try to download the correct version by using .Version() capabilitiy of WebDriverManager. Commented May 3, 2019 at 7:31
  • nable to read VR Path Registry getting for firefoxdriver, refer ccode-- WebDriverManager.firefoxdriver().version("0.21.0").setup(); driver=new FirefoxDriver(); Commented May 3, 2019 at 9:30
  • Is your chromeDriver working? Commented May 3, 2019 at 9:35
  • chrome is working perfectly Commented May 3, 2019 at 9:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.