“无法加载配置文件" Selenium WebDriver通过Python3.5和FF48发生错误 [英] "Can't load the profile" error occured with Selenium WebDriver by Python3.5 and FF48

查看:111
本文介绍了“无法加载配置文件" Selenium WebDriver通过Python3.5和FF48发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我正在尝试将Selenium与Python配合使用.
 因此,我编写了以下代码,并将其保存为工作目录/Users/ykt68/seleniumwork 中的名为 test.py 的文件.

 I'm trying to use Selenium with Python.
 So, I wrote the following codes and save as the file named test.py in working directory /Users/ykt68/seleniumwork .

[ykt68@macbp15 seleniumwork]$ pwd
/Users/ykt68/seleniumwork
[ykt68@macbp15 seleniumwork]$ cat -n test.py

     1  #! /usr/bin/env python
     2  # -*- encoding: utf-8 -*-
     3  
     4  from selenium import webdriver
     5  from selenium.webdriver.common.keys import Keys
     6  
     7  driver = webdriver.Firefox()
     8  driver.get("http://www.python.org")
     9  assert "Python" in driver.title
    10  elem = driver.find_element_by_name("q")
    11  elem.clear()
    12  elem.send_keys("pycon")
    13  elem.send_keys(Keys.RETURN)
    14  assert "No results found." not in driver.page_source
    15  driver.close()

[ykt68@macbp15 seleniumwork]$

 以上这些代码与 2.1简单用法 Selenium with Python 的文档中.

 These codes above are the same as 2.1 Simple Usage in documents of Selenium with Python.

 当我为上述test.py运行python命令时,

 When I ran the python command for test.py above,

  • FireFox浏览器启动并打开一个空白标签.
  • 大约30秒后,显示以下错误消息并关闭了FireFox窗口.
[ykt68@macbp15 seleniumwork]$ python test.py 
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    driver = webdriver.Firefox()
  File "/Users/ykt68/.pyenv/versions/seleniumwork/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
    self.binary, timeout)
  File "/Users/ykt68/.pyenv/versions/seleniumwork/lib/python3.5/site-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in    __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/Users/ykt68/.pyenv/versions/seleniumwork/lib/python3.5/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/Users/ykt68/.pyenv/versions/seleniumwork/lib/python3.5/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 108, in _wait_until_connectable
    % (self.profile.path))
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/86/55p1gj4j4xz2nw9g5q224bk40000gn/T/tmpf0uolidn If you specified a log_file in the FirefoxBinary constructor, check it for details.

[ykt68@macbp15 seleniumwork]$

 请教我为什么会发生此错误以及如何解决该问题,或者列出一些我应该参考的帖子或文件.

 Please teach me why this error has occured and how to solve the problem or list some posts or documents I should refer.

 此外

  1. 环境:
    • 操作系统:Apple OS X 10.11.6版
    • Python版本:3.5.2
    • FireFox版本:48.0.2
    • 硒版本:2.53.6
  1. Environments:
    • OS: Apple OS X Version 10.11.6
    • Python Version: 3.5.2
    • FireFox Version: 48.0.2
    • selenium Version: 2.53.6

[ykt68@macbp15 seleniumwork]$ python -V
Python 3.5.2
[ykt68@macbp15 seleniumwork]$ /Applications/Firefox.app/Contents/MacOS/firefox -v
Mozilla Firefox 48.0.2
[ykt68@macbp15 seleniumwork]$ /Applications/Firefox.app/Contents/MacOS/firefox-bin -v
Mozilla Firefox 48.0.2
[ykt68@macbp15 seleniumwork]$ pip list
pip (8.1.2)
selenium (2.53.6)
setuptools (20.10.1)
[ykt68@macbp15 seleniumwork]$

  1. 我推荐了类似的帖子 Selenium:FirefoxProfile异常无法加载配置文件.所以我尝试了
  1. I reffered the similar post of Selenium: FirefoxProfile exception Can't load the profile. So I tried

pip install -U selenium

但是上面出现错误消息的情况保持不变.

But the situation with error messages above remains unchanged.

最好的问候.

推荐答案

根据我的理解和结论,可以保留最新的selenium软件包版本,但必须将Firefox降级为47 ( 47.0.1 是47分支的最新稳定版).

From what I understand and concluded, you can keep the latest selenium package version, but you have to downgrade Firefox to 47 (47.0.1 is the latest stable from the 47 branch).

这篇关于“无法加载配置文件" Selenium WebDriver通过Python3.5和FF48发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆