Selenium打开空白的火狐

时间:2017-08-17 13:59:03

标签: java selenium firefox geckodriver

我正在使用:

  • Selenium 3.5.0
  • Selenium Standalone Server 3.5.0
  • Firefox 55 64bit
  • geckodriver 18(同样用16测试)
  • Java 8

它适用于Chrome,但是当我尝试使用Firefox运行时,它只打开空白浏览器,driver.get(url);无效。

运行Firefox的代码:

public static WebDriver ff() {
    File firefoxfile = new File(PropertyReader.getProperty("firefox"));
    System.setProperty("webdriver.gecko.driver", firefoxfile.getPath());

    WebDriver wd = null;

    try {
        URL url = new URL("http://" + TestRunner.SELENIUM_HUB + ":4444/wd/hub");
        FirefoxProfile fp = new FirefoxProfile();
        // set something on the profile...
        DesiredCapabilities dc = DesiredCapabilities.firefox();
        dc.setCapability(FirefoxDriver.PROFILE, fp);

        wd = new RemoteWebDriver(url, dc);
    } catch (MalformedURLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    return wd;
}

测试输出错误:

    org.openqa.selenium.WebDriverException: connection refused
    Command duration or timeout: 1291.92 seconds
    Build info: version: '3.5.0', revision: '8def36e068', time: '2017-08-10T23:00:22.093Z'
    System info: host: 'WIN-D855CG0E8N8', ip: '9.167.43.47', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0'
    Driver info: driver.version: FirefoxDriver
    Command duration or timeout: 1292.62 seconds
        at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:360)
        at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)

org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:363)             在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)             在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:137)             在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:174)             在Utils.BrowserDriver.ff(BrowserDriver.java:65)             在TestCases.LogInLogOut.logIn(LogInLogOut.java:28)             在TestCases.TestRunner.main(TestRunner.java:82)         引起:org.openqa.selenium.WebDriverException:连接被拒绝         命令持续时间或超时:1291.92秒         构建信息:版本:' 3.5.0',版本:' 8def36e068',时间:' 2017-08-10T23:00:22.093Z'         系统信息:主机:' WIN-D855CG0E8N8',ip:' 9.167.43.47',os.name:' Windows Server 2008 R2',os.arch: ' amd64',os.version:' 6.1',java.version:' 1.8.0'         驱动程序信息:driver.version:FirefoxDriver         构建信息:版本:'未知',修订版:'未知',时间:'未知'         系统信息:主持人:' LAPTOP-M8P6EPPV',ip:' 9.158.134.242',os.name:' Windows 10',os.arch:&# 39; amd64',os.version:' 10.0',java.version:' 1.8.0_141'         驱动程序信息:driver.version:FirefoxDriver             在org.openqa.selenium.remote.Gecko013ProtocolResponse.lambda $ getResponseFunction $ 2(Gecko013ProtocolResponse.java:90)

编辑,添加java -jar selenium-server-standalone-3.5.0.jar -enablePassThrough false

的控制台日志
    C:\Users\db2admin\Downloads>java -jar selenium-server-standalone-3.5.0.jar -enab
    lePassThrough false
    00:26:16.883 INFO - Selenium build info: version: '3.5.0', revision: '8def36e068
    '
    00:26:16.883 INFO - Launching a standalone Selenium Server
    2017-08-21 00:26:16.930:INFO::main: Logging initialized @484ms to org.seleniumhq
    .jetty9.util.log.StdErrLog
    00:26:17.039 INFO - Driver class not found: com.opera.core.systems.OperaDriver
    00:26:17.086 INFO - Driver provider class org.openqa.selenium.safari.SafariDrive
    r registration is skipped:
     registration capabilities Capabilities [{browserName=safari, version=, platform
    =MAC}] does not match the current platform VISTA
    2017-08-21 00:26:17.211:INFO:osjs.Server:main: jetty-9.4.5.v20170502
    2017-08-21 00:26:17.242:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.S
    ervletContextHandler@61a4f141{/,null,STARTING} has uncovered http methods for pa
    th: /
    2017-08-21 00:26:17.257:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletC
    ontextHandler@61a4f141{/,null,AVAILABLE}
    2017-08-21 00:26:17.850:INFO:osjs.AbstractConnector:main: Started ServerConnecto
    r@7fb23f39{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
    2017-08-21 00:26:17.850:INFO:osjs.Server:main: Started @1404ms
    00:26:17.850 INFO - Selenium Server is up and running
    00:26:27.257 INFO - Executing: [new session: Capabilities [{marionette=true, acc
    eptInsecureCerts=true, browserName=firefox, version=, platform=ANY}]])
    00:26:27.288 INFO - Creating a new session for Capabilities [{marionette=true, a
    cceptInsecureCerts=true, browserName=firefox, version=, platform=ANY}]
    1503300387959   geckodriver     INFO    Listening on 127.0.0.1:46666
    1503300388630   mozprofile::profile     INFO    Using profile path C:\Users\db2a
    dmin\AppData\Local\Temp\3\rust_mozprofile.bxC3mzvoGagd
    1503300388630   geckodriver::marionette INFO    Starting browser C:\Program File
    s\Mozilla Firefox\firefox.exe
    1503300388630   geckodriver::marionette INFO    Connecting to Marionette on loca
    lhost:55034
    Unable to read VR Path Registry from C:\Users\db2admin\AppData\Local\openvr\open
    vrpaths.vrpath
    [Parent 5848] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-rel-w64-0000
    0000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, li
    ne 346
    Unable to read VR Path Registry from C:\Users\db2admin\AppData\Local\openvr\open
    vrpaths.vrpath
    [Child 12456] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-rel-w64-0000
    0000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, li
    ne 346
    [Child 12456] WARNING: pipe error: 109: file c:/builds/moz2_slave/m-rel-w64-0000
    0000000000000000/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, li
    ne 346

0 个答案:

没有答案