刚开始学习selenium,在pycharm中运行正常,使用pyinstaller -F 打包后提示出错。错误代码如下
请教问题出在哪?我看说是路径出错了。但是不太明白为什么会这样。
Traceback (most recent call last):
File "selenium\webdriver\common\service.py", line 71, in start
File "subprocess.py", line 854, in __init__
File "subprocess.py", line 1307, in _execute_child
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sh1.4.py", line 7, in <module>
File "selenium\webdriver\chrome\webdriver.py", line 70, in __init__
File "selenium\webdriver\chromium\webdriver.py", line 90, in __init__
File "selenium\webdriver\common\service.py", line 81, in start
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
[10996] Failed to execute script 'sh1.4' due to unhandled exception!
这个是python的代码
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(options=chrome_options)
driver.get("http://youtonwangluo.cn/#/login?redirect=%2FbillDetail%2FbillDetail_examine")
print('开始打开网页')
driver.find_element("name", "username").send_keys("0000002")
driver.find_element("name", "password").send_keys("123456")
print('登录成功')
driver.find_element("class name", "el-button--primary").click()
time.sleep(5)
driver.find_element("class name", "el-icon-search").click() # 查找开始
print('开始更新数据')
try:
n = 10
for i in range(10):
time.sleep(5)
driver.find_element("class name", "el-checkbox__inner").click()
time.sleep(1)
driver.find_element("class name", "el-icon-s-help").click()
time.sleep(1)
driver.find_element("class name", "el-button--primary").click()
print(n, "条数据已审核")
n = n + 10
except:
driver.close()
print("自动审核已完成")
|