I m Getting error as soon as I Initialize driver new ChromeDriver

+1 vote
below is my code.

package com.salesforce.pageobject;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.BeforeClass;

public class BaseClass {

// public String url =

// public String username =

// public String password =

public static WebDriver driver;

@BeforeClass

public void setup()

{

System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"//Drivers//chromedriver.exe");

    driver = new ChromeDriver();

}

I'm getting error at very first line (package com.salesforce.pageobject;) and driver = new ChromeDriver();

when I initiaize WebDriver means when I write driver = new ChromeDriver();

Error that I get at package com.salesforce.pageobject; is below

(The type org.openqa.selenium.remote.RemoteWebDriver cannot be resolved. It is indirectly referenced from required .class files)

for driver = new ChromeDriver(); it's Type mismatch: cannot convert from ChromeDriver to WebDriver
Aug 22, 2019 in Selenium by Prajwal Wakekar
33,864 views

2 answers to this question.

+6 votes

Hi Prajwal, this type of error occurs when you have added the external jars in the ModulePath. To resolve this issue, you can remove the external jars from the node "Modulepath". Select the node "Classpath" then add the external jars. Review that all the jars are under the node "Classpath"

Hope this helps!

Check out selenium online training for more!

answered Oct 11, 2019 by Abha
• 28,140 points

edited Sep 6, 2023 by Khan Sarfaraz
Thank you. It was such a simple fix
Thankyou. It was a great fix!!
Thankyou, it worked out.
what if the classpath is not shown?
Hey, could you please post the error that you are getting in that case?
Thank you!
This was basic fix that I didn't find elsewhere.
Thanks a lot couldn't find this fix anywhere else!
Thank you so much.
thanks for your answer
Thanks for your contribution! Do upvote the answer in case you found it helpful.

Cheers!
hii...can anyone explain step by step to fix this issue...i am not able to fix from the answer..not able to get the classpath and all mentioned...please help me asap...please
Hey @Avishek, In eclipse IDE, right click on your project, select  configure build path. Now select classpath and add the external dependency files. This should do!
yes i have tried that...but not able to see any classpath or modulepath anywhere in my project...why is that so..how to fix now
ok...but which jar files i need to add to fix this issue...i have already added JRE...is there  any external jars need to download and add to overcome this issue...issue is "The type org.openqa.selenium.remote.RemoteWebDriver cannot be resolved. It is indirectly referenced from required .class files" and "Type mismatch: cannot convert from ChromeDriver to WebDriver"....please let me know...need help as i have a project to submit

This means 'RemoteWebDriver' dependency is not added to your project. You need to add a maven dependency of 'RemoteWebDriver' to fix this issue.

Add below dependency in your pom.xml and refresh the project.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-driver</artifactId>
    <version>3.6.0</version>
</dependency>
I have added the dependency also...still not resolved...dont know why its happening
Have you tried changing the compiler level in eclipse as suggested by another answer?
yes...i tried that too

Above error shows up when you do not have JRE or JDK not added to your build path. This is the well-known bug with Eclipse.

The possible solution is

  1. Close the project and reopen it.
  2. Clean the project (It will rebuild the build path hence reconfiguring with the JDK libraries  OR
  3. Delete and Re-import the project and if necessary do the above steps again
Thanks a lot Abha....its working :)
I Searched all over the internet for this issue and finally It got resolved when I removed it from module path and added under class path..Thanks a ton
Thank you so much, I have been searching all places like hell and finally I solved it thanks to your answer!

Didn't expected that "classpath" was the solution ^^ now i understand it was there for something
Thanks it worked for me.
Hi @KK, thank you for your contribution to the Edureka Community.

Register/Sign up on the community to gain points for further contributions. You may ask questions, answer, upvote, and downvote an answer. Each of these would fetch you points and you could be among the top contributors and win exciting merchandise from Edureka.

Cheers!
Thank u for the quick fix idea...it was really help full.
Great Help this worked for me

I have

Eclipse Version: 2020-09 (4.17.0)

java version "15.0.1" 2020-10-20

Selenium WebDriver: v3.141.59
excellent for me .... fixed the issue
You save my day. error resloved
+1 vote
If still getting the error "WebDriver cannot be resolved", after adding jar files to class path, go to Project -> Properties -> Java Compiler -> Change compiler level to 1.7 or so in Eclipse. This will resolve the errors.
answered Apr 9, 2020 by anonymous
Thanks heaps...It worked..hurray....was scratching my head off since last night...Thanks once again :)
Hi @Nishi, thank you for your contribution to the Edureka Community.

Register/Sign up on the community to gain points for further contributions. You may ask questions, answer, upvote, and downvote an answer. Each of these would fetch you points and you could be among the top contributors and win exciting merchandise from Edureka.

Cheers!
Hi, This worked for me, thank you so much

But didnt understand the new package restriction issue?
Hey @Sowmya Anakamahadeva, there might be some dependency/compatibility issues with the old package. Hence upgrading it to new package would help.
Great Help this worked for me

I have

Eclipse Version: 2020-09 (4.17.0)

java version "15.0.1" 2020-10-20

Selenium WebDriver: v3.141.59
Thanks..It also resolve my problem.It was same of compiler level

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

When i give WebDriver driver=new ChromeDriver();

If you use ChromeDriver driver = new ChromeDriver(); the ChromeDriver instance ...READ MORE

answered Oct 23, 2020 in Selenium by Karan
• 19,610 points
6,479 views
0 votes
2 answers

Getting Error in System.setProperty of ChromeDriver

System.setProperty("webdriver.chrome.driver", ...READ MORE

answered Jan 8, 2019 in Selenium by anonymous
9,273 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,998 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,724 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,830 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,647 views
0 votes
1 answer

i am not able to perform this method in selenium driver.get("google")

Hi Sachin, are you getting any errors ...READ MORE

answered May 15, 2019 in Selenium by Abha
• 28,140 points
1,609 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP