How to checkif there are pending requests (Ajax and its variants) from browser

前端 未结 4 1973
感动是毒
感动是毒 2020-12-28 16:20

Some of the sites I deal with have heavy ajax requests. I plan to wait for Ajax request completion before clicking for asserting for element. Currently I use



        
4条回答
  •  囚心锁ツ
    2020-12-28 17:07

    If you are using JSONP requests, you need to enable the active handling:

    jQuery.ajaxPrefilter(function( options ) {
        options.global = true;
    });
    

    I think that the use of active is correct, but possibly the way you have used might return false in the instanceof conditions.

    Optionally, see another way to wait for jQuery ajax calls using active in Selenium tests:

    browser.wait_for_condition("selenium.browserbot.getCurrentWindow().jQuery.active === 0;", '30000')
    

提交回复
热议问题