【发布时间】:2022-01-21 22:25:14
【问题描述】:
我需要一些帮助, 我尝试填写一个文本框 但是当我检查元素然后复制 xpath 它只给我
/body/html
然后,我尝试使用类名,但它不起作用
我该如何解决这个问题?
这是我的代码:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('link_to_the_website')
driver.find_element_by_xpath('/body/html').send_keys('hello world')
textboxes = driver.find_element_by_xpath('/html/body')
这是我检查文本框时的 html 代码
<body marginwidth="0" marginheight="0" class="textarea from-control wysihtml5-editor placeholder" spellcheck="true" style="background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); cursor: text; font-family: "Open Sans", sans-serif; font-size: 11px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 16.5px; letter-spacing: normal; text-align: start; text-decoration: none solid rgb(0, 0, 0); text-indent: 0px; text-rendering: auto; word-break: normal; overflow-wrap: break-word; word-spacing: 0px;" contenteditable="true">type here......</body>
【问题讨论】:
-
您没有共享指向网页的链接,或者至少没有共享 HTML。你认为我们如何知道元素定位器?
-
好的,看看我的回答是否解决了你的问题
-
在该链接中,我们将看到几个文本框 - 您想将密钥发送到哪个文本区域?
-
页面中几乎所有的文本区域都在 iframe 内。但在不知道您想要的文本区域的情况下,只能猜测。
-
是的,然后我想在文本区域中填写或书写。有几个文本框。我要一个一个地填写。
标签: python selenium google-chrome