错误:[Errno 111]连接被拒绝-Python,Selenium
我正在学习使用硒。到目前为止,我成功地使它工作。所以,现在我想使用Selenium IDE记录导航序列,将它们导出到python并运行它们 这是我使用的代码错误:[Errno 111]连接被拒绝-Python,Selenium,python,sockets,selenium,selenium-ide,Python,Sockets,Selenium,Selenium Ide,我正在学习使用硒。到目前为止,我成功地使它工作。所以,现在我想使用Selenium IDE记录导航序列,将它们导出到python并运行它们 这是我使用的代码 from selenium import selenium import unittest, time, re #from pyvirtualdisplay import Display class rc(unittest.TestCase): def setUp(self): self.verificationErrors =
from selenium import selenium
import unittest, time, re
#from pyvirtualdisplay import Display
class rc(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
#self.display = Display(visible=0, size=(1024, 768))
#self.display.start()
self.selenium = selenium("localhost", 4444, "*chrome", "http://www.some-website.in")
self.selenium.start()
def test_rc(self):
sel = self.selenium
sel.click("link=Careers")
response = sel.get_title()
print response
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
#self.display.stop()
if __name__ == '__main__':
unittest.main()
注释行是手动添加的,并在它们工作的情况下进行了尝试(就像在上一个基本示例中所做的那样,我只想让selenium工作并解决依赖关系)
运行此自动生成的python代码时,我得到:
File "mytest_test.py", line 34, in setUp
self.selenium.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 202, in start
result = self.get_string("getNewBrowserSession", start_args)
File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 237, in get_string
result = self.do_command(verb, args)
File "/usr/local/lib/python2.7/dist-packages/selenium/selenium.py", line 226, in do_command
conn.request("POST", "/selenium-server/driver/", body, headers)
File "/usr/lib/python2.7/httplib.py", line 973, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
帮助?您已经为selenium RC转换了测试脚本,所以在执行测试脚本之前,请确保selenium RC server正在您的机器上运行 运行selenium服务器的以下命令的用户: 打开命令提示符,转到下载的selenium服务器jar文件并运行命令 java-jar selenium-server-standalone-2.47.1.jar
在我的例子中,问题在于Chrome和chromedriver的版本不兼容 在终端中检查以下命令:
cd <<your test folder>>
which chromedriver
chromedriver --version
cd
哪一个镀铬器
彩色驱动程序-版本
并将该版本与chromedriver的最新版本进行比较:
当您面临这样的问题时,请检查您的
geckodriver
设置
当您打开浏览器时,您的木偶驱动程序代码的注释如下:#cap['marionete']=True
不要为Linux启用木偶驱动程序