1

I am getting the next error with this code:

package main;

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

public class main {

    public static void main(String[] args) {

        // TODO Auto-generated method stub
        WebDriver driver = new ChromeDriver("https://www.google.co.il/");
    

    }
}

Error: Exception in thread "main" java.lang.Error: Unresolved compilation problems: WebDriver cannot be resolved to a type ChromeDriver cannot be resolved to a type

at class6_v2/main.main.main(main.java:11)

i have added the Jars of selenium to the build path: enter image description here and checked that the web driver is the right version of chrome and in the class files what am i doing wrong?

ou_ryperd
  • 2,037
  • 2
  • 18
  • 23
Mishel Rossin
  • 51
  • 1
  • 3
  • Might want to follow a tutorial since you still need a chromedriver.exe and driver.get("yoururl") – Arundeep Chohan Dec 12 '20 at 09:23
  • Yes i can see that i miss that line, but even after that i have added it im getting the same error:WebDriver driver = new ChromeDriver(); driver.get("https://www.google.co.il/"); – Mishel Rossin Dec 12 '20 at 09:32

1 Answers1

0

You need to set up System Property first or set up your chromedriver.exe in to the environment path.

System.setProperty("webdriver.chrome.driver", path to your chromedriver.exe)

then you declare chrome driver and go to url

WebDriver driver = new ChromeDriver();
driver.get(your url);

Reference

https://www.guru99.com/selenium-tutorial.html

Trinh Phat
  • 524
  • 3
  • 6
  • Did as you instrcuted but it gives out the samer error :package main; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class main { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C://Users//mishe//eclipse-workspace//Class6_v2"); WebDriver driver = new ChromeDriver(); driver.get("http://www.google.com/"); } } – Mishel Rossin Dec 12 '20 at 09:45
  • You need to include the filename: C://Users//mishe//eclipse-workspace//Class6_v2//chromedriver.exe – Trinh Phat Dec 12 '20 at 09:47
  • Still same error : – Mishel Rossin Dec 12 '20 at 09:52
  • I Have found the issue, i have added the external JARS in the moudle path insted of the class path,thank you. – Mishel Rossin Dec 12 '20 at 10:09