python - 错误: 'value' : keys_to_typing(value)} while sending keys selenium python

标签 python selenium selenium-webdriver

我正在尝试使用 selenium 登录网站,但在向网站发送用户名和密码时遇到错误:

代码:

driver = webdriver.Chrome(
executable_path='../chromedriver')

driver.get('https://secure.imdb.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.imdb.com%2Fap-signin-handler&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=imdb_pro_us&openid.mode=checkid_setup&siteState=eyJvcGVuaWQuYXNzb2NfaGFuZGxlIjoiaW1kYl9wcm9fdXMiLCJyZWRpcmVjdFRvIjoiaHR0cHM6Ly9wcm8uaW1kYi5jb20vdjIvbmFtZS9ubTM0NzUyMDk_cmY9Y29uc19ubV9tZXRlciZyZWZfPW5tX3B1Yl91cHNsYl9sb2dpbiJ9&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&imdbPageAction=login')
driver.find_element_by_id("ap_email").send_keys("username")
driver.find_element_by_id("ap_password").send_keys("pass")
driver.find_element_by_id("signInSubmit").click()

它给出错误:

driver.find_element_by_id("ap_email").send_keys("username") File "/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys 'value': keys_to_typing(value)})

Chrome 版本:

chrome=70.0.3538.77

Chrome 驱动程序版本:

chromedriver=2.43.600229

如何解决这个问题?

最佳答案

正如我所见,如果不点击“使用 IMDb 登录” 链接,您将无法处理身份验证表单。尝试在发送 key 之前单击它:

# driver.find_element_by_id('login_with_imdb_expender').click()
driver.find_element_by_link_text('Log in with IMDb').click()
driver.find_element_by_id("ap_email").send_keys("username")
driver.find_element_by_id("ap_password").send_keys("pass")

关于python - 错误: 'value' : keys_to_typing(value)} while sending keys selenium python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53003590/

相关文章:

python - 使用 Selenium 时出错 (Python) : Unable to find class in HTML source code

java - geb geckodriver 无法正常工作(启动多个浏览器窗口)

python - 使用 selenium python webdriver 滚动网页

python - 消息 : element not intractable still not working even after a time. sleep() 和 WebDriverWait

selenium - 禁用 Firefox 的声音? ( Selenium 网络驱动程序编程)

javascript - 如何使用 Selenium 从下拉列表中选择一个值?

python - 如果文件存在,使用装饰器检索 jsondata,否则运行方法然后将输出存储为 json?

python - 有没有什么方法可以使用 pandas(不是 groupby)按条件将多行合并为一行?

python - 价格不会显示在 html 解析中

python - 使用 Python 3 中调用 super() 的 4 种方法中的哪一种?