我正在尝试将页面对象的对象创建为规范,我收到错误。
dashboard.pageObject.js
/*global exports,console*/
module.exports = function(){
this.dashboarurl = 'http://localhost:2525/ars-webapp/';
this.createNewReport_Clickhear = element(By.xpath("//a[contains(.,'Click Here')]"));
this.reportInputModel = element(by.model('reportDefCntrl.reportDef.reportname'));
this.reportDescriptionModel = element(by.model('reportDefCntrl.reportDef.reportdesc'));
this.templateListSelect = element(By.xpath("//select[@id='template-list-select']")).click();
this.selectAlarmDashboarTemplate= element(By.xpath("//option[contains(@value,'number:2')]"));
this.durationOfAlarmTemplate = element(By.xpath("//span[@class='ui-select-placeholder text-muted ng-binding']"));
this.duration_Daily = element(By.xpath("//span[contains(.,'Daily')]"));
this.addObject = element(By.xpath("//button[@data-ng-click='reportDefCntrl.addLogObjects()']"));
this.searchInput = element(By.xpath("//input[@type='search']"));
this.searchButton = element(By.xpath("//button[contains(.,'Search')]"));
this.selectAllButton = element(By.xpath("//button[contains(.,'SelectAll')]"));
this.addObjectButton = element(By.xpath("//button[@data-ng-click='addLogObjectsCntrl.submitObjects()']"));
this.saveButton = element(By.xpath("//button[contains(.,'Save')]"));
}
Specfile
/ 全局要求,控制台 /
var Dashboard = require('../pageObjects/dashboard.pageObject.js');
var dashboard = new Dashboard();
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get(dashboard.dashboarurl);
}
如果我跳过该行
var dashboard = new Dashboard();
并提供
browser.get('http://localhost:2525/ars-webapp/');
而不是
browser.get(dashboard.dashboarurl);
它正在工作。
但我不能使用页面对象的功能。
如果我使用
var dashboard = new Dashboard();
所以我收到错误
E / launcher - 等待量角器与页面同步时出错: " window.angular未定义。这可能是因为这是一个 非角度页面或因为您的测试涉及客户端导航, 这会干扰量角器的自举。看到 http://git.io/v4gXM了解详情"
答案 0 :(得分:0)
哦,伙计......发现它!!你的代码中的一切都很好。你知道吗......问题是......你的文件click()
中有一个this.templateListSelect = element(By.xpath("")).click()
- dashboard.pageObject.js
由于您首先require()
..首先执行仪表板文件,click()
即使在browser.get()
之前也会被触发,这就是您看到错误的原因