python - 键盘无法访问元素 <div id ="password"

标签 python python-3.x selenium selenium-webdriver

我正在尝试登录需要凭据的网站。我在密码页面上收到以下错误:

ElementNotInteractableException: Element <div id="password" class="rFrNMe KSczvd uyaebd BlbNGe zKHdkd sdJrJc Tyc9J"> is not reachable by keyboard

这是罪犯。

enter image description here

有什么解决办法吗?我在 Google 上搜索了 SO 的解决方案,并看到了一些关于 Java 的评论。我正在使用Python,但我还没有找到任何有用的东西。这是我的全部代码。

from bs4 import BeautifulSoup as bs
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
import time
import requests
import urllib.request
import pandas as pd  

    
wd = webdriver.Firefox(executable_path="C:/Utility/geckodriver.exe", firefox_profile=profile)
url = 'https://intra-net-website.com/'
wd.get(url)

# set username
time.sleep(2)
username = wd.find_element_by_id("identifierId")
username.send_keys("first.last@gmail.com")
wd.find_element_by_id("identifierNext").click()

# error occurs here
# set password
time.sleep(2)
password = wd.find_element_by_id("password")
password.send_keys("my_password")
wd.find_element_by_id("passwordNext").click()

如果我手动输入密码,一切都会正常,但这违背了自动化这项工作的目的。也许有一种方法可以欺骗系统。不确定。

最佳答案

从图像来看,您可能希望将send_keys发送到带有name“password”的输入。

password = wd.find_element_by_name("password")

关于python - 键盘无法访问元素 <div id ="password",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53804029/

相关文章:

python - 使用 python 解压缩 zip 文件夹而不更改目录

python - 通过多列中的非唯一值比较两个 csv 文件,输出到匹配的 csv 额外数据

java - 如何使用 java 将 prop.getProperty() 返回的字符串转换为整数

python - 如何在pygame中制作颜色选择器?

python - __getitem__ 空元组参数

python - 损坏的 pip 安装仅适用于 sudo

python - 如何处理TypeError : __call__() takes at least 2 arguments (1 given)?

通过 Selenium 运行测试用例时出现 java.lang.NullPointerException

python - 使用索引切片打印字符串中的每个单词

python - 具有不同 x 和 y 误差的 Pyplot 误差线