如何使用其他浏览器运行selenium?

时间:2014-02-22 13:37:10

标签: java selenium selenium-webdriver

我在Firefox中配置了Selenium 2.0 IDE,并使用此IDE执行我的项目。

  1. 使用IDE执行项目。
  2. 然后播放已执行的屏幕。
  3. 以HTML和Java格式保存这些测试用例。 (对于Java:我使用了Jnit / Webdriver)
  4. 然后我使用eclipse打开java文件以更改Chrome驱动程序
  5. 之后我将此代码附加到System.setProperty();
  6. 然后我使用命令提示符执行Chromewebdriver java -Dwebdriver.chrome.driver = / path / to / chromedriver -jar selenium-server-standalone-2.7.0.jar
  7. 然后我收到错误
  8. C:\Program Files\Java\jdk1.6.0\bin>java -Dwebdriver.chrome.driver=c:/Users/FSP/D
    ownloads/chromedriver.exe -jar selenium-server-standalone-2.39.0.jar
    Unable to access jarfile selenium-server-standalone-2.39.0.jar
    
    C:\Program Files\Java\jdk1.6.0\bin>java -Dwebdriver.chrome.driver=c:/Users/FSP/D
    ownloads/chromedriver.exe -jar c:/Users/FSP/Downloads/selenium-server-standalone
    -2.39.0.jar
    Feb 22, 2014 6:48:37 PM org.openqa.grid.selenium.GridLauncher main
    INFO: Launching a standalone server
    18:48:39.395 INFO - Java: Sun Microsystems Inc. 1.6.0-b105
    18:48:39.405 INFO - OS: Windows Vista 6.1 x86
    18:48:39.618 INFO - v2.39.0, with Core v2.39.0. Built from revision ff23eac
    18:48:40.440 INFO - Default driver org.openqa.selenium.iphone.IPhoneDriver regis
    tration is skipped: registration capabilities Capabilities [{platform=MAC, brows
    erName=iPhone, version=}] does not match with current platform: VISTA
    18:48:40.500 INFO - Default driver org.openqa.selenium.iphone.IPhoneDriver regis
    tration is skipped: registration capabilities Capabilities [{platform=MAC, brows
    erName=iPad, version=}] does not match with current platform: VISTA
    18:48:41.089 INFO - RemoteWebDriver instances should connect to: 
    18:48:41.091 INFO - Version Jetty/5.1.x
    18:48:41.122 INFO - Started HttpContext[/selenium-server/driver,/selenium-server
    /driver]
    18:48:41.124 INFO - Started HttpContext[/selenium-server,/selenium-server]
    18:48:41.125 INFO - Started HttpContext[/,/]
    18:48:41.772 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1db4f6
    f
    18:48:41.772 INFO - Started HttpContext[/wd,/wd]
    18:48:41.799 WARN - Failed to start: SocketListener0@0.0.0.0:4444
    Exception in thread "main" org.openqa.jetty.util.MultiException[java.net.SocketE
    xception: Unrecognized Windows Sockets error: 0: JVM_Bind]
            at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:696)
            at org.openqa.jetty.util.Container.start(Container.java:72)
            at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:4
    88)
            at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:30
    0)
    at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:24
    5)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:96)
    java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
    at java.net.ServerSocket.bind(ServerSocket.java:319)
    at java.net.ServerSocket.<init>(ServerSocket.java:185)
    at org.openqa.jetty.util.ThreadedServe`enter code here`r.newServerSocket(ThreadedServer.j
    ava:392)
    at org.openqa.jetty.util.ThreadedServer.open(ThreadedServer.java:478)
    at org.openqa.jetty.util.ThreadedServer.start(ThreadedServer.java:504)
    at org.openqa.jetty.http.SocketListener.start(SocketListener.java:202)
    at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:726)
    at org.openqa.jetty.util.Container.start(Container.java:72)
    at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:4
    88)
    at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:30
    0)
    at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:24
    5)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:96)
    C:\Program Files\Java\jdk1.6.0\bin>
    

    如何解决这个问题?因此,请尝试使用webdriver概念通过其他浏览器配置和运行脚本。

1 个答案:

答案 0 :(得分:0)

可能是类路径问题....

从seleniumHQ.org网站下载最新版本的selenium,例如2.39.0。

将其放在C:\驱动器中。转到环境变量并将 java -jar selenium-server-standalone-2.39.0.jar 添加到类路径