本文介绍了量角器 + chrome 驱动程序:元素在该点不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在进行基本量角器测试时遇到了一些麻烦.

Hi I am having some trouble getting a basic protractor test to work.

我的设置:

  • 我使用 requirejs,所以我使用 angular.bootstrap() 初始化 angular,而不是 ng-app attr.根据量角器文档,这不是开箱即用的,但似乎适用于不涉及点击的测试.
  • 量角器 conf.json:

  • I use requirejs so I init angular using angular.bootstrap(), not the ng-app attr. According to protractor docs this is not supported out of the box, but seems to work fine for tests that don' involve clicking.
  • Protractor conf.json:

"use strict";
exports.config = {
    specs: '../E2ETests/**/*.js',
    chromeOnly: true,
    getPageTimeout: 30000,
    allScriptsTimeout: 30000
}

  • 我使用了一些包含在指令中的第三方 jquery 插件,我怀疑这些可能是问题的一部分.
  • 测试:

    "use strict";
    describe('When clicking should add stuff', function () {
        var ptor;
        beforeEach(function () {
            browser.get('https://localhost/myApp');
            ptor = protractor.getInstance();
        });
        it('add stuff', function () {
            // If I comment this, the test pass. 
            element(by.id('add-stuff-button')).click();
            // This does not matter fails on the line above..
            expect(browser.getTitle()).toBeDefined();
        });
    });
    

    错误:

    UnknownError: unknown error: Element is not clickable at point (720, 881). Other element would         receive the click: <div class="col-md-5 col-md-offset-5">...</div>
    (Session info: chrome=37.0.2062.124)
    (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 SP1 x86_64)
    

    想法

    chromedriver 确实找到了按钮,因为如果我更改 id,它会抱怨找不到元素.所以我认为问题在于按钮从其初始位置移动.由于 element(***) 函数应该等待 angular 完成,我怀疑它的第三方插件可能会干扰,因为它们可能不使用 angular api 的获取数据等.所以 angular 认为它完成了,然后第三方插件填充和移动东西.

    The chromedriver do find the button, because if I change the id it complains that no element is found. So I think the problem is that the button moves from its initial position. As the element(***) function should wait for angular to be done, I suspect that its the third party plugins that might interfere as they might not use angular api's fetching data etc. So angular think its done but then the third party plug populates and moves stuff around.

    有什么想法可以做什么吗?如果第三方插头有问题,我能否以某种方式告诉 angular 第三方的东西正在发生,然后在完成后告诉它?

    Any ideas what to do? If the third party plugs is the problem, can I somehow tell angular that third party stuff is going on and then later tell it when its done?

    谢谢溴时间

    推荐答案

    您应该在配置文件中设置窗口大小

    You should set window size in your config file

    onPrepare: function() {
      browser.manage().window().setSize(1600, 1000);
    }
    

    这篇关于量角器 + chrome 驱动程序:元素在该点不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-24 04:36