0

I was writing a java program for selenium when tried to import "org.openqa.selenium.chrome.ChromeDriver" but it gives an error. "The import org.openqa cannot be resolved" on my MacBook.

import org.openqa.selenium.chrome.ChromeDriver;

public class Login {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "/Users/shilpa/Documents/Selenium/Selenium Softwares/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
    }
frianH
  • 7,295
  • 6
  • 20
  • 45

1 Answers1

0

This error message...

The import org.openqa cannot be resolved

...implies that ChromeDriver wasn't resolved at compiletime.

There can be a lot many resons behind this error. A bit more about your Test Environment e.g. JAR files, Maven or Gradle and the binary versions would have helped us to debug the issue in a better way. You can find a couple of relevant discussions in ChromeDriver and WebDriver for Selenium through TestNG results in 4 errors and java.lang.Error: Unresolved compilation problems : WebDriver/ChromeDriver cannot be resolved to a type error while executing selenium tests


Morepver, as you are using MacOS you instead of using the chromedriver.exe from chromedriver_win32.zip you need to download, extract and use the chromedriver binary from chromedriver_mac64 and change the System.setProperty() line as follows:

//without the extension (.exe)
System.setProperty("webdriver.chrome.driver", "/Users/shilpa/Documents/Selenium/Selenium Softwares/chromedriver");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352