Selenium 求问 java+selenium 在 web 页面 codemirror 编辑器输入

roc · 2019年03月20日 · 1519 次阅读

之前在页面富文本编辑器可以通过切换输入
但是今天遇到一个 是用 codemirror 编辑器的页面
定位可是实现,但是不能直接往里输入字符。在百度上看了一圈有点头绪,但是还是无从下手。

这是这个 codemirror 的 H5 代码块

<div class="CodeMirror cm-s-default CodeMirror-wrap" xpath="1" style="">
    <div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 4px; left: 30px;">
        <textarea autocorrect="off" autocapitalize="off" spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"
        tabindex="0">
        </textarea>
    </div>
    <div class="CodeMirror-vscrollbar" cm-not-content="true">
        <div style="min-width: 1px; height: 0px;">
        </div>
    </div>
    <div class="CodeMirror-hscrollbar" cm-not-content="true">
        <div style="height: 100%; min-height: 1px; width: 0px;">
        </div>
    </div>
    <div class="CodeMirror-scrollbar-filler" cm-not-content="true">
    </div>
    <div class="CodeMirror-gutter-filler" cm-not-content="true">
    </div>
    <div class="CodeMirror-scroll" tabindex="-1">
        <div class="CodeMirror-sizer" style="margin-left: 30px; margin-bottom: -6px; border-right-width: 24px; min-height: 31px; padding-right: 0px; padding-bottom: 0px;">
            <div style="position: relative; top: 0px;">
                <div class="CodeMirror-lines" role="presentation">
                    <div role="presentation" style="position: relative; outline: none;">
                        <div class="CodeMirror-measure">
                            <pre>
                                <span>
                                    xxxxxxxxxx
                                </span>
                            </pre>
                            <div class="CodeMirror-linenumber CodeMirror-gutter-elt">
                                <div>
                                    1
                                </div>
                            </div>
                        </div>
                        <div class="CodeMirror-measure">
                        </div>
                        <div style="position: relative; z-index: 1;">
                        </div>
                        <div class="CodeMirror-cursors" style="">
                            <div class="CodeMirror-cursor" style="left: 0px; top: 0px; height: 23px;">
                                &nbsp;
                            </div>
                        </div>
                        <div class="CodeMirror-code" role="presentation">
                            <div class="CodeMirror-activeline" style="position: relative;">
                                <div class="CodeMirror-activeline-background CodeMirror-linebackground">
                                </div>
                                <div class="CodeMirror-gutter-background CodeMirror-activeline-gutter"
                                style="left: -30px; width: 30px;">
                                </div>
                                <div class="CodeMirror-gutter-wrapper CodeMirror-activeline-gutter" style="left: -30px;">
                                    <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">
                                        1
                                    </div>
                                </div>


                                // 这里就是输入框输入行定位的代码
                                <pre class=" CodeMirror-line " role="presentation">
                                    <span role="presentation" style="padding-right: 0.1px;">
                                        <span cm-text="">
                                            ​

                                ...................................
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册