[英]OSError: [WinError 193] %1 is not a valid Win32 application while automating through Selenium ChromeDriver and Chrome in Python
Code block:代码块:
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()
Error:错误:
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
Just extract the chromedriver you have downloaded... chromedriver_win32.zip
make sure you have the chromedriver.exe
file in the downloads...只需提取您下载的 chromedriver... chromedriver_win32.zip
确保您在下载中有chromedriver.exe
文件...
browser = webdriver.Chrome('C:/Users/Cypher/Downloads/chromedriver.exe')
Hope this helps you!希望这对你有帮助!
This error message...这个错误信息...
OSError: [WinError 193] %1 is not a valid Win32 application
...implies that the argument which you have passed to initialize Chrome was not in the valid format. ...暗示您传递给初始化Chrome的参数不是有效格式。
You need to consider a couple of facts as follows:您需要考虑以下几个事实:
The argument executable_path
must be supported with a Value as either of the following:参数executable_path
必须支持以下任一值:
r'C:\\path\\to\\chromedriver.exe'
"C:/python/chromedriver.exe"
"C:\\\\python\\\\chromedriver.exe"
The working line of code will be:工作代码行将是:
from selenium import webdriver browser = webdriver.Chrome(executable_path=r'C:\\path\\to\\chromedriver.exe')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.