python selenium 没有要发送键的元素
本人刚开始学习selenium,如有错误还请谅解。 谢谢:)
我想爬行一个网站,可以通过硒创建一个名为“tistory”的博客。
为了创建文章,您必须选择默认模式、markdown 模式或 html 模式之一。
基本模式是可以的。 在此处输入图像描述
iframe=driver.find_element_by_css_selector('iframe')
driver.switch_to.frame(iframe)
driver.find_element_by_id('tinymce').send_keys("test text")
但我想做的是html模式,所以我创建了一个代码,可以通过selenium以html模式自动写入。 在此处输入图像描述
text_box = driver.find_element_by_css_selector("#html-editor-container > div.mce-edit-area > div > div > div:nth-child(1) > textarea")
text_box.send_keys("test text")
another element textarea
text_box = driver.find_element_by_css_selector("div.ReactCodemirror>textarea")
text_box.send_keys("test text")
当我尝试运行它时出现错误。
selenium.common.exceptions.ElementNotInteractableException: Message: element (Session info: chrome=99.0.4844.74)
关于该错误,我认为 textarea 元素是用于写入文本的不正确元素,但我不知道什么是正确的元素。
这是html模式的html。 在此处输入图像描述
这个问题已经困扰我三天了。 请解决这个问题。我求求你。
I just started studying selenium, so please understand if there is any mistake.
Thankyou :)
I would like to crawling a site where can create a blog called 'tistory' through selenium.
In order to create an article, you must choose one of the default mode, markdown mode, or html mode.
Basic mode is possible.
enter image description here
iframe=driver.find_element_by_css_selector('iframe')
driver.switch_to.frame(iframe)
driver.find_element_by_id('tinymce').send_keys("test text")
But I want to do is html mode, so I created a code that can automatically write through selenium in html mode.
enter image description here
text_box = driver.find_element_by_css_selector("#html-editor-container > div.mce-edit-area > div > div > div:nth-child(1) > textarea")
text_box.send_keys("test text")
another element textarea
text_box = driver.find_element_by_css_selector("div.ReactCodemirror>textarea")
text_box.send_keys("test text")
An error appears when I try to run it.
selenium.common.exceptions.ElementNotInteractableException: Message: element (Session info: chrome=99.0.4844.74)
Regarding the error, I think the textarea element is an incorrect element for writing text, but I don't know what is the correct element.
this is html mode html.
enter image description here
This problem has been bothering me for three days.
Please solve this problem. I beg you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在HTML 模式中,您没有看到iframe?
或者
由于您在基本模式下切换到iframe,因此您是否切换到
默认内容
?要解决
您应该像下面这样调试代码:
确保浏览器使用全屏启动
Use
ActionChains
:使用
execute_script
:导入:
In HTML mode, you don't see an iframe?
or
Since in Basic mode you switched to an iframe, did you switch to
default content
?to solve
You should debug your code like below:
Make sure the browser is launched in full screen using
Use
ActionChains
:Use
execute_script
:Imports: