无法在 confluence 上使用 selenium 和 python 定位文本输入元素
我试图在汇合时单击文本区域并将一些文本发送到页面。我尝试了很多组合来查找网页上的文本输入元素,但均不成功。我使用的代码如下 -
button1 = driver.find_element_by_class_name('mce-content-body aui-theme-default mceContentBody wiki-content fullsize notranslate page-edit')
button1.click()
button1.send_keys(x)
driver.switch_to.frame("wysiwygTextarea_ifr")
它给出了一个错误 - 没有这样的元素:无法找到元素: {“方法”:“CSS选择器”,“选择器”:“.mce-content-body aui-主题-默认 mceContentBody wiki 内容 fullsize notranslate 页面编辑”}
添加了源代码的快照。
I am trying to click inside the text area on confluence and send some text to the page. I have tried a lot of combinations to find the text input element on the webpage but have been unsuccessful. The code I am using is as below -
button1 = driver.find_element_by_class_name('mce-content-body aui-theme-default mceContentBody wiki-content fullsize notranslate page-edit')
button1.click()
button1.send_keys(x)
driver.switch_to.frame("wysiwygTextarea_ifr")
It gives an error - no such element: Unable to locate element:
{"method":"css selector","selector":".mce-content-body
aui-theme-default mceContentBody wiki-content fullsize notranslate
page-edit"}
Please help me out have been trying various combinations but nothing worked.
added a snapshot for the sourcecode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过查看您的代码和 DOM 快照,我推断您正在寻找此 DOM 组件: DOM 快照
这种情况下,你写的代码正好相反。您首先需要访问
iframe
,然后您可以访问其中的元素(您的操作方式相反)重构您的代码以与 DOM 保持一致:
Going through your code and the DOM snapshot, I deduce that you are looking for this DOM component: DOM snapshot
In which case, the code you wrote is just opposite. You have first access the
iframe
and then you can access the elements inside of it (which you did the opposite way)Refactored your code to align with the DOM: