[英]how to 'send_keys' to a textarea in python Selenium
Hey, im trying to 'send_keys' to a textarea in Instagram with Python Selenium , and im getting error:嘿,我正在尝试使用Python Selenium 将“send_keys”发送到 Instagram 中的文本区域,但我遇到了错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//textarea[contains(@placeholder,'Message...')]"}
This is the element inspect:这是元素检查:
<textarea placeholder="Message..." class="" style="height: 18px;"></textarea>
and here is the code i wrote:这是我写的代码:
def message(self, user, message):
self.nav_user(user)
self.driver.find_elements_by_xpath("//button[contains(text(), 'Message')]")[0].click()
**# FROM HERE IM IN THE MESSENGER OF INSTAGRAM, TRYING TO 'send_keys'**
self.driver.find_element_by_xpath("//textarea[contains(@placeholder,'Message...')]").click()
self.driver.find_element_by_xpath("//textarea[contains(@placeholder,'Message...')]").send_keys(message)
self.driver.find_elements_by_xpath("//button[contains(text(), 'Send')]")[0].click()
So actually adding time.sleep has worked for me.所以实际上添加 time.sleep 对我有用。 Thank You
谢谢你
self.nav_user(user)
self.driver.find_elements_by_xpath("//button[contains(text(), 'Message')]")[0].click()
time.sleep(1)
# if There is a Pop-Up windows to turn on notification we will use this line:
self.driver.find_element_by_xpath("//button[contains(text(),'Not Now')]").click()
self.driver.find_element_by_xpath("//textarea[contains(@placeholder,'Message...')]").click()
time.sleep(1)
self.driver.find_element_by_xpath("//textarea[contains(@placeholder,'Message...')]").send_keys(message)
self.driver.find_elements_by_xpath("//button[contains(text(), 'Send')]")[0].click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.