首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >python Selenium send_keys到Jupyter笔记本

python Selenium send_keys到Jupyter笔记本
EN

Stack Overflow用户
提问于 2018-08-15 02:24:01
回答 1查看 404关注 0票数 0

我正在尝试使用python中的selenium自动输入到Jupyter笔记本中。

我尝试将send_keys()方法与DOM中的各种元素一起使用,到目前为止,我尝试过的所有方法都有以下问题:

代码语言:javascript
复制
selenium.common.exceptions.ElementNotInteractableException: Message: Element <span> is not reachable by keyboard

到目前为止,我已经尝试过返回以下元素的定位器:

但是,这是隐藏的,因此不是interactable

  • ('tag name',‘’)下的
  • (‘tag name',’CodeMirror-
  • ‘)元素下的
  • (’tag name','CodeMirror-code')元素下的

(‘tag name','CodeMirror-code')元素

  • (’tag name‘,’

‘)下的

在DOM中看不到明显的input。有没有人尝试过自动化Jupyter笔记本?

当手动输入屏幕上的文本区域时,DOM似乎正在动态地更改下面的span元素……

下面是我正在使用的DOM的相关部分和文本区域的屏幕截图

代码语言:javascript
复制
<div class="cell code_cell rendered selected" tabindex="2">
   <div class="input">
      <div class="run_this_cell" title="Run this cell"><i class="fa-step-forward fa"></i></div>
      <div class="prompt input_prompt"><bdi>In</bdi>&nbsp;[&nbsp;]:</div>
      <div class="inner_cell">
         <div class="ctb_hideshow">
            <div class="celltoolbar"></div>
         </div>
         <div class="input_area">
            <div class="CodeMirror cm-s-ipython">
               <div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5.59375px; left: 5.59375px;"><textarea autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none;"></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: 0px; min-width: 8.59375px; margin-bottom: -15px; border-right-width: 15px; min-height: 28px; 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"></div>
                              <div class="CodeMirror-measure"></div>
                              <div style="position: relative; z-index: 1;"></div>
                              <div class="CodeMirror-cursors" style="visibility: hidden;">
                                 <div class="CodeMirror-cursor" style="left: 5.59375px; top: 0px; height: 17px;">&nbsp;</div>
                              </div>
                              <div class="CodeMirror-code" role="presentation">
                                 <pre class=" CodeMirror-line " role="presentation"><span role="presentation" style="padding-right: 0.1px;"><span cm-text="">​</span></span></pre>
                              </div>
                           </div>
                        </div>
                     </div>
                  </div>
                  <div style="position: absolute; height: 15px; width: 1px; border-bottom: 0px solid transparent; top: 28px;"></div>
                  <div class="CodeMirror-gutters" style="display: none; height: 43px;"></div>
               </div>
            </div>
         </div>
      </div>
   </div>
   <div class="output_wrapper">
      <div class="out_prompt_overlay prompt" title="click to expand output; double click to hide output"></div>
      <div class="output"></div>
      <div class="btn btn-default output_collapsed" title="click to expand output" style="display: none;">. . .</div>
   </div>
</div>

注意,我已经成功地通过javascript执行更改了DOM,使textarea可见,然后将键发送到它。(这是通过从继承它的父div元素的style属性中删除hidden;来实现的。然而,我正在寻找一个不需要修改DOM的解决方案。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51847645

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档