我有一个网页,我试图发表评论,但我似乎无法让文本显示在评论框。以下是网站的代码:
<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>
到目前为止,我得到的是:
^{pr2}$然而,当我试着给它发钥匙的时候,它有点反常,什么也进不去。你有没有想过如何将文字输入评论框?在
我认为可能会发生的情况是您在单击
form
元素,但您没有单击实际的注释框。如果不想输入上层的form
元素,则需要键入textarea
。在可以按id选择元素,然后在其中键入:
elem = driver.find_element_by_id("commentBox")
elem.send_keys("This is a comment I'd like to write!")
The Selenium Getting Started Guide
相关问题 更多 >
编程相关推荐