python - 如何在这个 html 中使用 Selenium/Python 编写一些文本
问题描述
我正在尝试在以下字段中插入一些文本,但它说它不可交互
<div class="col-md-6">
<div id="tagsReview" class="p4-autocomplete" style="width: 179px; border-radius: 4px;">
<ul class="p4-autocomplete-labels"></ul><input type="text"><ul class="p4-autocomplete-suggestions" style="width: 179px; display: none;">
<li class="newItem selected"><a>Criar novo marcador</a></li>
</div>
我尝试了不同的方法,但都没有奏效。
有任何想法吗?谢!
编辑:
此代码可在文本字段中单击:
driver.find_element_by_id('tagsReview').click()
向该 ID 发送密钥不起作用:
driver.find_element_by_id('tagsReview').send_keys('xyz')
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=83.0.4103.61)
其他尝试:
driver.find_element_by_xpath("(//*[contains(@class,'p4-autocomplete')])").send_keys('xyz')
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=83.0.4103.61)
driver.find_element_by_class_name('p4-autocomplete-labels').click()
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=83.0.4103.61)
driver.find_element_by_class_name('p4-autocomplete').click()
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div id="tagsSearch" class="p4-autocomplete" style="float: right; margin-top: -5px; width: 179px;">...</div> is not clickable at point (1254, 224). Other element would receive the click: <div id="dlgCreateNextReview" class="modal in" tabindex="-1" style="display: block;">...</div>
(Session info: chrome=83.0.4103.61)
解决方案
我刚刚用 driver.find_element_by_xpath("//*[@id='tagsReview']/input") 解决了
推荐阅读
- java - 如何在一个循环中遍历两个字符串数组
- reactjs - 将路由中的组件加载到布局中?
- deep-learning - 为什么我的张量流生成器功能这么慢?
- php - 对于使用 Refresh HTTP 标头提供的文档,为什么 w3 验证器会获得空源代码?
- python - 从任何地方运行 Python 脚本
- angular - 我如何在 Angular 8 的 AuthInterceptor 类中获取/使用 accessToken
- ms-wopi - 自定义 WOPI 实施
- java - 在 Linux Mint 19.1 中安装 Oracle Java 8
- r - 如何在没有for循环的情况下迭代列并基于另一列分配值?
- c++ - 错误:预期的表达式和表达式结果未使用