Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Sujata_Selenium_workspace\chromedriver.exe [duplicate] - selenium

This question already has an answer here:
java.lang.IllegalStateException: The driver executable does not exist: C:\Users\jagrelot\workspace\AntBuildExample\chromedriver.exe with ChromeDriver
(1 answer)
Closed 3 years ago.
xception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Sujata_Selenium_workspace\chromedriver.exe
Errors is showing.
package seleniumWebdriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class LaunchBrowser {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Sujata_Selenium_workspace\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.seleniumhq.org/download/");
}
}

I think your chromedriver does not placed in the path your defined "C:\Sujata_Selenium_workspace\chromedriver.exe"
Either place the chromedriver in the path or place it somewhere in D or E drive like
D:/Selenium/chromedriver.exe
Code like
System.setProperty("webdriver.chrome.driver", "D:/Selenium/chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.seleniumhq.org/download/");

Related

Selenium not opening the browser and the code instead runs in JAVA console and throws error message

package firstSeleniumTesting;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class testingAutomation {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.drive", "C:\\SeleniumDriver\\chromedriver_win32");
WebDriver driver = new ChromeDriver(); //Launches Firefox
driver.close();
}
}
I get the following error
Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable 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 https://chromedriver.storage.googleapis.com/index.html
at org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:280)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:132)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:38)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:231)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:434)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:127)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:46)
at firstSeleniumTesting.testingAutomation.main(testingAutomation.java:13)
Add the .exe in the chromedriver
Use like this
System.setProperty("webdriver.chrome.driver", "C:\\SeleniumDriver\\chromedriver_win32.exe");
WebDriver driver = new ChromeDriver();
driver.close();

WebDriver cannot be resolved to a type ChromeDriver cannot be resolved to a type [duplicate]

This question already has answers here:
java.lang.Error: Unresolved compilation problems : WebDriver/ChromeDriver cannot be resolved to a type error while executing selenium tests
(5 answers)
Closed 3 years ago.
I am using all latest versions as in below but still see the issue said in above. Can someone help with it.
Eclipse IDE Version: 2019-12 (4.14.0);
WebDriver (Java) - 3.141.59
ChromeDriver 79.0.3945.36
Here is my code:
package AutomationFrameWork;
import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
org.openqa.selenium.chrome.*;
public class FirstTestCase {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "C:\\Users\\xxxx.000\\Desktop\\Selenium\\chromedriver_win32\\chromedriver.exe");
driver.get("www.google.ca");
System.out.println("Successfully opened the website");
driver.quit();
}
}
Error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
WebDriver cannot be resolved to a type
ChromeDriver cannot be resolved to a type
at AutomationFrameWork.FirstTestCase.main(FirstTestCase.java:15)
You need to give like this .Also better to put in a folder than putting on the desktop.
WebDriver driver;
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"\\Jar_files\\chromedriver.exe");
driver = new ChromeDriver();
System.setProperty() should be prior to driver intialization.
Also check version of chrome browser and chrome driver are in sync.

Selenium Code: Specified URL is not opening [duplicate]

This question already has answers here:
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property
(4 answers)
Closed 3 years ago.
In the below code, the browser got opened but the URL is not typed by the script. Can anyone please suggest me the corrections needed for this script?
package SeleniumDemo;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class S {
public static void main(String[] args) throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
WebDriver DRIVER = new ChromeDriver();
String URL = "http://www.facebook.com";
DRIVER.manage().window().maximize();
DRIVER.get(URL);
System.out.println(DRIVER.getTitle());
DRIVER.close();
}
}
System.setProperty should point to you chrome driver location not chrome application
In your code you have specified wrong path of chromedriver.exe. It should be chromedriver.exe not chrome.exe. Also, check your chrome browser version and based on that download chromedriver to execute your program.
System.setProperty("webdriver.chrome.driver", "path of chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
System.out.println("Page title is: " + driver.getTitle());
You can download chromdriver from below location:
https://chromedriver.chromium.org/downloads

Selenium-Firefox Driver Issue (Firefox Driver cannot be resolved to a type [duplicate]

This question already has answers here:
ChromeDriver and WebDriver for Selenium through TestNG results in 4 errors
(2 answers)
Closed 4 years ago.
I am trying to write simple selenium scripts using maven ,But getting an error with firefox driver despite downloading all the dependent selenium jars through maven.
Refer the screenshot below: Any help is deeply appreciated
enter image description here
Try this code :
public class NewTest {
public WebDriver driver;
#BeforeClass
public void setupClass() {
System.setProperty("webdriver.gecko.driver", "C:\\Users\\***\\Downloads\\chromedriver_win32\\geckodriver.exe");
driver = new FirefoxDriver();
}
#Test
public void openMyBlog() {
driver.get("http://www.google.com");
System.out.println("This is first test");
}
#AfterClass
public void tearDownClass() {
// driver.quit();
}
}
Make sure you have imported all required packages.
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Selenium\geckodriver.exe

I am getting below exception while trying to open a site
Exception in thread "main" java.lang.IllegalStateException: The driver
executable does not exist: C:\Selenium\geckodriver.exe at
com.google.common.base.Preconditions.checkState(Preconditions.java:534)
at
org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:136)
at
org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:131)
at
org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
at
org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:141)
at
org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at
org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:158)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120)
at
org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98)
at com.tst.Test.main(Test.java:12)
My code is:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:/Selenium/geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("http://www.google.co.in");
I am using selenium 3 with geckodriver-v0.19.1-win64.zip. and java version is 1.8.
Please help me out
You need to setPath properly for binary file. On windows, I prefer \\ instead od /, Can you please try this?-
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:\\Selenium\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("http://www.google.co.in");