2016-02-23 68 views
0

我想使用Java代碼自動化Node \ Hub配置過程。爲此,我從網上獲取代碼,並在我的測試代碼中執行所需的功能更改和實現。在執行代碼的同時,我可以打開Firefox瀏覽器,但在 myDriver.get(「http://www.google.com」) 聲明之前,執行失敗,並顯示出錯誤。硒網格自動化錯誤

任何人都可以有解決方案嗎?

在此先感謝。

ERROR: 
2016-02-22 13:35:40.103:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT 
2016-02-22 13:35:40.214:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null} 
2016-02-22 13:35:40.237:INFO:osjs.AbstractConnector:Started [email protected]:4444 


    13:35:40.923 INFO - Java: Oracle Corporation 22.1-b02 
    13:35:40.923 INFO - OS: Windows 7 6.1 amd64 
    13:35:40.943 INFO - v2.47.1, with Core v2.47.1. Built from revision 411b314 
    13:35:41.140 INFO - Driver class not found: com.opera.core.systems.OperaDriver 
    13:35:41.140 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered 
    13:35:41.285 INFO - Version Jetty/5.1.x 
    13:35:41.286 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 
    13:35:41.289 INFO - Started HttpContext[/selenium-server,/selenium-server] 
    13:35:41.289 INFO - Started HttpContext[/,/] 
    13:35:41.293 INFO - Started [email protected] 
    13:35:41.293 INFO - Started HttpContext[/wd,/wd] 
    13:35:41.296 INFO - Started SocketListener on 0.0.0.0:5555 
    13:35:41.296 INFO - Started [email protected] 
    13:35:41.308 INFO - Registering the node to the hub: http://localhost:4444/grid/register 
    13:35:41.329 WARN - Max instance not specified. Using default = 1 instance 
    13:35:41.338 INFO - Registered a node http://localhost:5555 
    13:35:41.338 INFO - The node is registered to the hub and ready to use 
    Main URL:------: http://localhost:4444/wd/hub 
    13:35:41.735 INFO - Got a request to create a new session: Capabilities [{platform=WINDOWS, firefox_profile=org.openqa.selenium.firefox.F..., seleniumProtocol=WebDriver, browserName=firefox, version=44.0.2}] 
    13:35:41.736 INFO - Available nodes: [http://localhost:5555] 
    13:35:41.736 INFO - Trying to create a new session on node http://localhost:5555 
    13:35:41.737 INFO - Trying to create a new session on test slot {platform=WINDOWS, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile, seleniumProtocol=WebDriver, browserName=firefox, version=44.0.2} 
    13:35:42.081 INFO - Executing: [new session: Capabilities [{seleniumProtocol=WebDriver, firefox_profile=org.openqa.selenium.firefox.F..., platform=WINDOWS, browserName=firefox, version=44.0.2}]]) 
    13:35:42.118 INFO - Creating a new session for Capabilities [{seleniumProtocol=WebDriver, firefox_profile=org.openqa.selenium.firefox.F..., platform=WINDOWS, browserName=firefox, version=44.0.2}] 
    org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: 
    \[email protected]","installDate":1456148143480,"updateDate":1456148143480,"applyBackgroundUpdates":1,"bootstrap":false,"size":8235030,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":true,"hasBinaryComponents":true,"strictCompatibility":false,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"3.0","maxVersion":"66.*"}],"targetPlatforms":[{"os":"Darwin","abi":null},{"os":"SunOS","abi":null},{"os":"FreeBSD","abi":null},{"os":"OpenBSD","abi":null},{"os":"WINNT","abi":"x86-msvc"},{"os":"Linux","abi":null}],"multiprocessCompatible":false,"signedState":0} 
    1456148144037 addons.xpi DEBUG Updating XPIState for {"id":"{972ce4c6-7e08-4474-a285-3208198ce6fd}","syncGUID":"HmcHDpAIq3gI","location":"app-global","version":"44.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}","installDate":1455253192222,"updateDate":1455253192222,"applyBackgroundUpdates":1,"skinnable":true,"size":24172,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"44.0.2","maxVersion":"44.0.2"}],"targetPlatforms":[]} 
    1456148144038 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd} 
    1456148144039 DeferredSave.extensions.json  DEBUG Save changes 
    1456148144039 addons.xpi DEBUG Updating database with changes to installed add-ons 
    1456148144039 addons.xpi-utils  DEBUG Updating add-on states 
    1456148144041 addons.xpi-utils  DEBUG Writing add-ons list 
    1456148144063 addons.manager  DEBUG Registering shutdown blocker for XPIProvider 
    1456148144064 addons.manager  DEBUG Provider finished startup: XPIProvider 
    1456148144064 addons.manager  DEBUG Starting provider: LightweightThemeManager 
    1456148144064 addons.manager  DEBUG Registering shutdown blocker for LightweightThemeManager 
    1456148144065 addons.manager  DEBUG Provider finished startup: LightweightThemeManager 
    1456148144066 addons.manager  DEBUG Starting provider: GMPProvider 
    1456148144076 addons.manager  DEBUG Registering shutdown blocker for GMPProvider 
    1456148144077 addons.manager  DEBUG Provider finished startup: GMPProvider 
    1456148144077 addons.manager  DEBUG Starting provider: PluginProvider 
    1456148144077 addons.manager  DEBUG Registering shutdown blocker for PluginProvider 
    1456148144078 addons.manager  DEBUG Provider finished startup: PluginProvider 
    1456148144078 addons.manager  DEBUG Completed startup sequence 
    1456148144416 addons.manager  DEBUG Starting provider: <unnamed-provider> 
    1456148144416 addons.manager  DEBUG Registering shutdown blocker for <unnamed-provider> 
    1456148144416 addons.manager  DEBUG Provider finished startup: <unnamed-provider> 
    1456148144543 DeferredSave.extensions.json  DEBUG Starting write 
    1456148144808 addons.repository DEBUG No addons.json found. 
    1456148144808 DeferredSave.addons.json DEBUG Save changes 
    1456148144813 DeferredSave.addons.json DEBUG Starting timer 
    1456148144836 addons.manager  DEBUG Starting provider: PreviousExperimentProvider 
    1456148144837 addons.manager  DEBUG Registering shutdown blocker for PreviousExperimentProvider 
    1456148144837 addons.manager  DEBUG Provider finished startup: PreviousExperimentProvider 
    1456148144843 DeferredSave.extensions.json  DEBUG Write succeeded 
    1456148144844 addons.xpi-utils  DEBUG XPI Database saved, setting schema version preference to 17 
    1456148144878 DeferredSave.addons.json DEBUG Starting write 
    1456148144894 DeferredSave.addons.json DEBUG Write succeeded 

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:122) 
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:276) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:223) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:134) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525) 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103) 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97) 
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60) 
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222) 
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:166) 
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
    at java.lang.Thread.run(Thread.java:722) 
    13:36:29.288 WARN - Exception thrown 
    java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException 
    Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46' 
    System info: host: 'TPR02', ip: '10.1.6.98', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_03' 
    Driver info: driver.version: unknown 

回答

1

我相信WebDriver被實例化了兩次,因此在驅動程序實例化後無法打開瀏覽器。

java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException 
0

硒版本應該與Firefox瀏覽器版本兼容。嘗試一些不同版本的瀏覽器。