我試圖實現量角器測試在我的MVC項目,我們正在慢慢地轉變爲角量角器,登錄到asp,net MVC登錄頁面,然後等待默認頁面,重定向到角度頁面並做測試....怎麼樣?
我一個MVC登錄頁面上登錄,輸入用戶名和密碼,點擊登錄,然後我需要等待登錄瀏覽多個頁面,並進入默認屏幕。
然後我需要重定向到我的一個Angular頁面並運行一個簡單的測試(button = enabled)。
我認爲這是我需要做的,如果我正確的話,我在等待幾個重定向到最終默認頁面時失敗。在整個登錄過程完成之前,我正在重定向到我的頁面。
以下是我有:
// spec.js
//ptor = protractor.getInstance();
describe('ScoutAngular Protractor Tests', function() {
beforeEach(function() {
browser.ignoreSynchronization = true;
browser.get('http://localhost/Scout3G/Account/LogOn');
browser.driver.findElement(by.id('UserName')).sendKeys('oster.robert');
browser.driver.findElement(by.id('Password')).sendKeys('H0gw1ld!');
});
it('should login and goto the angular page', function() {
var submit = browser.driver.findElement(protractor.By.tagName('input'));
browser.ignoreSynchronization = false;
submit.click().then
(
function()
{
console.log("===================== 1");
//<<<<<--------I think i need to wait for login to finish several page redirects here
browser.get('http://localhost/Scout3G/Maintenance/TestAngularEWB')
.then(function() {
browser.driver.sleep(1);
browser.waitForAngular();
console.log("===================== about to expect");
element(by.Css("button").isEnabled());
}
);
}
);
console.log("===================== 4");
});
});
當我到了我的TestAngularEWB頁我得到錯誤的用戶沒有登錄...
我怎樣才能讓等待默認頁面,然後重定向到TestAngulareEWB?
我是否在做任何其他的總noob量角器錯誤?
browser.wait是怎麼清盤得到它上班。兩個答案似乎都是有效的。 –