如何运行多个firefox webdriver测试

时间:2014-05-21 15:24:42

标签: firefox selenium selenium-webdriver webdriver

当我尝试运行多个尝试使用firefox的webdriver测试时,我遇到了问题。

以下是我得到的错误

Exception in thread "main" org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'ip-172-31-23-96.us-west-2.compute.internal', ip: '172.31.23.96', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.7.0_55'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:98)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:84)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
    at feedbackWorksproperly.main(feedbackWorksproperly.java:23)


sudo javac -cp ".:/includes/selenium-2.41.0/selenium-java-2.41.0-srcs.jar:/includes/selenium-2.41.0/selenium-java-2.41.0.jar:/includes/selenium-2.41.0/libs/*" feedbackWorksproperly.java

sudo java -cp ".:/includes/selenium-2.41.0/selenium-java-2.41.0-srcs.jar:/includes/selenium-2.41.0/selenium-java-2.41.0.jar:/includes/selenium-2.41.0/libs/*" feedbackWorksproperly    

以下是我初始化webdriver的方式

    String Xport = System.getProperty("lmportal.xvfb.id", ":1");
    final File firefoxPath = new File(System.getProperty("lmportal.deploy.firefox.path",
        "/usr/bin/firefox"));
    FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath);
    firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
    FirefoxDriver wd;
    wd = new FirefoxDriver(firefoxBinary, null);

注意我有一个休息服务器,根据请求运行测试。每当它获得一个包含java代码的请求时,它将继续运行测试,独立于当前在服务器上运行的其他测试。

1 个答案:

答案 0 :(得分:1)

我猜你是在同时运行两个驱动程序? 如果是这种情况,

Unable to bind to locking port 7054

看起来另一个正在同一个端口上运行。使用不同的端口可能有效。

但是我建议使用Selenium Grid在不同的浏览器/并行上运行测试 见http://code.google.com/p/selenium/wiki/Grid2