2016-07-26 62 views
0

Jenkins運行的自動化測試設置不時失敗。當測試設置失敗時,它將跳過所有其他測試設置和測試。它在Mozilla Firefox上運行。Selenium中的失敗testSetup

有沒有機會擺脫異常?

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7056 after 45000 ms. Firefox console output: 
1469480338859 addons.manager DEBUG Application has been upgraded 
1469480338873 addons.manager DEBUG Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"] 
1469480338875 addons.manager DEBUG Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"] 
1469480338879 addons.xpi DEBUG startup 
1469480338880 addons.xpi DEBUG Skipping unavailable install location app-system-local 
1469480338881 addons.xpi DEBUG Skipping unavailable install location app-system-share 
1469480338882 addons.xpi INFO Mapping {972ce4c6-7e08-4474-a285-3208198ce6fd} to C:\Program Files (x86)\Mozilla Firefox\browser\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd} 
1469480338883 addons.xpi INFO Mapping [email protected] to C:\Users\user\AppData\Local\Temp\anonymous7098252712982546494webdriver-profile\extensions\[email protected] 
1469480338883 addons.xpi INFO Mapping [email protected] to C:\Users\user\AppData\Local\Temp\anonymous7098252712982546494webdriver-profile\extensions\[email protected] 
1469480338884 addons.xpi DEBUG Ignoring file entry whose name is not a valid add-on ID: C:\Users\user\AppData\Local\Temp\anonymous7098252712982546494webdriver-profile\extensions\webdriver-staging 
1469480338884 addons.xpi DEBUG checkForChanges 
1469480338894 addons.xpi DEBUG Directory state JSON differs: cache [] state [{"name":"app-global","addons":{"{972ce4c6-7e08-4474-a285-3208198ce6fd}":{"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}","mtime":1434617609039,"rdfTime":1417010916000}}},{"name":"app-profile","addons":{"[email protected]":{"descriptor":"C:\\Users\\user\\AppData\\Local\\Temp\\anonymous7098252712982546494webdriver-profile\\extensions\\[email protected]","mtime":1469480305220,"rdfTime":1469480305217},"[email protected]":{"descriptor":"C:\\Users\\user\\AppData\\Local\\Temp\\anonymous7098252712982546494webdriver-profile\\extensions\\[email protected]","mtime":1469480303712,"rdfTime":1469480303712}}}] 
1469480338900 addons.xpi-utils DEBUG Opening XPI database C:\Users\user\AppData\Local\Temp\anonymous7098252712982546494webdriver-profile\extensions.json 
1469480338901 addons.xpi DEBUG New add-on [email protected] installed in app-profile 
*** Blocklist::_loadBlocklistFromFile: blocklist is disabled 
1469480339870 addons.xpi-utils DEBUG Make addon app-profile:[email protected] visible 
1469480339874 DeferredSave.extensions.json DEBUG Save changes 
1469480339878 DeferredSave.extensions.json DEBUG Save changes 
1469480339878 addons.xpi DEBUG New add-on [email protected] installed in app-profile 
1469480339886 addons.xpi-utils DEBUG Make addon app-profile:[email protected] visible 
1469480339887 DeferredSave.extensions.json DEBUG Save changes 
1469480339887 DeferredSave.extensions.json DEBUG Save changes 
1469480339887 addons.xpi DEBUG New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global 
1469480339892 addons.xpi-utils DEBUG Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible 
1469480339893 DeferredSave.extensions.json DEBUG Save changes 
1469480339893 DeferredSave.extensions.json DEBUG Save changes 
1469480339907 addons.xpi DEBUG Updating database with changes to installed add-ons 
1469480339907 addons.xpi-utils DEBUG Updating add-on states 
1469480339908 addons.xpi-utils DEBUG Writing add-ons list 
1469480339919 addons.manager DEBUG Registering shutdown blocker for XPIProvider 
1469480339921 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager 
1469480339924 addons.manager DEBUG Registering shutdown blocker for OpenH264Provider 
1469480339925 addons.manager DEBUG Registering shutdown blocker for PluginProvider 
1469480349163 DeferredSave.extensions.json DEBUG Starting timer 
1469480349708 DeferredSave.extensions.json DEBUG Starting write 

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:113) 
    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:216) 
    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:124) 
    at com.intuit.ifs.csscat.core.WebDriverFactory.getWebDriver(WebDriverFactory.java:104) 
    at com.intuit.ifs.csscat.core.BaseTestNGWebDriver.testSetup(BaseTestNGWebDriver.java:71) 
    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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) 
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) 
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:640) 
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894) 
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219) 
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) 
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) 
    at org.testng.TestRunner.privateRun(TestRunner.java:768) 
    at org.testng.TestRunner.run(TestRunner.java:617) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:240) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1188) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1113) 
    at org.testng.TestNG.run(TestNG.java:1025) 
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:122) 
    at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) 
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101) 
    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:172) 
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104) 
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70) 

Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) 
+0

根據錯誤,firefox和selenium之間沒有進行firefox連接。你能確保版本和RAM的可用性是好的。 – selva

回答

0

當無法啓動請求的網絡驅動程序時會發生這種情況。有兩種情況我親自看到了這種情況:(1)Selenium版本和Firefox版本之間存在不兼容問題;(2)當Firefox已經運行太多的實例並且二進制文件無法啓動時。既然你說這是間歇性的,我假設(1)不是問題,並假設你正在跑(2)。我不知道你是否並行運行你的測試,不知道你的自動化設置我會說簡單的解決方案是將WebDriver的創建包裝成一個try-catch塊的循環,處理該異常。我建議而不是使循環無限(例如給它一個超時)。還要注意,這是簡單的解決方案,但不一定是最好的。通常,如何最好地處理資源管理高度依賴於測試環境,運行的測試數量,並行度(如果有的話)等。

另外,請注意,如果您在配置方法中有異常(例如安裝程序),它會跳過其他測試,因爲它在運行測試時需要「在錯誤配置上快速失敗」的思路。如果你不需要希望你需要在捕獲和處理這些配置方法中的所有異常時保持一致。

+0

非常感謝Aaron。我們正在同時進行測試。不同的服裝,但在同一臺服務器上,所以這一定是這種情況。我會在內部討論什麼解決方案可能是最好的,如果有幫助,我們如何解決問題,請回復您。 –

相關問題