我正在使用量角器和茉莉花進行自動化測試。 我做了一個測試註冊頁面上,用下面的代碼:量角器測試錯誤超時
it('Verify Alert message when New user registered itself for the first time',function() {
FuncLib.ButtonClick('Close'); //Close the error message displayed in previous scenario
Registration.Email.clear(); //Clear valid E-mail Id
Registration.Password.clear(); //Clear Password
Registration.ConfirmPassword.clear(); //Clear Confirm Password
Registration.Firstname.clear(); //clear Firstname Password
Registration.Lastname.clear(); //clear Lastname Password
Registration.Phonenumber.clear(); //clear phonenumber
browser.sleep(500);
Registration.Email.sendKeys('[email protected]'); //Enter valid E-mail Id
Registration.Password.sendKeys('Hello1'); //Enter Password
Registration.ConfirmPassword.sendKeys('Hello1'); //Enter wrong Confirm Password
Registration.Firstname.sendKeys('candy'); //Enter Firstname Password
Registration.Lastname.sendKeys('smith'); //Enter Lastname Password
Registration.Phonenumber.sendKeys('9191919106'); //Enter phone number.
expect(Registration.Checkbox.isPresent()).toBe(true); // Terms and condition checkbox should display
Registration.Checkbox.click(); // select the Terms and condition checkbox
Registration.Checkbox.click(); // select the Terms and condition checkbox
browser.sleep(200);
expect(Registration.RegisterButton.isPresent()).toBe(true);
Registration.RegisterButton.click(); //click Register button
browser.sleep(200);
browser.driver.wait(function() { // Wait for the current URL to change to Home page
return browser.driver.getCurrentUrl().then(function(url) {
return (/home/).test(url);
});
});
expect(browser.getCurrentUrl()).toEqual(Registration.HomeURL);
console.log('When New user registered itself for the first time:');
expect(Registration.AlertMsg.getText()).toEqual(Registration.msg6);
Registration.AlertMsg.getText().then(function(text) {
console.log(' When New user registered itself for the first time:'); //Jasmine expect statement : compare actual and expected value
});
});
一切工作正常,直到這部分代碼:
expect(Registration.RegisterButton.isPresent()).toBe(true);
Registration.RegisterButton.click(); //click Register button
browser.sleep(200);
browser.driver.wait(function() { // Wait for the current URL to change to Home page
return browser.driver.getCurrentUrl().then(function(url) {
return (/home/).test(url);
});
});
expect(browser.getCurrentUrl()).toEqual(Registration.HomeURL);
console.log('When New user registered itself for the first time:');
expect(Registration.AlertMsg.getText()).toEqual(Registration.msg6);
Registration.AlertMsg.getText().then(function(text) {
console.log(' When New user registered itself for the first time:'); //Jasmine expect statement : compare actual and expected value
});
在這裏我得到的報告這個錯誤結束: 錯誤:超時 - 異步回調不被jasmine.DEFAULT_TIMEOUT_INTERVAL
指定的超時時間內調用,我真的不明白爲什麼。
在你的config.js文件中增加'defaultTimeoutInterval:60000' –