Having a problem getting going with Selenium on Java. I\'m trying to follow the example on this page: http://code.google.com/p/selenium/wiki/GettingStarted
I\'m ty
Compile like so:
javac -classpath selenium-server-standalone-2.20.0.jar Example.java
Unless you put the Java file in the org.openqa.selenium.example
, you will have to remove the package specifier. Run the compiled file like so:
java -cp .:selenium-server-standalone-2.20.0.jar Example
This chains the current directory to the classpath.
For those doing a java dynamic web project in eclipse, and receiving the error above, the following link might help:
http://me-ol-blog.blogspot.co.il/2013/07/using-selenium-in-java-dynamic-web.html
Basically, it mentions that the standalone jar is not "standalone" when using dynamic web projects and that a different jar should be used along with its dependent jars.
Add html unit driver dependency in your pom file.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.21</version>
</dependency>
It is working fine for me.