5

I have a problem while running more than one test in protractor : Timed out waiting for asynchronous script result after 60010 s The code of tutorial script which is executed just after the login script : Here the code of login script + Tutorial script

Here the code i'm using in my config file from A Code proposed in another question but it didn't solve my problem !

onPrepare: function() {
  return browser.getProcessedConfig().then(function(config) {
    var browserName = config.capabilities.browserName;
    browser.manage().timeouts().setScriptTimeout(60000);

  });

Here the config file

PS : Even if i put an incorrect location for the element i have the error of time out and not this element cannot be found ! as if that line of code "the click into tutorial button" is never executed

  • Is it because tutorial make an ajax call ?

Error Here my html code :

</div></md-card-content> </md-card><!-- end ngIf: !expandChart --> </div> </div> </div></md-content> </div></div> <!-- Google Analytics: change UA-XXXXX-X to be your site's ID --> <!--<script>--> <!--!function(A,n,g,u,l,a,r){A.GoogleAnalyticsObject=l,A[l]=A[l]||function(){--> <!--(A[l].q=A[l].q||[]).push(arguments)},A[l].l=+new Date,a=n.createElement(g),--> <!--r=n.getElementsByTagName(g)[0],a.src=u,r.parentNode.insertBefore(a,r)--> <!--}(window,document,'script','https://www.google-analytics.com/analytics.js','ga');--> <!--ga('create', 'UA-XXXXX-X');--> <!--ga('send', 'pageview');--> <!--</script>--> <script src="scripts/vendor.js"></script> <script src="cordova.js"></script> <script src="scripts/scripts.js"></script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"></script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script> <div class="introjs-overlay" style="top: 0;bottom: 0; left: 0;right: 0;position: fixed;opacity: 0.8;"></div><div class="introjs-helperLayer " style="width: 538px; height:366px; top:64px;left: 195px;"></div><div class="introjs-tooltipReferenceLayer" style="width: 538px; height:366px; top:64px;left: 195px;"><div class="introjs-tooltip" style="left: 546px;"><div class="introjs-tooltiptext">Watchlist view. Swipe the row in the grid to the left to show the delete action.</div><div class="introjs-bullets"><ul><li><a class="active" href="javascript:void(0);" data-stepnumber="1">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="2">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="3">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="4">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="5">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="6">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="7">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="8">&nbsp;</a></li></ul></div><div class="introjs-progress" style="display: none;"><div class="introjs-progressbar" style="width:12.5%;"></div></div><div class="introjs-arrow left" style="display: inherit;"></div><div class="introjs-tooltipbuttons"><a class="introjs-button introjs-skipbutton" href="javascript:void(0);">Don't show it again!</a><a href="javascript:void(0);" class="introjs-button introjs-prevbutton introjs-disabled" tabindex="-1">Previous</a><a href="javascript:void(0);" class="introjs-button introjs-nextbutton">Next</a></div></div></div></body></html>​

Appium log

14
  • Yeah, it's an angular site
    – Emna Ayadi
    May 7, 2016 at 6:22
  • 1
    If that is the case, ideal solution would be to ask them if they can switch that service to use Interval.js (part of Angular). Otherwise you'd have to turn on browser.ignoreSynchronization and treat your app as if it's non-angular
    – Gunderson
    May 7, 2016 at 18:50
  • 1
    @Emma Hi, I found this question in your comment. So I will try to help. --- First change element(by.buttonText('Next')) to $('.introjs-nextbutton') --- Second EC.stalenessOf... it look like you are waiting for the button to be NOT attached to DOM then click on it... this doesn't make any sense for me. Try to remove EC.stalenessOf then simply do tutorial.click(). Give these suggests a try and tell me if it works ;)
    – Linh Pham
    May 10, 2016 at 15:16
  • 1
    @LinhPham, Hi Ok thanks i'll try and tell you ;)
    – Emna Ayadi
    May 10, 2016 at 15:18
  • 1
    @Emma, can you somehow share me full code of that describe block after you have adjusted?
    – Linh Pham
    May 10, 2016 at 15:50

4 Answers 4

3
+25

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.

8
  • 1
    Thank you for your suggestions, i'll try and let you know ;)
    – Emna Ayadi
    May 10, 2016 at 17:18
  • 1
    @Emma, I've added 3rd suggestion. If error still present, please copy and paste it here. I will check on this again tomorrow, cheer! ;)
    – Linh Pham
    May 10, 2016 at 17:36
  • Ok i'll check it because until now error is still present .. Thanks a lot for all your tries ;)
    – Emna Ayadi
    May 10, 2016 at 17:38
  • @Emma, is it like we still have the same error output?
    – Linh Pham
    May 11, 2016 at 2:55
  • 1
    @Emma, very useful information, I got 2 questions --- regarding with browser.sleep(time_to_wait); can you count how long it is after login and the error of time out appearr? --- please try to do a manual login and use a clock to check how long it took to finish the login (the route + view got changed and updated)?
    – Linh Pham
    May 11, 2016 at 12:49
2

Add parameter to conf.js under capabilities:

maxSessions: 1,

it should help. Also your timeoutinterval might be too high 30000 should be enough.

Or on prepare change line to :

browser.manage().timeouts().implicitlyWait(5000);

@EDIT: change to sth similar to this found something like this

  1. baseUrl is 10.0.2.2 instead of localhost because it is used to access the localhost of the host machine in the android emulator/device
baseUrl: 'http://10.0.2.2:' + (process.env.HTTP_PORT || '8000'),

Capabilities new command:

 newCommandTimeout: 60

Also use of promises might be helpfull instead of timeouts

someethingToDo.click().then(function(){

  return somethingToDo.click();

}).then(function(){
    //morecode
});
7
  • Same error with the first answer ! i'll try the second ;)
    – Emna Ayadi
    May 6, 2016 at 12:43
  • Sorry even with the second option i still have the same issue ! for login it's done that click option it's not working at all in home page
    – Emna Ayadi
    May 6, 2016 at 12:50
  • I have a question. You are using protractor or somekind pytractor or protractor.net ? I had similar problem while i was working on PyTractor, and i had to change it for clean ProTractor.
    – Hikaryu
    May 6, 2016 at 12:50
  • i'm using protractor to test a site in a mobile device (ipad simulator)
    – Emna Ayadi
    May 6, 2016 at 12:51
  • I edit main answer check it mb it will work :), and tell me you have homepage visable on mobile or not ?
    – Hikaryu
    May 6, 2016 at 13:03
2

I think you might have an issue with how your timeouts are set up. Remove all timeout references from your config file and try something like this (adjust accordingly to include other configurations as needed):

exports.config = {
    allScriptsTimeout: 60000,
    getPageTimeout: 30000,
    jasmineNodeOpts: {
        defaultTimeoutInterval: 62000,
    }
}
1
  • I tried it but i still have a jasmine DEFAULT_TIMEOUT_INTERVAL
    – Emna Ayadi
    May 13, 2016 at 8:36
2

Finally i tried to solve my problem by adding this call back

describe("long asynchronous specs", function() {
    beforeEach(function(done) {
      done();
    }, 10000);
    });

Here is a link from jasmine Asynchronous_Support that help me understand time out problems. Hope that can help you,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.