Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

timeout after 5000 msec #88

Closed
ranjanbhambroo opened this issue Sep 12, 2013 · 12 comments
Closed

timeout after 5000 msec #88

ranjanbhambroo opened this issue Sep 12, 2013 · 12 comments

Comments

@ranjanbhambroo
Copy link

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

@stickel
Copy link

stickel commented Sep 12, 2013

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

@ranjanbhambroo
Copy link
Author

@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

@juliemr
Copy link
Member

juliemr commented Sep 12, 2013

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

@stickel
Copy link

stickel commented Sep 12, 2013

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?

@ranjanbhambroo
Copy link
Author

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

@ranjanbhambroo
Copy link
Author

@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
Copy link
Author

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

@ranjanbhambroo
Copy link
Author

@apankov1 It seems like its not working correctly

@juliemr
Copy link
Member

juliemr commented Sep 13, 2013

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

@ChipCamden
Copy link

Julie, you are my goddess.

@AlexCppns
Copy link

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

@mahmoud-nb
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants