我正在研究硒自动化。今天我更新了我的pom文件以获得最新的依赖项。
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.0-beta3</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.0.0-beta3</version>
</dependency>
在此之后,我的测试都没有在浏览器上运行。假设firefox在48版本上打开,但是webdriver没有与浏览器交互。我得到的错误日志是:
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary
(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows:
,"syncGUID":"Ei_LbuNEIU60","location":"app-global","version":"48.0.2","type":"theme","internalName":"classic/1.0",
"updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL ":null,"icons": {"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,
"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1475694945987,"updateDate":1475694945987,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"48.0.2","maxVersion":"48.0.2"}],"targetPlatforms":[],"seen":true}
这是我在今天早上将64位机器上的jre和jdk更改为32位后出现的新错误
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
,"syncGUID":"qLUZlH20Y8gq","location":"app-global","version":"48.0.2","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1475694945987,"updateDate":1475694945987,"applyBackgroundUpdates":1,"skinnable":true,"size":21905,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"48.0.2","maxVersion":"48.0.2"}],"targetPlatforms":[],"seen":true}
1475767803924 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
这是Selenium3
和Mozilla Firefox
版本之间的不兼容问题。
实际上Selenium3
支持可执行的geckodriver
,就像其他驱动程序一样启动Mozilla Firefox >= v47
。
To work around you need to download latest executable geckodriver and extract downloaded zip into your system at any location并设置Syetem
属性与webdriver.gecko.driver
指向下载可执行geckodriver位置如下: -
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver");
WebDriver driver = new FirefoxDriver();