量角器失败:元素在vue2编辑器中不可交互

时间:2019-05-19 08:29:27

标签: vue.js protractor e2e-testing

我正在使用'量角器'测试我的Web应用程序。 我在项目中添加了“ vue2-editor” ,我想在编辑器中写一些东西并保存数据。 这是Vue生成的html:

<div id="quill-container" class="ql-container ql-snow">
    <div class="ql-editor ql-blank" data-gramm="false" contenteditable="true" data-placeholder="Add Note...">
        <p>
            <br>
        </p>
    </div>
    <div class="ql-clipboard" contenteditable="true" tabindex="-1"></div>
    <div class="ql-mention-list-container" style="display: none; position: absolute;">
        <ul class="ql-mention-list"></ul>
    </div>
</div>

这是我的测试代码:

describe('When you save a note', function () {
      beforeAll(function () {
          browser.get('http://example');
          element.all(by.css(" [id='quill-container'] > div.ql-editor.ql-blank")).click();
          element.all(by.css(" [id='quill-container'] > div.ql-editor.ql-blank")).sendKeys('Some Notes add here');
          element(by.css("[id='add-note-btn']")).click();
          browser.sleep(1000);
      });
      it('You must see your note at the current page', function () {
         expect(element(by.xpath('//p[text()="Some Notes add here"]')).isPresent()).toBe(true);
       });
});

执行代码时,量角器会显示以下消息:

  

失败:元素不可交互

我该怎么办?

1 个答案:

答案 0 :(得分:0)

基本上,有四个原因导致元素不可交互。

1)计时-元素加载所需的时间。为此,您需要检查如何使用隐式显式等待

2)检查元素是否在框架中

3)定位器不正确

4)错误的响应方式实施。这仍然源于3)。某些网站仅针对移动版和网络版启用了一个代码。因此,当您检查xxxxx.size时,该元素将具有多个实例。您将需要在列表中搜索显示为!= none的那一个。

相关问题