桔梗花开 发表于 2017-12-7 13:15:17

运行的时候.py,报错

文件为:
# coding=utf-8
from selenium import webdriver

driver = webdriver.Firefox()
driver.get("https://www.baidu.com/")

driver.find_element_by_id("kw").send_keys("Selenium2")
driver.find_element_by_id("su").click()
driver.quit()



运行的时候:
>>>
=== RESTART: C:\Users\www\AppData\Local\Programs\Python\Python36\baidu.py ===
Traceback (most recent call last):
File "C:\Users\www\AppData\Local\Programs\Python\Python36\baidu.py", line 4, in <module>
    driver = webdriver.Firefox()
File "C:\Users\www\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 148, in __init__
    self.service.start()
File "C:\Users\www\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
File "C:\Users\www\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 667, in __init__
    errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File "C:\Users\www\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 905, in _get_handles
    p2cread = self._make_inheritable(p2cread)
File "C:\Users\www\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 955, in _make_inheritable
    _winapi.DUPLICATE_SAME_ACCESS)
OSError: 句柄无效。
运行文件的时候,报错 句柄无效

本才 发表于 2017-12-7 14:10:31

Webdriver 的驱动安装有误,selenium3 是要额外安装Firefox webdriver 的。
页: [1]
查看完整版本: 运行的时候.py,报错