2017-02-24 47 views
1

我想創建一個頁面對象對象到規範中,我得到錯誤。量角器:錯誤:等待量角器與頁面同步時出錯:「window.angular is undefined。如果我創建PageObject的新對象

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 - Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"

+0

是您試圖測試角度的頁面嗎?如果沒有,你不能使用'browser.get()' – AdityaReddy

+0

是的這個頁面是角頁面。但爲什麼我不能初始化對象新的儀表板(); –

回答

0

哦..人發現它!!一切都在你的代碼罰款。你知道..的問題..你在你的文件有什麼在這一行this.templateListSelect = element(By.xpath("")).click()一個click() - dashboard.pageObject.js

既然你有一個require()第一..執行儀表板文件第一和click()甚至browser.get()並且那之前trigerred您看到該錯誤的原因

相關問題