无法使用Selenium 3正确运行firefox

时间:2016-11-12 16:23:50

标签: java selenium-firefoxdriver selenium3

我在JUnit中编写了一个测试,用Selenium 3.0.1启动Firefox。 但我的Firefox便携版有问题。在我的机器上安装了Firefox,我没有这个问题。

我的测试非常简单:

public class SeleniumTest extends FluentTest {
  WebDriver webDriver = new FirefoxDriver();
  static {
    // 1) Work with native Firefox
    System.setProperty("webdriver.gecko.driver", ClassLoader.getSystemResource("webdriver/geckodriver_0.11.1.exe").getFile());

    // 2) Don't work when I add these 2 properties
    //        System.setProperty("webdriver.firefox.marionette", "true");
    //        System.setProperty("webdriver.firefox.bin", "D:\\firefox-portable\\FirefoxPortablex64-48.0.2\\FirefoxPortable.exe");
  }

  @Test
  public void test() {
    System.out.println("test is executed");
  }
}

在n°2的情况下,我添加了运行Firefox便携版本所需的属性,但测试保持锁定在“在本地主机上连接到Marionette:52702”的步骤。什么都发生了。

1478965841203   geckodriver INFO    Listening on 127.0.0.1:45941
nov. 12, 2016 4:50:41 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFOS: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1478965841598   mozprofile::profile INFO    Using profile path d:\Profiles\<username>\AppData\Local\Temp\rust_mozprofile.TisH4gXwlj3K
1478967041359   geckodriver::marionette INFO    Starting browser D:\firefox-portable\FirefoxPortablex64-48.0.2\FirefoxPortable.exe
1478967041388   geckodriver::marionette INFO    Connecting to Marionette on localhost:52702

但是使用原生Firefox,我可以看到接下来的步骤并执行测试。

1478967281791   Marionette  INFO    Listening on port 53224
1478967283064   Marionette  INFO    startBrowser d3c2b382-5643-4149-9168-57fd36a43678
nov. 12, 2016 5:14:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFOS: Detected dialect: W3C
test is executed

最后,我确切地说,我希望使用Firefox便携版本更加灵活和独立。

我的环境: Jdk 8 / Selenium 3.0.1 / FluentLenium 3.0.2 / GeckoDriver 0.11.1 / Native Firefox:49.0.2 / Firefox便携版:48.0.2和49.0

任何帮助都将受到赞赏。

0 个答案:

没有答案
相关问题