Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python Seleniu send_key()不工作_Python_Python 3.x_Selenium_Automation - Fatal编程技术网

python Seleniu send_key()不工作

python Seleniu send_key()不工作,python,python-3.x,selenium,automation,Python,Python 3.x,Selenium,Automation,我是自动化新手。我试图在Omegle的文本框中输入一个sting并按enter键,但它显示了一个错误: selenium.common.exceptions.ElementNotInteractiableException:消息:键盘无法访问元素 是我想要访问文本框的网页链接 import time import random from selenium import webdriver from selenium.webdriver.common.keys import Keys from s

我是自动化新手。我试图在Omegle的文本框中输入一个sting并按enter键,但它显示了一个错误:

selenium.common.exceptions.ElementNotInteractiableException:消息:键盘无法访问元素

是我想要访问文本框的网页链接

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)
应:

button = driver.find_element_by_xpath('/html/body/div[3]/table/tbody/tr[2]/td[1]/div/div/div[1]/span[2]')
button.click()
button.send_keys('panda')
button.send_keys(u'\ue007')
应:

button = driver.find_element_by_xpath('/html/body/div[3]/table/tbody/tr[2]/td[1]/div/div/div[1]/span[2]')
button.click()
button.send_keys('panda')
button.send_keys(u'\ue007')

我试过了,效果不错。

从selenium导入webdriver
来自selenium.webdriver.common.keys
导入密钥
导入时间
browser=webdriver.Chrome()
browser.get(“https://www.omegle.com/")
text\u area=浏览器。通过类名称(“主题占位符”)查找元素
文本区域。单击()
输入=浏览器。通过类名称(“newtopicinput”)查找元素
输入。发送_键(“熊猫”)
输入。发送\u键(键。返回)

我希望已经解决了你的问题。我试过了,效果不错。

从selenium导入webdriver
来自selenium.webdriver.common.keys
导入密钥
导入时间
browser=webdriver.Chrome()
browser.get(“https://www.omegle.com/")
text\u area=浏览器。通过类名称(“主题占位符”)查找元素
文本区域。单击()
输入=浏览器。通过类名称(“newtopicinput”)查找元素
输入。发送_键(“熊猫”)
输入。发送\u键(键。返回)

我希望已经解决了您的问题。

如果您单击的是一个按钮,那么您不应该向它发送密钥,因为它不是文本输入点。重新评估网站,以获得更好的互动方式我如何才能找到输入点,在项目中,我再次遇到相同的问题,但在不同的文本字段,你能告诉我如何找到一个可交互点吗?如果你点击了一个按钮,你就不能向它发送一个键,因为它不是一个文本输入点。重新评估网站,以获得更好的互动方式我如何才能找到输入点,在项目中,我再次遇到相同的问题,但在不同的文本字段,您能告诉我如何找到可交互点吗?它抛出了一个错误selenium.common.exceptions.ElementNotInteractiableException:Message:Element无法通过键盘访问,感谢您帮助我抛出一个错误selenium.common.exceptions.ElementNotInteractiableException:Message:Element无法通过键盘访问,谢谢你帮助我