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

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.

Related

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

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

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/");

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;

Firefox browser not invoking from Selenium Webdriver version 3.4.0

So here is the issue:
Basically I'm trying to invoke Firefox browser with selenium.
package basics;
import org.openqa.selenium.WebDriver;
public class BrowserInvocation {
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
// There is no import option displaying when mouse over FirefoxDriver such as **import org.openqa.selenium.firefox.FirefoxDriver;**
Console output:
Exception in thread "main" java.lang.Error: Unresolved compilation
problem:
FirefoxDriver cannot be resolved to a type at
basics.firefox.main(firefox.java:19)
I'm using latest versions of all software involve (as of May 15 2017) like firefox, java, eclipse and selenium. I have use 32 bit versions and 64 bit versions. tried removing everything and setup environment again but no luck.
I have tried invoking chrome in same environment with chrome driver and so far at least I can invoke the browser.

Error in selenium webDriver while executing the normal test case

Here is my code for selenium webDriver
package com.pack;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GoogleSearchTest {
public static void main(String...args) {
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://google.com");
String appTitle = driver.getTitle();
System.out.println("Application title is :: "+appTitle);
driver.quit();
}
}
Below is the Error I am getting:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
WebDriver cannot be resolved to a type
FirefoxDriver cannot be resolved to a type
at com.pack.GoogleSearchTest.main(GoogleSearchTest.java:9)
I need to understand why I am getting that error.
Looks like you are trying to run the code that is already having compilation issues. You should be seeing a tab called "Problems", where it shows all/ any possible errors and warnings. Do you see anything in that tab? If so it will walk through the steps that you need to follow to overcome the issue.
The other option is to download a fresh copy of eclipse IDE and configure your selenium. Let me know which one worked for you.