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.access$000(ChromeDriverService.java:35)
and same code is working with .exe files but not when we are loading through WebDriverManager.