问题描述
- python+selenium无法用firefox加载网页
-
最近在学习selenium遇到的这个问题,只能打开firefox,之后就没法加载url,公司的电脑我试下是可以的,网上搜了很多资料也没有解决,很纠结,请大家帮忙看看...
python代码:
from selenium import webdriver
from time import sleeps = webdriver.Firefox()
s.get('https://www.baidu.com')
s.find_element_by_id('kw').send_keys('python')
sleep(3)s.find_element_by_id('su').click()
sleep(5)s.quit()
打印的报错信息:
Traceback (most recent call last):
File "D:/python/new.py", line 5, in
s = webdriver.Firefox()
File "C:Python27libsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverfirefoxwebdriver.py", line 77, in init
self.binary, timeout),
File "C:Python27libsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverfirefoxextension_connection.py", line 49, in init
self.binary.launch_browser(self.profile)
File "C:Python27libsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverfirefoxfirefox_binary.py", line 68, in launch_browser
self._wait_until_connectable()
File "C:Python27libsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverfirefoxfirefox_binary.py", line 103, in _wait_until_connectable
raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
我的环境是:
python2.7.11 selenium2.48 Firefox42
解决方案
你的firefox的profile是否有问题。
解决方案二:
casperjs无法加载https的网页
解决方案三:
楼上的回答很风趣,有可能是版本不兼容