protractor icon indicating copy to clipboard operation
protractor copied to clipboard

timeout after 5000 msec

Open ranjanbhambroo opened this issue 13 years ago • 12 comments

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:

  1. 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

ranjanbhambroo avatar Sep 12 '13 20:09 ranjanbhambroo

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 avatar Sep 12 '13 20:09 stickel

@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

ranjanbhambroo avatar Sep 12 '13 21:09 ranjanbhambroo

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);

juliemr avatar Sep 12 '13 21:09 juliemr

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?

stickel avatar Sep 12 '13 21:09 stickel

@juliemr angular.js is loaded on the login page. The timeout is not occurring anymore.

ranjanbhambroo avatar Sep 12 '13 21:09 ranjanbhambroo

@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.

ranjanbhambroo avatar Sep 12 '13 21:09 ranjanbhambroo

If i try to waitForAngular(), it times out again...

ranjanbhambroo avatar Sep 13 '13 14:09 ranjanbhambroo

@apankov1 It seems like its not working correctly

ranjanbhambroo avatar Sep 13 '13 15:09 ranjanbhambroo

Made a separate bug to consolidate these issues - now duplicate of #92

juliemr avatar Sep 13 '13 18:09 juliemr

Julie, you are my goddess.

ChipCamden avatar Mar 09 '14 06:03 ChipCamden

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...

AlexCppns avatar Apr 17 '14 15:04 AlexCppns

Property 'getInstance' does not exist on type 'Ptor'. any idea

mahmoud-nb avatar May 12 '17 10:05 mahmoud-nb