selenium4+python send_keys() 出现错误Message: element not interactable
本帖最后由 jxnkdwf 于 2022-3-4 14:04 编辑selenium4+python send_keys() 出现错误Message: element not interactable
[*]python
[*]selenium
[*]
自动化测试发帖在https://bbs.csdn.net/forums/python_learners
注意是Markdown格式的页面下
部分代码:
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
print(driver.title)driver.get('https://bbs.csdn.net/forums/python_learners')
time.sleep(10)
element=driver.find_element(By.CLASS_NAME,'pub-img') #点击发帖
element.click()
time.sleep(2)element=driver.find_element(By.ID,'txtTitle')
element.clear()
element.send_keys("标题")
time.sleep(2)element=driver.find_element(By.CLASS_NAME,'md_textarea')
element.click()
time.sleep(2)
element.send_keys("内容")#这步出现element not interactable问题
time.sleep(2)
何解?
自己顶一下 md_textarea 我进去了没找到这个标签,要不你截个图看看 <div data-v-35560b3a="" data-v-7ba5bd90="" class="md_textarea" textlength="0">
<textarea data-v-35560b3a="" spellcheck="false" id="textarea_1647014337235" placeholder="请编写您的帖子内容" maxlength="" rows="auto" class="" style="height: 289px; overflow: auto; cursor: text;">
</textarea>
……
</div>
class="md_textarea"的下级子节点才是内容输入框,试下:
element = driver.find_element(By.CSS_SELECTOR, '.md_textarea textarea')
element = driver.find_element(By.CSS_SELECTOR, '#textarea_1647014337235')
页:
[1]