0

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);
    }
}
  • problem not solved please provide another solution – Pawan Pothala Sep 3 at 5:57
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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