0

I'm using Windows but I don't have access to install Eclipse IDE or others so the only way is to run selenium through command prompt, I know there are similar question like this or this or this but that not solved my problem. And here are my script

mySelenium.java

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

public class mySelenium {

  public static void main(String[] args) {

    WebDriver driver = new ChromeDriver();

    // Open Google
    driver.get("https://www.example.com");

    // Close browser
    driver.quit();
  }
}

when I run following in CMD

java -classpath "selenium-server-standalone-3.141.59.jar" mySelenium.java
java -classpath "selenium-server-standalone-3.141.59.jar" mySelenium

I get error

Error: Could not find or load main class mySelenium.java

I don't understand why it cannot found the main because in my script here is main, so what the command that I need to run it correctly?

2 Answers 2

1
java -classpath "selenium-server-standalone-3.141.59.jar" mySelenium.java
java -classpath "selenium-server-standalone-3.141.59.jar" mySelenium

It should be:

**javac** -classpath "selenium-server-standalone-3.141.59.jar" mySelenium.java
java -classpath "selenium-server-standalone-3.141.59.jar" mySelenium

You wrote java instead of javac.

Sign up to request clarification or add additional context in comments.

Comments

0

You have to add current directory to your classpath.

java -classpath "selenium-server-standalone-3.141.59.jar;." mySelenium

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.