0

I am trying to learn automation with Selenium but I got stuck with WebDriver... I followed all the steps. Installed the following, configured PATH:

Chromedriver version : ChromeDriver 93.0.4577.63 Selenium WebDriver version: 4.10.0

Eclipse IDE version: Eclipse IDE for Java Developers (includes Incubating components)

Version: 2023-06 (4.28.0) Build id: 20230608-1333

java 20.0.1 2023-04-18 Java(TM) SE Runtime Environment (build 20.0.1+9-29) Java HotSpot(TM) 64-Bit Server VM (build 20.0.1+9-29, mixed mode, sharing)


But when I try to do small project like invoking Chrome Browser... I am getting this error... WebDriver Can not be resolved to a type. ChromeDriver can not be resolved to a type;

I don't see the option to 'import ....'.

What am I doing wrong and how can I resolve the error.

Thank you.

Tried all the tips suggested from Youtube videos but no luck

3 Answers3

0

If you are using Selenium version 4.10.0, then you do not have to worry about the browser version or the chromedriver version. Selenium will internally download/manage the chromedriver based on the installed chrome browser on your system. Java code to launch a browser can be as simple as:

public static void main(String[] args)  {
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.get("https://www.google.com/");
    System.out.println(driver.getTitle());
    driver.close();
}

Imports required:

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

Reference: https://stackoverflow.com/a/76463081/7598774

Shawn
  • 4,064
  • 2
  • 11
  • 23
  • Thank you Shawn. But my problem is I don't see the import option ... gives error but no option to import... – Sama Reddy Aug 02 '23 at 02:13
0

Selenium version doesn't have any documented dependency on ChromeDriver version or version as such.

But matching the major version of ChromeDriver and version is mandatory.

However, ideally you should be using the latest version of all the binaries:

  • Selenium
  • ChromeDriver
  • Google Chrome

Using the latest Selenium v4.10.0 and Chrome v115.x Selenium Manager download the matching ChromeDriver as per the version of Google Chrome installed. Your minimal code will be:

ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(options);
driver.get("https://weather.com/");

References

You can find a couple of relevant detailed discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Try to download the latest version of selenium java 4.11.0--https://www.selenium.dev/downloads/ Its working for me.