当我运行简单的java程序时,我的简单硒测试失败了。 基本上FF浏览器会立即启动并崩溃,从而产生以下错误。
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7056 after 45000 ms. Firefox console output:
79e-8d7a-e26a942a87c8}":{"d":"C:\\Program Files (x86)\\WinZip Courier\\FFExt","e":false,"v":"3.5","st":1340002031091,"mt":1324569850000},"light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com":{"d":"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky Internet Security 16.0.0\\FFExt\\light_plugin_firefox","e":false,"v":"4.6.2-40","st":1464513627629,"mt":1464513107540}}}
1464894922238 addons.xpi DEBUG Existing add-on fxdriver@googlecode.com in app-profile
1464894922239 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1464894922240 addons.xpi DEBUG Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1464894922240 addons.xpi DEBUG Existing add-on {74c841e3-b59f-479e-8d7a-e26a942a87c8} in winreg-app-global
1464894922241 addons.xpi DEBUG Existing add-on light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com in winreg-app-global
1464894922241 addons.xpi DEBUG getInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"C:\\Users\\manideep\\AppData\\Local\\Temp\\anonymous2127859292061232754webdriver-profile\\extensions\\fxdriver@googlecode.com","e":false,"v":"2.45.0","st":1464894915312,"mt":1464894915280}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"44.0.2","st":1462469835718,"mt":1462469835312}},"winreg-app-global":{"{74c841e3-b59f-479e-8d7a-e26a942a87c8}":{"d":"C:\\Program Files (x86)\\WinZip Courier\\FFExt","e":false,"v":"3.5","st":1340002031091,"mt":1324569850000},"light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com":{"d":"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky Internet Security 16.0.0\\FFExt\\light_plugin_firefox","e":false,"v":"4.6.2-40","st":1464513627629,"mt":1464513107540}}}
1464894922243 addons.xpi DEBUG No changes found
1464894922251 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1464894922252 addons.manager DEBUG Provider finished startup: XPIProvider
1464894922252 addons.manager DEBUG Starting provider: LightweightThemeManager
1464894922252 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1464894922252 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1464894922253 addons.manager DEBUG Starting provider: GMPProvider
1464894922259 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1464894922259 addons.manager DEBUG Provider finished startup: GMPProvider
1464894922259 addons.manager DEBUG Starting provider: PluginProvider
1464894922259 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1464894922260 addons.manager DEBUG Provider finished startup: PluginProvider
1464894922260 addons.manager DEBUG Completed startup sequence
1464894922402 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\manideep\AppData\Local\Temp\anonymous2127859292061232754webdriver-profile\extensions.json
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1464894922542 addons.manager DEBUG Starting provider: <unnamed-provider>
1464894922542 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1464894922542 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1464894922657 addons.xpi-utils DEBUG Async JSON file read took 0 MS
1464894922657 addons.xpi-utils DEBUG Finished async read of XPI database, parsing...
1464894922658 addons.xpi-utils DEBUG Successfully read XPI database
1464894922762 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1464894922762 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1464894922763 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
JavaScript warning: https://normandy.cdn.mozilla.net/static/js/bundles/selfrepair-7575f6d27445b45bcffb.js, line 9825: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at org.openqa.selenium.example.Selenium_Test.main(Selenium_Test.java:24)
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7056; process output follows:
79e-8d7a-e26a942a87c8}":{"d":"C:\\Program Files (x86)\\WinZip Courier\\FFExt","e":false,"v":"3.5","st":1340002031091,"mt":1324569850000},"light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com":{"d":"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky Internet Security 16.0.0\\FFExt\\light_plugin_firefox","e":false,"v":"4.6.2-40","st":1464513627629,"mt":1464513107540}}}
1464894922238 addons.xpi DEBUG Existing add-on fxdriver@googlecode.com in app-profile
1464894922239 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1464894922240 addons.xpi DEBUG Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1464894922240 addons.xpi DEBUG Existing add-on {74c841e3-b59f-479e-8d7a-e26a942a87c8} in winreg-app-global
1464894922241 addons.xpi DEBUG Existing add-on light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com in winreg-app-global
1464894922241 addons.xpi DEBUG getInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"C:\\Users\\manideep\\AppData\\Local\\Temp\\anonymous2127859292061232754webdriver-profile\\extensions\\fxdriver@googlecode.com","e":false,"v":"2.45.0","st":1464894915312,"mt":1464894915280}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"44.0.2","st":1462469835718,"mt":1462469835312}},"winreg-app-global":{"{74c841e3-b59f-479e-8d7a-e26a942a87c8}":{"d":"C:\\Program Files (x86)\\WinZip Courier\\FFExt","e":false,"v":"3.5","st":1340002031091,"mt":1324569850000},"light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com":{"d":"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky Internet Security 16.0.0\\FFExt\\light_plugin_firefox","e":false,"v":"4.6.2-40","st":1464513627629,"mt":1464513107540}}}
1464894922243 addons.xpi DEBUG No changes found
1464894922251 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1464894922252 addons.manager DEBUG Provider finished startup: XPIProvider
1464894922252 addons.manager DEBUG Starting provider: LightweightThemeManager
1464894922252 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1464894922252 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1464894922253 addons.manager DEBUG Starting provider: GMPProvider
1464894922259 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1464894922259 addons.manager DEBUG Provider finished startup: GMPProvider
1464894922259 addons.manager DEBUG Starting provider: PluginProvider
1464894922259 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1464894922260 addons.manager DEBUG Provider finished startup: PluginProvider
1464894922260 addons.manager DEBUG Completed startup sequence
1464894922402 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\manideep\AppData\Local\Temp\anonymous2127859292061232754webdriver-profile\extensions.json
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1464894922542 addons.manager DEBUG Starting provider: <unnamed-provider>
1464894922542 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1464894922542 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1464894922657 addons.xpi-utils DEBUG Async JSON file read took 0 MS
1464894922657 addons.xpi-utils DEBUG Finished async read of XPI database, parsing...
1464894922658 addons.xpi-utils DEBUG Successfully read XPI database
1464894922762 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1464894922762 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1464894922763 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
JavaScript warning: https://normandy.cdn.mozilla.net/static/js/bundles/selfrepair-7575f6d27445b45bcffb.js, line 9825: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'manideep-PC', ip: '10.0.0.7', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_25'
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.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:95)
at org.openqa.selenium.example.Selenium_Test.main(Selenium_Test.java:24)
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7056 after 45000 ms. Firefox console output:
79e-8d7a-e26a942a87c8}":{"d":"C:\\Program Files (x86)\\WinZip Courier\\FFExt","e":false,"v":"3.5","st":1340002031091,"mt":1324569850000},"light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com":{"d":"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky Internet Security 16.0.0\\FFExt\\light_plugin_firefox","e":false,"v":"4.6.2-40","st":1464513627629,"mt":1464513107540}}}
1464894922238 addons.xpi DEBUG Existing add-on fxdriver@googlecode.com in app-profile
1464894922239 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1464894922240 addons.xpi DEBUG Existing add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} in app-global
1464894922240 addons.xpi DEBUG Existing add-on {74c841e3-b59f-479e-8d7a-e26a942a87c8} in winreg-app-global
1464894922241 addons.xpi DEBUG Existing add-on light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com in winreg-app-global
1464894922241 addons.xpi DEBUG getInstallState changed: false, state: {"app-profile":{"fxdriver@googlecode.com":{"d":"C:\\Users\\manideep\\AppData\\Local\\Temp\\anonymous2127859292061232754webdriver-profile\\extensions\\fxdriver@googlecode.com","e":false,"v":"2.45.0","st":1464894915312,"mt":1464894915280}},"app-global":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"d":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}","e":true,"v":"44.0.2","st":1462469835718,"mt":1462469835312}},"winreg-app-global":{"{74c841e3-b59f-479e-8d7a-e26a942a87c8}":{"d":"C:\\Program Files (x86)\\WinZip Courier\\FFExt","e":false,"v":"3.5","st":1340002031091,"mt":1324569850000},"light_plugin_D772DC8D6FAF43A29B25C4EBAA5AD1DE@kaspersky.com":{"d":"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky Internet Security 16.0.0\\FFExt\\light_plugin_firefox","e":false,"v":"4.6.2-40","st":1464513627629,"mt":1464513107540}}}
1464894922243 addons.xpi DEBUG No changes found
1464894922251 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1464894922252 addons.manager DEBUG Provider finished startup: XPIProvider
1464894922252 addons.manager DEBUG Starting provider: LightweightThemeManager
1464894922252 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1464894922252 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1464894922253 addons.manager DEBUG Starting provider: GMPProvider
1464894922259 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1464894922259 addons.manager DEBUG Provider finished startup: GMPProvider
1464894922259 addons.manager DEBUG Starting provider: PluginProvider
1464894922259 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1464894922260 addons.manager DEBUG Provider finished startup: PluginProvider
1464894922260 addons.manager DEBUG Completed startup sequence
1464894922402 addons.xpi-utils DEBUG Starting async load of XPI database C:\Users\manideep\AppData\Local\Temp\anonymous2127859292061232754webdriver-profile\extensions.json
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled
1464894922542 addons.manager DEBUG Starting provider: <unnamed-provider>
1464894922542 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1464894922542 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1464894922657 addons.xpi-utils DEBUG Async JSON file read took 0 MS
1464894922657 addons.xpi-utils DEBUG Finished async read of XPI database, parsing...
1464894922658 addons.xpi-utils DEBUG Successfully read XPI database
1464894922762 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1464894922762 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1464894922763 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
JavaScript warning: https://normandy.cdn.mozilla.net/static/js/bundles/selfrepair-7575f6d27445b45bcffb.js, line 9825: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
... 7 more
类似的程序在作为黄瓜程序运行时可以正常工作。
Code for above failing program is :
import java.util.List;
import net.sourceforge.htmlunit.corejs.javascript.tools.shell.Environment;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.Select;
public class Selenium_Test {
// public class Example {
public static void main(String[] args) {
try {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.moneycontrol.com/portfolio_plus/sso/portfolio_signup.php");
}
WebElement element = driver.findElement(By.className("btn_logpor"));
System.out.println(element.getText());
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
Select abc = new Select(driver.findElement(By.xpath("")));
// abc.selectByValue(value);
} catch (Exception e) {
e.printStackTrace();
// }
}
}
}
答案 0 :(得分:0)
问题在于JAR文件,selenium 2.45和2.53独立JAR文件之间存在冲突。
要避免此问题,请确保用于selenium的所有JAR都具有相同的版本。
从MAVEN成功执行的原因是它从Maven依赖项中获取JAR,但是在将程序作为JAVA应用程序运行时,它面临着冲突。