timeout after 5000 msec
I am really new at this. When i click the login button It logs in and then i wait for angular to finish. but its timing out for some reason. The code is:
var util = require('util');
describe('Login', function(){
var ptor;
beforeEach(function(){
ptor = protractor.getInstance();
ptor.get('#/login');
});
it('The user should be able to login', function(){
ptor = protractor.getInstance();
ptor.findElement(protractor.By.input('login')).sendKeys("****");
ptor.findElement(protractor.By.input('password')).sendKeys("****");
ptor.findElement(protractor.By.css("input.login-form-container-button")).click().then(function() {
ptor.waitForAngular();
expect(ptor.getCurrentUrl()).toBe(ptor.baseurl + '/#/missioncontrol');
},30000);
});
});
Error that i get:
Failures:
- Login The user should be able to login Message: timeout: timed out after 5000 msec waiting for spec to complete Stacktrace: undefined
Finished in 8.685 seconds 1 test, 1 assertion, 1 failure
Shutting down selenium standalone server
/Users/ranjanbhambroo/Documents/protractor_voloforce_tests/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1542 throw error; ^ ScriptTimeoutError: Timed out waiting for async script result after 99953ms
Looks like you have the timeout on a findElement instead of the it. Try this:
var util = require('util');
describe('Login', function() {
var ptor;
beforeEach(function() {
ptor = protractor.getInstance();
ptor.get('#/login');
});
it('allows user to log in', function() {
var expectedUrl = ptor.baseurl + '/#/missioncontrol';
ptor.findElement(protractor.By.input('login')).sendKeys('login');
ptor.findElement(protractor.By.input('password')).sendKeys('password');
ptor.findElement(protractor.By.css('input.login-form-container-button')).click()
ptor.getCurrentUrl().
then(function(url) {
expect(url).toBe(expectedUrl);
});
}, 30000);
});
You're also getting an instance of protractor during beforeEach so I don't believe you need to get it again during the test (it statement).
@stickel I tried your suggestion but its not resolving to the url intended.. Expected 'http://example.com/#/login' to be 'http://example.com/#/missioncontrol'.
If the url is not resolved i wont be able to find the elements on the intended 'http://example.com/#/missioncontrol'. after the successful login
Does your login page have angular.js loaded on it? If it doesn't, protractor may time out while trying to find angular. Try increasing the timeout on beforeEach and seeing if the error message changes:
beforeEach(function() {
ptor = protractor.getInstance();
ptor.get('#/login');
}, 30000);
Sounds like the test isn't timing out now there's just a failing test, correct? When the tests are running does the browser show text being entered in login/password fields? Does the app work correctly when you enter the same information in manually?
@juliemr angular.js is loaded on the login page. The timeout is not occurring anymore.
@stickel Yes when i enter all the details manually its working fine... When i run the test it opens the browser and performs the entering of the text in login/password fields. Also i see the url with baseUrl + '#/missioncontrol'. Its still resolving the currentUrl to be baseUrl + '#/login'. Thats why the test is failing.
If i try to waitForAngular(), it times out again...
@apankov1 It seems like its not working correctly
Made a separate bug to consolidate these issues - now duplicate of #92
Julie, you are my goddess.
Hi there, I ended here because I am confused about how the timing works. Are those milliseconds in the it parameters? The numbers don't add up here. Also why is it set in the it method? I cannot test intervals like this...
Property 'getInstance' does not exist on type 'Ptor'. any idea