Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
填写评论表并使用python&;提交;硒_Python_Forms_Selenium - Fatal编程技术网

填写评论表并使用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()