Can't run Java example for Selenium / WebDriver

前端 未结 3 1282
醉话见心
醉话见心 2020-12-31 13:54

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

相关标签:
3条回答
  • 2020-12-31 14:42

    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.

    0 讨论(0)
  • 2020-12-31 14:45

    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.

    0 讨论(0)
  • 2020-12-31 14:55

    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.

    0 讨论(0)
提交回复
热议问题