First Chrome browser test in Selenium show errors

246 views
Skip to first unread message

Gabs

unread,
Mar 30, 2020, 1:13:33 PM3/30/20
to Selenium Users
I hope somebody can help.

I have just written my first test code to open a Chrome browser with Selenium & java in Eclipse but it is just returning errors.

STEPS.
1. I created the project, package and class as normal.
2. I added the external JAR files in the classpath Libraries through build part for the project for the Selenium Webdriver (2 X client combined files and the content of the Lib folder). screenshot attached as JAR Files.
3. Java code attached (Screenshot attached as Java Selenium code).

package seleniumPackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class seleniumCode {

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Others\\Downloads\\chromedriver_win32");
WebDriver driver = new ChromeDriver();

}

}

4. I import the Webdriver and Chrome driver as normal.
5. When I run the code with or without the System.setProperty in the code I just get errors in screenshot and as below.

Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: C:\Users\Others\Downloads\chromedriver_win32
at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:148)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at seleniumPackage.seleniumCode.main(seleniumCode.java:10)

Selenium doesn't look user friendly or am I missing something vital?

Thanks in advance.
Gabs


JAR Files.JPG
Java Code and error.JPG

Anil Gursahani

unread,
Mar 30, 2020, 4:13:10 PM3/30/20
to Selenium Users
Hi Gabs,

You are missing the name of the chromedriver.exe file.  The command should be - System.setProperty("webdriver.chrome.driver", "C:\\Users\\Others\\Downloads\\chromedriver_win32\\chromedriver.exe") or whatever the name of the chromedriver executable file is.
Reply all
Reply to author
Forward
0 new messages