无法使用selenium webdriver在Jenkins中打开firefox浏览器

时间:2017-05-23 12:56:12

标签: java selenium firefox jenkins

我正在使用 Selenium版本3.4.0 geckodriver版本0.16.1 。我的firfox版本 52.0.1

我已经通过命令行 java -jar jenkins.war 启动了Jenkins服务器 Jenkins服务器工作正常。但是当我尝试执行Jenkins参数化作业(maven测试)时,firefox会打开片刻并立即关闭。

这是我的跟踪日志:

Running TestSuite
Before Test::com.sample.jenkins_demo.LoginTest
1495542214304   geckodriver INFO    Listening on 127.0.0.1:20563
1495542215003   mozprofile::profile INFO    Using profile path C:\Users\X--TM\AppData\Local\Temp\rust_mozprofile.Ec9pWyDHao34
1495542215020   geckodriver::marionette INFO    Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1495542215057   geckodriver::marionette INFO    Connecting to Marionette on localhost:60423
1495542216346   Marionette  INFO    Listening on port 60423
1495542216787   Marionette  WARN    TLS certificate errors will be ignored for this session
May 23, 2017 5:53:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.InvalidArgumentException: Missing 'type' parameter
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'X-TM', ip: '192.168.139.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\X--TM\AppData\Local\Temp\rust_mozprofile.Ec9pWyDHao34, rotatable=false, timeouts={implicit=0.0, page load=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=52.0.1, platformVersion=10.0, moz:processID=10620.0, browserName=firefox, javascriptEnabled=true, platformName=windows_nt}]
Session ID: ec7c23fa-a0b3-4f54-b017-bd192830db16
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:868)
    at com.sample.jenkins_demo.Base.setUp(Base.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:517)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)
    at org.testng.TestRunner.beforeRun(TestRunner.java:645)
    at org.testng.TestRunner.run(TestRunner.java:613)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1199)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1124)
    at org.testng.TestNG.run(TestNG.java:1032)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:295)
    at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:90)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Before Method::com.sample.jenkins_demo.LoginTest

如果我使用Chrome浏览器,它在Jenkins中工作正常。

注意:同样的测试在firefox和chrome浏览器上都在本地执行。

我的firefox配置:

   public static WebDriver driver = null;
   DesiredCapabilities capabilities = DesiredCapabilities.firefox();
   capabilities.setCapability("marionette", true);
   driver = new FirefoxDriver(capabilities);

   driver.manage().window().maximize();
   driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
   driver.get("https://www.google.co.in");

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

以下是您的问题的答案:

错误说明了Missing 'type' parameter

这是使用Mozilla Firefox在Selenium上的Missing 'type' parameter Build info: version: '3.4.0'上的一个已知问题。您可以找到讨论here

升级到Mozilla Firefox 53.x将解决您的问题。

如果这回答你的问题,请告诉我。