【发布时间】:2014-11-30 10:45:38
【问题描述】:
您好,我在进行基本量角器测试时遇到了一些问题。
我的设置:
- 我使用 requirejs,所以我使用 angular.bootstrap() 初始化 angular,而不是 ng-app attr。根据量角器文档,这不支持开箱即用,但对于不涉及点击的测试似乎可以正常工作。
-
量角器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 认为它已经完成,但是第三方插件填充和移动东西。
有什么想法吗? 如果第三方插件是问题所在,我可以以某种方式告诉 angular 第三方的事情正在发生,然后在完成后告诉它吗?
谢谢 溴 转折
【问题讨论】:
-
如果chrome窗口太小会出现这种情况,尝试在beforeEach里面添加browser.driver.manage().window().setSize(1280, 1024);
-
感谢起源,工作!添加为答案,我会标记它。
-
另外,请查看this answer 了解您可以尝试的内容。
标签: angularjs protractor selenium-chromedriver