【发布时间】:2019-11-11 19:00:09
【问题描述】:
我正在尝试使用 Selenium 和 Fidelity 登录我的 Fidelity 帐户。我已经确定我使用的是正确的网络驱动程序(我的 Chrome 版本 78 是版本 78)。我认为这与唯一的 Chrome 网络驱动程序是 32 位有关,而我使用的是 64 位。这是我得到的最后一个错误。它打开网页,输入我的用户名和密码,然后我认为在按钮上单击它会崩溃或就在它之前。
from selenium import webdriver
def test_bot(username, password):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
br = webdriver.Chrome(chrome_options=chrome_options)
br.get("https://www.fidelity.com")
br.implicitly_wait(10)
user = br.find_element_by_id('userId-input')
user.clear()
user.send_keys(username)
pwd = br.find_element_by_id('password')
pwd.clear()
pwd.send_keys(password)
btn = br.find_element_by_id('fs-login-button')
btn.click()
test_bot("MYUSERNAME", "MYPASSWORD")
这是我遇到的错误。
Exception ignored in: <function Popen.__del__ at 0x03957270>
Traceback (most recent call last):
File "C:\Users\Notebook\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 860, in __del__
self._internal_poll(_deadstate=_maxsize)
File "C:\Users\Notebook\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1216, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
我正在使用 Pycharm 和 Selenium。
【问题讨论】:
-
你试过评论
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])这一行吗? -
感谢您的推荐。我试着注释掉它,它仍然没有用。该行可防止 Chrome 因使用自动化而对您大喊大叫。
标签: python selenium xpath css-selectors webdriverwait