天天看点

python+selenium 者常见错误

1.浏览器版本于driver与兼容,需要重新下载兼容浏览器版本的驱动

call function result missing 'value
           
cannot get automation extension
           

解决方案:

Chrome 驱动地址

参考版本:

chrome:67.0.3396.62(正式版本)

driver:2.37.0

注:64位计算机兼容32位

更多关于driver问题: chrome版本和chromedriver.exe

2.selenium 语法错误: Message: no such session

Traceback (most recent call last): File "E:/Python_selenium/PycharmProjects/data/run.py", line 22, in print(driver.title)

  File "E:\Python_selenium\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 222, in title

    resp = self.execute(Command.GET_TITLE)

  File "E:\Python_selenium\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute

    self.error_handler.check_response(response)

  File "E:\Python_selenium\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response

    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: no such session
           

3.

clear()

无效的元素状态:元素必须是用户可编辑的,才能清除它。

invalid element state: Element must be user-editable in order to clear it.

首先需要确保这个元素能输入内容,如果可以send_keys(),却不能clear(),那么试试先对元素click(),让焦点在元素上再clear()

4.弹出Edit configuration 解决方案

在GitHub上下载了一个项目,导入后每执行一个模块都会弹出,如下图:(PS:因为问题发生时忘记截图,现在网上找了一个图)

python+selenium 者常见错误

原因是 这个工程没有配置python解释器,具体设置方法如下:

1.打开File下的settings

python+selenium 者常见错误

2.选择相应的python解释器后,点击Apply(必要步骤),点击OK,设置完成,此工程文件可以正常执行了

python+selenium 者常见错误