[英]selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable while inserting value using Selenium and Python
I'm trying to insert a value into a text box located in a web page. 我正在尝试将值插入位于网页中的文本框中。
Text box appears at the bottom of the web page and the element is not locatable by the code. 文本框出现在网页的底部,并且该代码找不到该元素。 I should
Inspect two times to see the table value in Chrome (first time it shows a different/parent HTML all together) that suggests us that there are multiple layers and requires finding in deep.
我应该进行两次检查 ,以查看Chrome中的表格值(首次显示所有HTML /父HTML),这表明我们存在多个层次,需要深入研究。
I've tried inserting the string as shown below.. 我尝试插入如下所示的字符串。
driver.find_element_by_id("arid1005").send_keys("TESTING")
and 和
elem = driver.find_element_by_id("arid1005")
driver.execute_script('arguments[0].value = "TESTING";',elem)
I've also tried finding the elements by Class Name, CSS, Xpath but end up getting
我也尝试过通过类名,CSS,Xpath查找元素
,但最终得到
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
When I inspect 2 times, the below table gets highlighted. 当我检查2次时,下表将突出显示。
<table class="SearchBarInput" width="100%">
<tbody>
<tr><td width="">
<textarea style="width:99%;height:21px;" class="sr" cols="" wrap="off" rows="1" id="arid1005"></textarea></td>
</tr>
</tbody>
</table>
Can somebody throw some light on what I'm missing here? 有人可以告诉我我在这里想念的东西吗? Sorry if this question was already asked but I couldn't find any relevant so far.
抱歉,是否已经有人问过这个问题,但到目前为止我找不到任何相关问题。
The id attribute of the desired element looks dynamic, so to click()
on the element you have to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following solutions: 所需元素的id属性看起来很动态,因此要对元素进行
click()
就必须为element_to_be_clickable()
诱导WebDriverWait ,并且可以使用以下任一解决方案:
Using CSS_SELECTOR
: 使用
CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "table.SearchBarInput>tbody>tr>td>textarea"))).send_keys("TESTING")
Using XPATH
: 使用
XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//table[@class='SearchBarInput']/tbody/tr/td/textarea"))).send_keys("TESTING")
Note : You have to add the following imports : 注意 :您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
References: You can find a couple of relevant discussions in: 参考资料:您可以在以下位置找到一些相关的讨论:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.