填写评论表并使用python&;提交;硒
我有一个网页,我正试图发表评论,但我似乎无法让文本显示在评论框中。以下是网站的代码:填写评论表并使用python&;提交;硒,python,forms,selenium,Python,Forms,Selenium,我有一个网页,我正试图发表评论,但我似乎无法让文本显示在评论框中。以下是网站的代码: <form id="commentForm" class="comment_form" accept-charset="UTF-8"> <p class="post-error" style="display: none;">There was a problem posting your comment, please try again.</p> <
<form id="commentForm" class="comment_form" accept-charset="UTF-8">
<p class="post-error" style="display: none;">There was a problem posting your comment, please try again.</p>
<textarea placeholder="Leave a comment..." name="comment" id="commentBox" class="commentBox" onkeyup="limitTextReverse(jQuery('.commentBox'),jQuery('.myCount'), 140);" onkeydown="limitTextReverse(jQuery('.commentBox'),jQuery('.myCount'), 140);"></textarea>
<span class="button grey btn-submit" class="track-click" data-track="checkin_page" data-href=":comment/post" href="#">Post<input type="submit" value="Post" /></span>
<span class="comment-loading" style="display: none;"></span>
<span class="counter"><abbr class="myCount">0</abbr>/140</span>
<input type="hidden" name="checkin" value="123456789" />
</form>
然而,当我试着给它发钥匙时,它有点反常,什么也没进去。关于如何将文本输入评论框,您有什么想法吗?我认为可能发生的情况是您正在单击
表单
元素,但您没有单击实际的评论框。您不想在上层表单
元素中键入内容,而是想在文本区域
中键入内容
您可以按id选择元素,然后在其中键入:
elem=驱动程序。通过id(“commentBox”)查找元素
elem.send_keys(“这是我想写的评论!”)
box = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "comment_form")))
box.click()