无法使用 Selenium 自动登录 Chase 站点 [英] Unable to use Selenium to automate Chase site login

查看:27
本文介绍了无法使用 Selenium 自动登录 Chase 站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 Selenium (Python) 登录 Chase 网站时,收到以下错误消息:

When I try to log into the Chase website using Selenium (Python), I'm hit with the following error message:

但是,使用人工"登录效果很好.似乎当 Selenium 找到一个元素时,它会触发这个问题.

However, using "human" login works fine. It seems that when Selenium finds an element it triggers the issue.

我错过了什么吗?我试图在 stackoverflow 上找到答案,但无济于事.

Am I missing something? I've tried to find the answer on stackoverflow but to no avail.

预期的结果是脚本将成功允许我以编程方式登录.

The expected result is that the script would successfully allow me to login programatically.

这是下面的代码示例:

import time
import os

from selenium import webdriver

CHASE_USER_ID = os.getenv('CHASE_USER_ID', None)
CHASE_PASSWORD = os.getenv('CHASE_PASSWORD', None)

assert CHASE_USER_ID is not None, 'Chase user id not set'
assert CHASE_PASSWORD is not None, ' Chase password not set'


def main():
    chrome_options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(r'./chromedriver', chrome_options=chrome_options)

    try:
        driver.get('https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?')

        time.sleep(2)

        user_element = driver.find_element_by_id('userId-input-field')  # Finding an element here seems to make the login process fail 
        user_element.send_keys(CHASE_USER_ID)

        password_element = driver.find_element_by_id('password-input-field')
        password_element.send_keys(CHASE_PASSWORD)

        time.sleep(2)

        password_element.submit()

        time.sleep(10)
    finally:
        driver.quit()


if __name__ == '__main__':
    main()

推荐答案

我把你的代码简化了结构,用最少的代码运行了如下测试:

I took your code and simplified the structure and ran the test with minimal lines of code as follows:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait


options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:UtilityBrowserDriverschromedriver.exe')
driver.get("https://secure07c.chase.com/web/auth/#/logon/logon/chaseOnline?")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.jpui.input.logon-xs-toggle.clientSideError"))).send_keys("jsmiao")
driver.find_element_by_css_selector("input.jpui.input.logon-xs-toggle#password-input-field").send_keys("hello")
driver.find_element_by_css_selector("button#signin-button>span.label").click()

同样,根据您的观察,我遇到了与以下错误相同的障碍:

Similarly, as per your observation I have hit the same roadblock with the error as:

似乎 click() 在带有文本的元素上 Sign in 确实发生了.虽然启动了 username/password 查找,但该过程被中断.在检查网页DOM树时,您会发现一些

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆