1

I am getting the following Exception:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:     
Type mismatch: cannot convert from ChromeDriver to WebDriver    
The method get(String) is undefined for the type WebDriver at selOne.New.main(New.java:15)

Code:

package selOne;

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

public class New {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver", "C:/Users/name/Downloads/selenium-java-3.141.59/chromedriver.exe");
        WebDriver driver=new ChromeDriver();
        String baseurl = "http://www.google.com/";
        driver.get(baseurl);
    }
}
1
  • problem not solved please provide another solution Sep 3, 2019 at 5:57

3 Answers 3

1

Try declaring the webdriver outside the main class.

package selOne;

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

public class New {

    public static WebDriver driver;
    public static String baseurl;

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "C:/Users/name/Downloads/selenium-java-3.141.59/chromedriver.exe");
        driver=new ChromeDriver();
        baseurl = "http://www.google.com/";
        driver.get(baseurl);

    }
}

Let me know if this solved the problem.

0

This happens when you have added the external jars in the ModulePath.

Solution:

Remove the external jars from the node "Modulepath". Select the node "Classpath" then add the external jars. Check selenium jar is imported.

1
  • i added in classpath only. Pleasefind screenshot
    – Sarayu
    Feb 1, 2019 at 11:44
0

The solution of adding the selenium jars in "classpath" and not in "Modulepath" in project build helps in overcoming the error message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.