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,180
  • 7
  • 32
  • 38

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
  • 769
  • 7
  • 24
0

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

Corey Goldberg
  • 56,214
  • 26
  • 121
  • 139