Timed out waiting for asynchronous script result while executing protractor scripts with appium

1. Regarding with route check

In case after first spec, user got logged in and the route changed. Make sure all are navigated before any test executed.

expect(browser.getCurrentUrl()).toContain('#/the_route_of_logged_in'); 
// '#/' is just illustration. You can remove it to make it shorter
// => like this ...toContain('the_route_of_logged_in');

2. Regarding with click on tutorial

browser.wait(EC.elementToBeClickable(tutorial), 10000);

Do the browser.wait with EC for click-able button before attempt to click it (it seem like you got good approach here)

=> SUMMING UP you can give this a try:

'user strict';

var EC = protractor.ExpectedConditions;

describe('tutorials', function () {

    it('should make click into tutorial button', function () {

        expect(browser.getCurrentUrl()).toContain('the_route_of_logged_in');

        var tutorial = $('.introjs-nextbutton'); 
        browser.wait(EC.elementToBeClickable(tutorial), 8000, 'Timed out');
        tutorial.click();

        browser.sleep(8080); // regardless we are not reaching this point. But I will suggest to reduce this sleep time like 1000 (1s).
    });
});

3. (optional) in case 2 points above does not help

In your all of your spec login-spec.js and tutorial-spec.js. Add process.nextTick(done); in a afterAll() block to ensure if there are no any Jasmine Reporters being stuck after a spec.

describe('foo', function(){

  afterAll(function(done){
    process.nextTick(done);
  });  

  it('should bar...', function() {});
}

P.S. Beware that I am totally have no clue if my suggestions/approach could help. As debugging with e2e-test always painful… because we are always likely not knowing “where are the errors come from”. So all I can do is giving you suggestions.
(sometimes it took me hours to just observe the behaviors of browser to identify an issue of e2e-test)

And DO NOT COPY PASTE my code into your code. I typed it with the images you provide, I can make some typos there.

Leave a Comment