python selenium 连接到firefox后只打开网页后就没有反应了
在windows上配置好python3.5 + selenium 3.5 ,运行一个小程序(打开firefox,打开百度首页),在打开firefox之后就没有反应了,也不会打开网页,等待很久后报错connect refused,这个是为什么? 大概率是因为不兼容 1、上代码,看看是不是你的代码有问题!2、看看是不是Firefox的驱动不兼容你电脑上安装的Firefox的版本! selenium3.5不支持firefox默认的driver,建议使用selenium2.X
参考资料:
http://www.cnblogs.com/ppppying/p/6143803.html 贴上代码和报错信息! 是不是没有下载驱动软件 我的win 10 代码不报错,启动起来浏览器就报异常。 Miss_love 发表于 2017-9-18 11:06
大概率是因为不兼容
不清楚哇。 神仙也考试 发表于 2017-9-18 10:59
1、上代码,看看是不是你的代码有问题!
2、看看是不是Firefox的驱动不兼容你电脑上安装的Firefox的版本!
代码:
# coding = utf-8
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.baidu.com")
browser.find_element_by_id("kw").send_keys("selenium")
browser.find_element_by_id("su").click()
browser.quit()
报错信息:
C:\Users\Administrator\AppData\Local\Programs\Python\Python35\python.exe C:/Users/Administrator/PycharmProjects/untitled/webtest/test_1.py
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/untitled/webtest/test_1.py", line 3, in <module>
browser = webdriver.Firefox()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 154, in __init__
keep_alive=True)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused .chao 发表于 2017-9-18 16:37
是不是没有下载驱动软件
下了的,:'( 清晨一缕阳光 发表于 2017-9-18 11:13
贴上代码和报错信息!
代码:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.baidu.com")
browser.find_element_by_id("kw").send_keys("selenium")
browser.find_element_by_id("su").click()
browser.quit()
告警信息:
C:\Users\Administrator\AppData\Local\Programs\Python\Python35\python.exe C:/Users/Administrator/PycharmProjects/untitled/webtest/test_1.py
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/untitled/webtest/test_1.py", line 3, in <module>
browser = webdriver.Firefox()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 154, in __init__
keep_alive=True)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused 余温_zey 发表于 2017-9-18 20:51
代码:
# coding = utf-8
from selenium import webdriver
已经解决,是Firefox的驱动版本不对,多谢 Miss_love 发表于 2017-9-18 11:06
大概率是因为不兼容
果然是,我的Firefox驱动的版本不对,换了个最新的就好了:lol
页:
[1]