python - OSError: [WinError 193] %1 在通过 Selenium ChromeDriver 和 Python 中的 Chrome 进行自动化时不是有效的 Win32 应用程序
问题描述
代码块:
import time
from selenium import webdriver
browser = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver_win32.zip')
browser.maximize_window()
browser.get('https://www.google.com/gmail/')
email_field = browser.find_element_by_id('identifierId')
email_field.clear()
email_field.send_keys('My mail')
email_next_button = browser.find_element_by_id('identifierNext')
email_next_button.click()
time.sleep(1)
password_field = browser.find_element_by_name('password')
password_field.clear()
password_field.send_keys('My password')
password_next_button = browser.find_element_by_id('passwordNext')
password_next_button.click()
time.sleep(100)
browser.quit()
错误:
Traceback (most recent call last):
File "C:/Users/Cypher/PycharmProjects/untitled5/login_gmail.py", line 4, in <module>
driver = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver_win32.zip')
File "C:\Users\Cypher\PycharmProjects\untitled5\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Cypher\PycharmProjects\untitled5\venv\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Cypher\Miniconda3\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\Users\Cypher\Miniconda3\lib\subprocess.py", line 1155, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
解决方案
只需提取您下载的 chromedriver...chromedriver_win32.zip
确保您chromedriver.exe
在下载中包含该文件...
browser = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver.exe')
希望这对你有帮助!
推荐阅读
- ios - pngData 返回 UIImage
- node.js - CSGO,Demofile,NodeJS 获取“无法删除不存在的实体”错误
- xamarin.forms - 如何更改 xamarin 表单的 android 启动器图标
- ios - 如何获取部分平移到屏幕外的 UIView 的可见部分?
- c++ - 打印指向的对象
- r - 从 dplyr 的列表列中保存的混淆矩阵中提取内容
- reactjs - 如何在 reactjs 中使用 recompose 清理表单?
- javascript - 我还需要什么来尝试解决这个 npm start 错误?
- typescript - 如何在 typescript 2.9.1 中将字符串转换为枚举?
- continuous-integration - 在一个 Pipeline 中部署多个 serverless 服务的部署策略