0

I have downloaded chromedriver.exe and eclipse, I have added through add external jars but while executing it gives me error

Error: Could not find or load main class demochrome.DemoChrome

package demochrome;


public class DemoChrome {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
        System.out.println("Welcome to chrome");

    }

}
EstevaoLuis
  • 2,422
  • 7
  • 33
  • 40

2 Answers2

1

I recommend page factory pattern, working example:

public class NewTest {
String baseUrl = "http://google.com"; 
String driverPath= "C:\\chromedriver.exe";

WebDriver driver;

@BeforeTest
public void beforeTest() {
    System.setProperty("webdriver.chrome.driver", driverPath);
    driver  = new ChromeDriver();

}

and in @Test

driver.get(baseUrl);

Maybe you changed class name in code (in project there's another name) and you have improper slash in "E://chromedriver.exe"

mtmx
  • 827
  • 1
  • 10
  • 31
0

E://chromedriver.exe is not a valid path. try E:/chromedriver.exe or E:\\chromedriver.exe

Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143