2011-06-01 79 views
1
$ java -jar selenium-server-standalone-2.0b3.jar 

00:17:03.883 INFO - Java: Sun Microsystems Inc. 19.0-b09 
00:17:03.885 INFO - OS: Linux 2.6.32-305-ec2 i386 
00:17:03.889 INFO - v2.0 [b3], with Core v2.0 [b3] 
00:17:04.501 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 
00:17:04.530 INFO - Version Jetty/5.1.x 
00:17:04.531 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 
00:17:04.532 INFO - Started HttpContext[/selenium-server,/selenium-server] 
00:17:04.532 INFO - Started HttpContext[/,/] 
00:17:04.614 INFO - Started [email protected] 
00:17:04.614 INFO - Started HttpContext[/wd,/wd] 
00:17:04.618 INFO - Started SocketListener on 0.0.0.0:4444 
00:17:04.618 INFO - Started [email protected] 

當我運行此腳本:硒似乎工作,但然後得到超時錯誤?

from selenium.webdriver.common.keys import Keys 
import time 

browser = webdriver.Remote('http://localhost:4444/wd/hub', {'browser_name':'firefox','platform':'ANY', 'version':'','javascript_enabled':True}) 
browser.get("http://www.yahoo.com") 

硒服務器似乎在第一工作:

00:17:08.776 INFO - Executing: [new session: {platform=ANY, browser_name=firefox, javascript_enabled=true, version=}] at URL: /session) 

但後來我得到一個蟒蛇錯誤:

Traceback (most recent call last): 
    File "fb2.py", line 13, in <module> 
    browser = webdriver.Remote('http://localhost:4444/wd/hub', {'browser_name':'firefox','platform':'ANY', 'version':'','javascript_enabled':True}) 
    File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 60, in __init__ 
    self.start_session(desired_capabilities, browser_profile) 
    File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 96, in start_session 
    'desiredCapabilities': desired_capabilities, 
    File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 142, in execute 
    self.error_handler.check_response(response) 
    File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 100, in check_response 
    raise exception_class(message) 
selenium.common.exceptions.WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms 
+0

可能是因爲/ etc/hosts文件具有環回地址。您是否嘗試將值127.0.0.1更改爲正確的IP地址? – 2011-06-01 04:44:32

回答

2

外貌就像你使用Selenium Grid一樣。網格由一個集線器和連接到它的節點組成。當你運行一個測試時,你發送一個請求到服務器,根據你在desired_capabilities中定義的內容,相應地向主機發送相應的配置。在這種情況下,你似乎沒有在任何地方啓動節點。

您似乎無法啓動節點。另外我相信使用WebDriver需要Grid 2.0。據我瞭解,你使用的版本只有RC API的Grid支持。如果您下載並編譯當前中繼,則可以使用以下指南: http://code.google.com/p/selenium/wiki/Grid2

+0

你是怎麼知道他在使用網格的?好奇地知道並學習:) – 2011-06-03 15:27:58

+0

他的RemoteWebDriver連接到http:// localhost:4444/wd/hub,它應該是網格配置的中心。 – 2011-06-03 15:58:11

相關問題