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