【发布时间】:2019-12-24 20:03:29
【问题描述】:
我是自动化的新手。我正在尝试在 Omegle 的文本框中输入一个字符串,然后按 Enter,但它向我显示了一个错误:
selenium.common.exceptions.ElementNotInteractableException:消息:键盘无法访问元素
here 是我要访问文本框的网页链接。
import time
import random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.get("https://www.omegle.com/")
time.sleep(random.randint(2, 5))
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(random.randint(1, 5))
button = driver.find_element(By.XPATH, "//span[@class='topicplaceholder']")
button.click()
button.send_keys("panda")
button.send_keys(Keys.RETURN)
【问题讨论】:
-
如果您单击的是一个按钮,那么您应该无法向它发送密钥,因为它不是文本输入点。重新评估网站以获得更好的互动方式
-
我怎样才能找到输入点,在项目中我又遇到了同样的问题,但在不同的文本字段,你能告诉我如何找到可交互的点吗?
标签: python python-3.x selenium automation