【发布时间】:2017-07-02 22:58:21
【问题描述】:
我正在使用 maven 项目运行 selenium 测试,但是当我运行测试文件时,我收到错误:无法连接到二进制 FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox. exe)在端口7055上。它打开FF的空白页然后测试结果抛出错误:
无法连接到端口 7055 上的二进制 FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe);进程输出如下: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 未发现更改 1487083932618 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi 注册清单 1487083932620 addons.xpi调试从 C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi 加载引导范围 1487083932629 addons.xpi 调试调用引导在 aushelper@mozilla.org 版本 1.0 上启动方法 1487083932631 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi 注册清单 1487083932633 addons.xpi DEBUG 从加载引导范围C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi 1487083932638 addons.xpi DEBUG 在 e10srollout@mozilla.org 版本 1.7 上调用引导方法启动 1487083932639 addons.xpi DEBUG 为 C 注册清单: \Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi 1487083932650 addons.xpi DEBUG 从 C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket 加载引导范围。 com.xpi 1487083932657 addons.xpi DEBUG 在 firefox@getpocket.com 版本 1.0.5 上调用引导方法启动 1487083932669 addons.xpi-utils DEBUG 开始异步加载 XPI 数据库 C:\Users\EGLDT1~1\AppData\Local\Temp\匿名5933286477074635697webdriver-profile\extensions.json 148708 3932671 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi 注册清单 1487083932673 addons.xpi DEBUG 从 C:\Program Files (x86)\Mozilla 加载引导范围Firefox\browser\features\webcompat@mozilla.org.xpi 1487083932678 addons.xpi DEBUG 在 webcompat@mozilla.org 版本 1.0 上调用引导方法启动 1487083932681 addons.manager DEBUG 为 XPIProvider 注册关闭阻止程序 1487083932681 addons.manager DEBUG 提供程序完成启动:XPIProvider 1487083932681 addons.manager DEBUG开始提供商:为LightweightThemeManager 1487083932682 addons.manager DEBUG提供成品启动LightweightThemeManager 1487083932681 addons.manager DEBUG注册关机阻滞剂:LightweightThemeManager 1487083932683 addons.manager DEBUG开始提供商:GMPProvider 1487083932701 addons.manager DEBUG注册关机阻滞剂GMPProvider 1487083932701插件.manager DEBUG Provider 完成启动:GMPProv ider 1487083932701 addons.manager DEBUG 启动提供程序:PluginProvider 1487083932702 addons.manager DEBUG 为 PluginProvider 注册关闭阻止程序 1487083932702 addons.manager DEBUG 提供程序已完成启动:PluginProvider 1487083932703 addons.manager DEBUG 完成启动顺序 14870839 0 MS 1487083933230 addons.xpi-utils DEBUG 已完成 XPI 数据库的异步读取,解析... 1487083933236 addons.xpi-utils DEBUG 成功读取 XPI 数据库 1487083933253 addons.manager DEBUG 启动提供程序:1487083933253 addons.manager DEBUG 注册93 关闭325 for3 .manager DEBUG Provider 完成启动:*** Blocklist::_loadBlocklistFromFile:blocklist 已禁用 1487083933441 addons.manager DEBUG 启动提供程序:PreviousExperimentProvider 1487083933442 addons.manager DEBUG 为 PreviousExperimentProvider 注册关闭阻止程序 1487083933442 addons.manager DEBUG Provider 完成启动p:PreviousExperimentProvider 构建信息:版本:'2.45.0',修订:'5017cb8e7ca8e37638dc3091b2440b90a1d8686f',时间:'2015-02-27 09:10:26' 系统信息:主机:'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.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 未发现更改 1487083932618 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi 注册清单 1487083932620 addons.xpi DEBUG 从 C:\Program Files (x86)\Mozilla Firefox\browser\features\aushelper@mozilla.org.xpi 加载引导范围 1487083932629 addons.xpi DEBUG 在 aushelper@mozilla.org 1.0 版上调用引导方法启动 1487083932631 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi 注册清单 1487083932633 addons.xpi DEBUG 从 C:\Program Files (x86)\Mozilla Firefox\browser\features\e10srollout@mozilla.org.xpi 加载引导范围 1487083932638 addons.xpi DEBUG 在 e10srollout@mozilla.org 版本 1.7 上调用引导方法启动 1487083932639 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi 注册清单 1487083932650 addons.xpi DEBUG 从 C:\Program Files (x86)\Mozilla Firefox\browser\features\firefox@getpocket.com.xpi 加载引导范围 1487083932657 addons.xpi DEBUG 在 firefox@getpocket.com 版本 1.0.5 上调用引导方法启动 1487083932669 addons.xpi-utils DEBUG 开始异步加载 XPI 数据库 C:\Users\EGLDT1~1\AppData\Local\Temp\anonymous5933286477074635697webdriver-profile\extensions.json 1487083932671 addons.xpi DEBUG 为 C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi 注册清单 1487083932673 addons.xpi DEBUG 从 C:\Program Files (x86)\Mozilla Firefox\browser\features\webcompat@mozilla.org.xpi 加载引导范围 1487083932678 addons.xpi DEBUG 在 webcompat@mozilla.org 1.0 版上调用引导方法启动 1487083932681 addons.manager DEBUG 为 XPIProvider 注册关闭阻止程序 1487083932681 addons.manager DEBUG Provider完成启动:XPIProvider 1487083932681 addons.manager DEBUG 起始提供者:LightweightThemeManager 1487083932681 addons.manager DEBUG 为 LightweightThemeManager 注册关闭阻止程序 1487083932682 addons.manager DEBUG Provider完成启动:LightweightThemeManager 1487083932683 addons.manager DEBUG 起始提供者:GMPProvider 1487083932701 addons.manager DEBUG 为 GMPProvider 注册关闭阻止程序 1487083932701 addons.manager DEBUG Provider完成启动:GMPProvider 1487083932701 addons.manager DEBUG 起始提供者:PluginProvider 1487083932702 addons.manager DEBUG 为 PluginProvider 注册关闭阻止程序 1487083932702 addons.manager DEBUG Provider启动完成:PluginProvider 1487083932703 addons.manager DEBUG 完成启动序列 1487083933230 addons.xpi-utils DEBUG 异步 JSON 文件读取耗时 0 MS 1487083933230 addons.xpi-utils DEBUG 已完成 XPI 数据库的异步读取,正在解析... 1487083933236 addons.xpi-utils DEBUG 成功读取XPI数据库 1487083933253 addons.manager DEBUG 启动提供程序: 1487083933253 addons.manager DEBUG 注册关闭阻止程序 1487083933253 addons.manager DEBUG Provider 完成启动: *** Blocklist::_loadBlocklistFromFile:阻止列表被禁用 1487083933441 addons.manager DEBUG 起始提供者:PreviousExperimentProvider 1487083933442 addons.manager DEBUG 为 PreviousExperimentProvider 注册关闭阻止程序 1487083933442 addons.manager DEBUG Provider 完成启动:PreviousExperimentProvider 构建信息:版本:'2.45.0',修订:'5017cb8e7ca8e37638dc3091b2440b90a1d8686f',时间:'2015-02-27 09:10:26' 系统信息:主机:'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.version:FirefoxDriver 在 org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:130) 在 org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:114) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:191) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:186) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:182) 在 ConsultaLogAuth.setUp(ConsultaLogAuth.java:26) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:606) 在 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 在 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 在 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 在 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 在 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 在 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 在 org.junit.runners.ParentRunner.run(ParentRunner.java:363) 在 org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) 在 org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) 在 org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:606) 在 org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) 在 org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) 在 org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) 在 org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) 在 org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68) 原因:org.openqa.selenium.firefox.NotConnectedException:45000 毫秒后无法连接到端口 7055 上的主机 127.0.0.1。火狐控制台输出: 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)。
【问题讨论】:
标签: maven selenium selenium-webdriver netbeans automated-tests