VVB
VVB

Reputation: 7641

import cannot be resolved for selenium drivers

I am trying to import WebDriver & ChromeDriver, tried all libraires but no luck

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

public class TestChrome {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver", "/home/vikas/Downloads/chromedriver.exe");

        // Initialize browser
        WebDriver driver=new ChromeDriver();


        // Open Google
        driver.get("http://www.google.com");

        // Maximize browser

        driver.manage().window().maximize();
    }

}

Getting below errors

The import org.openqa.selenium.WebDriver cannot be resolved
The import org.openqa.selenium.chrome.ChromeDriver cannot be resolved

Upvotes: 1

Views: 27932

Answers (8)

Victor Adesanya
Victor Adesanya

Reputation: 1

When adding external jars, make sure you add the jars in the lib folder first before adding the ones in the main selenium-java folder. This made the difference for me.

Upvotes: 0

Ranjit
Ranjit

Reputation: 11

Remove the selenium java jar files from Modulepath and add to Classpath

Upvotes: 1

Bhargavi Kommineni
Bhargavi Kommineni

Reputation: 1

If it is in mac, there should be problem in setProperty path. Instead of mentioning chromedriver.exe, you should give just chromedriver(as you should be seeing just chromedriver under Downloads).

Be sure to set JAVA_HOME path in bash profile.

Upvotes: 0

Shubham Jain
Shubham Jain

Reputation: 17553

You are working on Linux/Mac, as you have a path like /home/vikas/, but you are using chromedriver.exe.

You can't use exe binary on Linux platform. It is specifically designed for Windows only, .exe is only for Windows.

You need to download Linux/Mac chrome binary from below URL:

https://chromedriver.storage.googleapis.com/index.html?path=2.33/

Upvotes: 0

Davide Patti
Davide Patti

Reputation: 3471

The recommended Selenium (and chromedriver) that you must to use depends on your Chrome Browser version.

If you are using the latest version of the Chrome Browser, you have to use the latest chromedriver and (is recommended to) import the Selenium 3.5 (or greater).

So, from selenium download, download your interested version and import the jar in your project.

If is a maven project, you can simple add this dependency on your pom:

       <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.6.0</version>
       </dependency>

Else download the .jar and import manually (find how to import a jar using your IDE).

Upvotes: 0

iamsankalp89
iamsankalp89

Reputation: 4739

This is the issue unresolved dependency. I think you should to used selenium 3.4 with chromedriver 2.32 and chrome 60 browser

Also i guess uu are importing all the jar files

Upvotes: 0

Rathan Naik
Rathan Naik

Reputation: 1015

selenium jar has to be added to the project to identify the interface org.openqa.selenium.WebDriver and class org.openqa.selenium.chrome.ChromeDriver

selenium download link: http://www.seleniumhq.org/download/

Upvotes: 3

Ankur Vashisht
Ankur Vashisht

Reputation: 66

This error occurs due to unresolved dependency. can you confirm if all your jar dependencies are resolved

Upvotes: 0

Related Questions