无法在Selenium中键入任何文本

时间:2018-04-16 21:24:18

标签: java selenium selenium-webdriver

我有这个DOM:

<?xml version="1.0" encoding="UTF-8"?>
<div class="CodeMirror-scroll" tabindex="-1" draggable="true">
   <div class="CodeMirror-sizer" style="margin-left: 53px; margin-bottom: -16px; border-right-width: 14px; min-height: 26px; min-width: 7px; padding-right: 0px; padding-bottom: 0px;">
      <div style="position: relative; top: 0px;">
         <div class="CodeMirror-lines" role="presentation">
            <div style="position: relative; outline: medium none currentcolor;" role="presentation">
               <div class="CodeMirror-measure" />
               <div class="CodeMirror-measure" />
               <div style="position: relative; z-index: 1;" />
               <div class="CodeMirror-cursors" style="" />
               <div class="CodeMirror-code" role="presentation" autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" contenteditable="true">
                  <div style="position: relative;">
                     <div class="CodeMirror-gutter-wrapper" style="left: -53px;" contenteditable="false">
                        <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">1</div>
                     </div>
                     <pre class=" CodeMirror-line " role="presentation" style="">
                        <span role="presentation">
                           <span cm-text="">​</span>
                        </span>
                     </pre>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
   <div style="position: absolute; height: 14px; width: 1px; border-bottom: 0px solid transparent; top: 26px;" />
   <div class="CodeMirror-gutters" style="height: 40px;">
      <div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 53px;" />
   </div>
</div>

(这是github的主要代码区域)。我试图模仿人类对任何文本的打字,最后,创造要点。但这是span,此元素的sendKeys不起作用。 所有尝试在span中设置文本都不会影响Create gist按钮 - 这种行为在此span上回调的原因之一。 我需要帮助来模仿人类打字来解锁Create gist button

1 个答案:

答案 0 :(得分:1)

如果您希望Selenium告诉您特定操作所需的命令(在这种情况下,键入字段),您可以使用Katalon Recorder记录Selenese中的操作。然后可以导出到Java(或C#,或PHP,或......)