【发布时间】:2017-02-24 13:10:15
【问题描述】:
我正在尝试将页面对象的对象创建到规范中,但出现错误。
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')]"));
}
规范文件是
/全局要求,控制台/
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 - 等待 Protractor 与页面同步时出错: “window.angular 未定义。这可能是因为这是一个 非角度页面或因为您的测试涉及客户端导航, 这可能会干扰量角器的引导。看 http://git.io/v4gXM了解详情"
【问题讨论】:
-
您要测试的页面是 Angular 的吗?如果不是你不能使用'browser.get()'
-
是的,这个页面是有角度的页面。但是为什么我不能初始化对象 new Dashboard();
标签: angularjs jasmine protractor