接收错误:无法在端口7055上连接到二进制FirefoxBinary

时间:2017-02-14 15:17:26

标签: maven selenium selenium-webdriver netbeans automated-tests

我正在使用maven项目运行selenium测试,但是当我运行测试文件时,我正在收到错误:无法连接到二进制FirefoxBinary(C:\ Program Files(x86)\ Mozilla Firefox \ firefox。在端口7055上打开一个空白页面,然后测试结果抛出错误:

Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows:  e":true,"v":"1.0.5","st":1484790105743},"webcompat@mozilla.org":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\features\\webcompat@mozilla.org.xpi","e":true,"v":"1.0","st":1484790105745}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","e":true,"v":"51.0","st":1484790105687}},"winreg-app-global":{"{D19CA586-DD6C-4a0a-96F8-14644F340D60}":{"d":"C:\\Program Files (x86)\\Common Files\\McAfee\\SystemCore","e":false,"v":"15.4.0","st":1484874384474,"mt":1481296942197}}} 1487083932603 addons.xpi DEBUG No changes found 1487083932618 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi 1487083932620 addons.xpi DEBUG Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi 1487083932629 addons.xpi DEBUG Calling bootstrap method startup on aushelper@mozilla.org version 1.0 1487083932631 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi 1487083932633 addons.xpi DEBUG Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi 1487083932638 addons.xpi DEBUG Calling bootstrap method startup on e10srollout@mozilla.org version 1.7 1487083932639 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi 1487083932650 addons.xpi DEBUG Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi 1487083932657 addons.xpi DEBUG Calling bootstrap method startup on firefox@getpocket.com version 1.0.5 1487083932669 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\EGLDT1~1\AppData\Local\Temp\anonymous5933286477074635697webdriver-profile\extensions.json 1487083932671 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi 1487083932673 addons.xpi DEBUG Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi 1487083932678 addons.xpi DEBUG Calling bootstrap method startup on webcompat@mozilla.org version 1.0 1487083932681 addons.manager DEBUG Registering shutdown blocker for XPIProvider 1487083932681 addons.manager DEBUG Provider finished startup: XPIProvider 1487083932681 addons.manager DEBUG Starting provider: LightweightThemeManager 1487083932681 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager 1487083932682 addons.manager DEBUG Provider finished startup: LightweightThemeManager 1487083932683 addons.manager DEBUG Starting provider: GMPProvider 1487083932701 addons.manager DEBUG Registering shutdown blocker for GMPProvider 1487083932701 addons.manager DEBUG Provider finished startup: GMPProvider 1487083932701 addons.manager DEBUG Starting provider: PluginProvider 1487083932702 addons.manager DEBUG Registering shutdown blocker for PluginProvider 1487083932702 addons.manager DEBUG Provider finished startup: PluginProvider 1487083932703 addons.manager DEBUG Completed startup sequence 1487083933230 addons.xpi-utils DEBUG Async JSON file read took 0 MS 1487083933230 addons.xpi-utils DEBUG Finished async read of XPI database, parsing... 1487083933236 addons.xpi-utils DEBUG Successfully read XPI database 1487083933253 addons.manager DEBUG Starting provider:  1487083933253 addons.manager DEBUG Registering shutdown blocker for  1487083933253 addons.manager DEBUG Provider finished startup:  *** Blocklist::_loadBlocklistFromFile: blocklist is disabled 1487083933441 addons.manager DEBUG Starting provider: PreviousExperimentProvider 1487083933442 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider 1487083933442 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider  Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26' System info: host: 'Moises_Zarate', ip: '172.29.6.108', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_60' Driver info: driver.version: FirefoxDriver
org.openqa.selenium.WebDriverException
e":true,"v":"1.0.5","st":1484790105743},"webcompat@mozilla.org":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\features\\webcompat@mozilla.org.xpi","e":true,"v":"1.0","st":1484790105745}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","e":true,"v":"51.0","st":1484790105687}},"winreg-app-global":{"{D19CA586-DD6C-4a0a-96F8-14644F340D60}":{"d":"C:\\Program Files (x86)\\Common Files\\McAfee\\SystemCore","e":false,"v":"15.4.0","st":1484874384474,"mt":1481296942197}}}
1487083932603   addons.xpi  DEBUG   No changes found
1487083932618   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi
1487083932620   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi
1487083932629   addons.xpi  DEBUG   Calling bootstrap method startup on aushelper@mozilla.org version 1.0
1487083932631   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi
1487083932633   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi
1487083932638   addons.xpi  DEBUG   Calling bootstrap method startup on e10srollout@mozilla.org version 1.7
1487083932639   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi
1487083932650   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi
1487083932657   addons.xpi  DEBUG   Calling bootstrap method startup on firefox@getpocket.com version 1.0.5
1487083932669   addons.xpi-utils    DEBUG   Starting async load of XPI database C:\Users\EGLDT1~1\AppData\Local\Temp\anonymous5933286477074635697webdriver-profile\extensions.json
1487083932671   addons.xpi  DEBUG   Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi
1487083932673   addons.xpi  DEBUG   Loading bootstrap scope from C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi
1487083932678   addons.xpi  DEBUG   Calling bootstrap method startup on webcompat@mozilla.org version 1.0
1487083932681   addons.manager  DEBUG   Registering shutdown blocker for XPIProvider
1487083932681   addons.manager  DEBUG   Provider finished startup: XPIProvider
1487083932681   addons.manager  DEBUG   Starting provider: LightweightThemeManager
1487083932681   addons.manager  DEBUG   Registering shutdown blocker for LightweightThemeManager
1487083932682   addons.manager  DEBUG   Provider finished startup: LightweightThemeManager
1487083932683   addons.manager  DEBUG   Starting provider: GMPProvider
1487083932701   addons.manager  DEBUG   Registering shutdown blocker for GMPProvider
1487083932701   addons.manager  DEBUG   Provider finished startup: GMPProvider
1487083932701   addons.manager  DEBUG   Starting provider: PluginProvider
1487083932702   addons.manager  DEBUG   Registering shutdown blocker for PluginProvider
1487083932702   addons.manager  DEBUG   Provider finished startup: PluginProvider
1487083932703   addons.manager  DEBUG   Completed startup sequence
1487083933230   addons.xpi-utils    DEBUG   Async JSON file read took 0 MS
1487083933230   addons.xpi-utils    DEBUG   Finished async read of XPI database, parsing...
1487083933236   addons.xpi-utils    DEBUG   Successfully read XPI database
1487083933253   addons.manager  DEBUG   Starting provider: 
1487083933253   addons.manager  DEBUG   Registering shutdown blocker for 
1487083933253   addons.manager  DEBUG   Provider finished startup: 
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1487083933441   addons.manager  DEBUG   Starting provider: PreviousExperimentProvider
1487083933442   addons.manager  DEBUG   Registering shutdown blocker for PreviousExperimentProvider
1487083933442   addons.manager  DEBUG   Provider finished startup: PreviousExperimentProvider
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'Moises_Zarate', ip: '172.29.6.108', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_60'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:130)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:114)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:191)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:182)
    at ConsultaLogAuth.setUp(ConsultaLogAuth.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
e":true,"v":"1.0.5","st":1484790105743},"webcompat@mozilla.org":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\features\\webcompat@mozilla.org.xpi","e":true,"v":"1.0","st":1484790105745}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","e":true,"v":"51.0","st":1484790105687}},"winreg-app-global":{"{D19CA586-DD6C-4a0a-96F8-14644F340D60}":{"d":"C:\\Program Files (x86)\\Common Files\\McAfee\\SystemCore","e":false,"v":"15.4.0","st":1484874384474,"mt":1481296942197}}}

这些是我的文件:

的pom.xml

<dependencies>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.45.0</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium.server</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.48.2</version>
        <scope>test</scope>
        <type>jar</type>
    </dependency>
</dependencies>

ConsultaLogAuth.java

import java.io.File;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.support.ui.Select;

public class ConsultaLogAuth {
  private WebDriver driver;
  private String baseUrl;
  private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

  @Before
  public void setUp() throws Exception {     

File pathToBinary = new File("C:\\Program Files (x86)\\Mozilla     Firefox\\firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();       
driver = new FirefoxDriver(ffBinary,firefoxProfile);      
//    driver = new FirefoxDriver();
    baseUrl = "http://172.29.6.228:8025/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

我有FireFox 51.0和selenium-java 2.45.0(jar)。

1 个答案:

答案 0 :(得分:1)

您需要升级Selenium Server(例如升级到3.5.x),以便它可以支持您的新版Firefox。

pom.xml文件中的配置示例:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>3.5.2</version>
  <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium.server</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.5.2</version>
    <scope>test</scope>
    <type>jar</type>
</dependency>

请参阅: