当我运行我的webdriver项目时,有时它会抛出“Not Connected”的异常,有时它工作正常。
此外,当它连接并开始执行时,然后在执行中它无法找到对象并执行将保留在那里..
由于我已经看到一些参考网站并发现它们是一些配置问题,所以我尝试过以下几点:
任何人都可以让我知道解决问题的方法。
控制台输出:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
,"maxVersion":"47.0"}],"targetPlatforms":[{"os":"Darwin","abi":null},{"os":"SunOS","abi":null},{"os":"FreeBSD","abi":null},{"os":"OpenBSD","abi":null},{"os":"WINNT","abi":null},{"os":"Linux","abi":null}],"multiprocessCompatible":false,"signedState":0}
1459838940361 addons.xpi DEBUG getModTime: Recursive scan of fxdriver@googlecode.com
1459838940392 addons.xpi DEBUG Updating XPIState for {"id":"{972ce4c6-7e08-4474-a285-3208198ce6fd}","syncGUID":"VkfhbWyu_8Qh","location":"app-global","version":"44.0","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}","installDate":1457930979545,"updateDate":1457930979545,"applyBackgroundUpdates":1,"skinnable":true,"size":24166,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"44.0","maxVersion":"44.0"}],"targetPlatforms":[]}
1459838940392 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1459838940396 DeferredSave.extensions.json DEBUG Save changes
1459838940396 addons.xpi DEBUG Updating database with changes to installed add-ons
1459838940396 addons.xpi-utils DEBUG Updating add-on states
1459838940399 addons.xpi-utils DEBUG Writing add-ons list
1459838940424 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1459838940425 addons.manager DEBUG Provider finished startup: XPIProvider
1459838940425 addons.manager DEBUG Starting provider: LightweightThemeManager
1459838940425 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1459838940425 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1459838940426 addons.manager DEBUG Starting provider: GMPProvider
1459838940438 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1459838940439 addons.manager DEBUG Provider finished startup: GMPProvider
1459838940439 addons.manager DEBUG Starting provider: PluginProvider
1459838940439 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1459838940440 addons.manager DEBUG Provider finished startup: PluginProvider
1459838940440 addons.manager DEBUG Completed startup sequence
1459838941252 addons.manager DEBUG Starting provider: <unnamed-provider>
1459838941252 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1459838941253 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1459838941515 DeferredSave.extensions.json DEBUG Starting write
1459838942317 addons.repository DEBUG No addons.json found.
1459838942317 DeferredSave.addons.json DEBUG Save changes
1459838942322 DeferredSave.addons.json DEBUG Starting timer
1459838942348 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1459838942348 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1459838942349 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
1459838942357 DeferredSave.extensions.json DEBUG Write succeeded
1459838942358 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 17
JavaScript error: chrome://fxdriver/content/server.js, line 61: uncaught exception: [object Object]
JavaScript error: chrome://fxdriver/content/server.js, line 61: NS_ERROR_XPC_CI_RETURNED_FAILURE: Component returned failure code: 0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE) [nsIJSCID.createInstance]
1459838942625 DeferredSave.addons.json DEBUG Starting write
1459838943133 DeferredSave.addons.json DEBUG Write succeeded
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:112)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at com.chayan.af.MainClass.<init>(MainClass.java:64)
at com.chayan.af.MainClass.main(MainClass.java:70)
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows:
,"maxVersion":"47.0"}],"targetPlatforms":[{"os":"Darwin","abi":null},{"os":"SunOS","abi":null},{"os":"FreeBSD","abi":null},{"os":"OpenBSD","abi":null},{"os":"WINNT","abi":null},{"os":"Linux","abi":null}],"multiprocessCompatible":false,"signedState":0}
1459838940361 addons.xpi DEBUG getModTime: Recursive scan of fxdriver@googlecode.com
1459838940392 addons.xpi DEBUG Updating XPIState for {"id":"{972ce4c6-7e08-4474-a285-3208198ce6fd}","syncGUID":"VkfhbWyu_8Qh","location":"app-global","version":"44.0","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}","installDate":1457930979545,"updateDate":1457930979545,"applyBackgroundUpdates":1,"skinnable":true,"size":24166,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"44.0","maxVersion":"44.0"}],"targetPlatforms":[]}
1459838940392 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1459838940396 DeferredSave.extensions.json DEBUG Save changes
1459838940396 addons.xpi DEBUG Updating database with changes to installed add-ons
1459838940396 addons.xpi-utils DEBUG Updating add-on states
1459838940399 addons.xpi-utils DEBUG Writing add-ons list
1459838940424 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1459838940425 addons.manager DEBUG Provider finished startup: XPIProvider
1459838940425 addons.manager DEBUG Starting provider: LightweightThemeManager
1459838940425 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1459838940425 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1459838940426 addons.manager DEBUG Starting provider: GMPProvider
1459838940438 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1459838940439 addons.manager DEBUG Provider finished startup: GMPProvider
1459838940439 addons.manager DEBUG Starting provider: PluginProvider
1459838940439 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1459838940440 addons.manager DEBUG Provider finished startup: PluginProvider
1459838940440 addons.manager DEBUG Completed startup sequence
1459838941252 addons.manager DEBUG Starting provider: <unnamed-provider>
1459838941252 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1459838941253 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1459838941515 DeferredSave.extensions.json DEBUG Starting write
1459838942317 addons.repository DEBUG No addons.json found.
1459838942317 DeferredSave.addons.json DEBUG Save changes
1459838942322 DeferredSave.addons.json DEBUG Starting timer
1459838942348 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1459838942348 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1459838942349 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
1459838942357 DeferredSave.extensions.json DEBUG Write succeeded
1459838942358 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 17
JavaScript error: chrome://fxdriver/content/server.js, line 61: uncaught exception: [object Object]
JavaScript error: chrome://fxdriver/content/server.js, line 61: NS_ERROR_XPC_CI_RETURNED_FAILURE: Component returned failure code: 0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE) [nsIJSCID.createInstance]
1459838942625 DeferredSave.addons.json DEBUG Starting write
1459838943133 DeferredSave.addons.json DEBUG Write succeeded
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'sipl157', ip: '10.10.10.157', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_60'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:124)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at com.chayan.af.MainClass.<init>(MainClass.java:64)
at com.chayan.af.MainClass.main(MainClass.java:70)
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:
,"maxVersion":"47.0"}],"targetPlatforms":[{"os":"Darwin","abi":null},{"os":"SunOS","abi":null},{"os":"FreeBSD","abi":null},{"os":"OpenBSD","abi":null},{"os":"WINNT","abi":null},{"os":"Linux","abi":null}],"multiprocessCompatible":false,"signedState":0}
1459838940361 addons.xpi DEBUG getModTime: Recursive scan of fxdriver@googlecode.com
1459838940392 addons.xpi DEBUG Updating XPIState for {"id":"{972ce4c6-7e08-4474-a285-3208198ce6fd}","syncGUID":"VkfhbWyu_8Qh","location":"app-global","version":"44.0","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}","installDate":1457930979545,"updateDate":1457930979545,"applyBackgroundUpdates":1,"skinnable":true,"size":24166,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"44.0","maxVersion":"44.0"}],"targetPlatforms":[]}
1459838940392 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1459838940396 DeferredSave.extensions.json DEBUG Save changes
1459838940396 addons.xpi DEBUG Updating database with changes to installed add-ons
1459838940396 addons.xpi-utils DEBUG Updating add-on states
1459838940399 addons.xpi-utils DEBUG Writing add-ons list
1459838940424 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1459838940425 addons.manager DEBUG Provider finished startup: XPIProvider
1459838940425 addons.manager DEBUG Starting provider: LightweightThemeManager
1459838940425 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1459838940425 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1459838940426 addons.manager DEBUG Starting provider: GMPProvider
1459838940438 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1459838940439 addons.manager DEBUG Provider finished startup: GMPProvider
1459838940439 addons.manager DEBUG Starting provider: PluginProvider
1459838940439 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1459838940440 addons.manager DEBUG Provider finished startup: PluginProvider
1459838940440 addons.manager DEBUG Completed startup sequence
1459838941252 addons.manager DEBUG Starting provider: <unnamed-provider>
1459838941252 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1459838941253 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1459838941515 DeferredSave.extensions.json DEBUG Starting write
1459838942317 addons.repository DEBUG No addons.json found.
1459838942317 DeferredSave.addons.json DEBUG Save changes
1459838942322 DeferredSave.addons.json DEBUG Starting timer
1459838942348 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1459838942348 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1459838942349 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
1459838942357 DeferredSave.extensions.json DEBUG Write succeeded
1459838942358 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 17
JavaScript error: chrome://fxdriver/content/server.js, line 61: uncaught exception: [object Object]
JavaScript error: chrome://fxdriver/content/server.js, line 61: NS_ERROR_XPC_CI_RETURNED_FAILURE: Component returned failure code: 0x80570015 (NS_ERROR_XPC_CI_RETURNED_FAILURE) [nsIJSCID.createInstance]
1459838942625 DeferredSave.addons.json DEBUG Starting write
1459838943133 DeferredSave.addons.json DEBUG Write succeeded
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:112)
... 8 more
代码:
public class MainClass {
/*private static final String BROWSER_PATH = "D:\\abc\\setup\\FFinstalled\\firefox.exe";*/
private static final String BROWSER_PATH = "C:\\Program Files (x86)\\Mozilla\\firefox.exe";
/*private static final String TEST_SUITE_PATH = "D:\\abc\\workspace for selenium\\AutomationFramework(16 june)\\AutomationFramework\\configuration\\GmailTestSuite.xls";
private static final String TEST_RESULT = "D:\\abc\\workspace for selenium\\AutomationFramework(16 june)\\AutomationFramework\\configuration\\TestResult.xls";
private static final String OBJECT_REPOSITORY_PATH = "D:\\abc\\workspace for selenium\\AutomationFramework(16 june)\\AutomationFramework\\configuration\\objectrepository.xls";*/
private static final String TEST_SUITE_PATH = "D:\\abc\\workspace for selenium\\AutomationFramework(16 june)\\AutomationFramework\\StackTestSuite.xls";
private static final String TEST_RESULT = "D:\\abc\\workspace for selenium\\AutomationFramework(16 june)\\AutomationFramework\\TestResult - Copy.xls";
private static final String OBJECT_REPOSITORY_PATH = "D:\\abc\\workspace for selenium\\AutomationFramework(16 june)\\AutomationFramework\\objectrepository.xls";
private static final String ADDRESS_TO_TEST = "http://stackoverflow.com/";
// other constants
static WebDriver driver=null;
private Properties properties;
private String screenshotName;
WebDriverWait wait;
/* private WebElement we; */
public MainClass() {
File file = new File(BROWSER_PATH);
FirefoxBinary fb = new FirefoxBinary(file);
FirefoxProfile firefoxProfile = new FirefoxProfile();
driver = new FirefoxDriver(fb, firefoxProfile);
driver.manage().window().maximize();
//driver= new FirefoxDriver();
driver.get(ADDRESS_TO_TEST);
}