In BASE CLASS
public class BaseClass {
public static WebDriver driver;
public void getDriver() {
System.setProperty("webdriver.chrome.driver",
"D:\\Assignments\\Tasks\\Framework_Task\\adactinhotelapp\\adactinhotelapp\\Drivers\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
public void launchUrl(String url) {
driver.get(url);
}
}
In then while I running it
public class SampleClassWithTestNg extends BaseClass {
static BaseClass global = new BaseClass();
@BeforeTest
public void driverConfiguring() {
global.getDriver();
global.launchUrl("http://adactinhotelapp.com/");
}
}
but I'm getting error
java.lang.IllegalStateException: The driver executable does not exist: D:\Assignments\Tasks\Framework_Task\adactinhotelapp\Drivers\chromedriver.exe
Please check the chromedriver.exe
file because the exact code is working fine for me.
Screenshot:
java.lang.IllegalStateException: The driver executable does not exist:
The above error, clearly indicate that there is some issue with the chromedriver.exe
file.
As per the path mention, I can assume you are using windows, so make sure:
Chromrdriver
path is correct - If possible provide screenshot of the directory with path.
You have permission to execute the chromedriver
.
Download the correct Chromedriver
version for platform:
https://sites.google.com/a/chromium.org/chromedriver/downloads https://chromedriver.chromium.org/downloads https://chromedriver.storage.googleapis.com/index.html
Note: For ubuntu and Mac the chromedriver shouldn't contain.exe as extension.
You can also remove the hassle of definingSystem.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
by using WebDriverManager .
To use WebDriverManager from tests in a Maven project, you need to add the following dependency in your pom.xml (Java 8 or upper required).
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.4.3</version>
</dependency>
Just use:
WebDriverManager.chromedriver().setup();
instead of System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.