Search code examples
javascriptajaxselenium-webdrivercodeception

Codeception selenium WaitForJS and Ajax


I have a loading waiting for a hidden field to be fill. i would like to wait for the ajax to be loaded to go to the next step. i tried to use the waitForJS to do this but i dont know how to built the javascript condition.

I already try with an other condtion but it doesnt work, i really need the ajax to be loaded to go the next step.

$I->waitForJS(
    15000, 
    "(function myJavascriptFunction() {       
        var monChamp = document.getElementById('data-com_product_id');
        if (monChamp.value != '') {
            return true;    
        } else {
            return false;   
        }
     })()"
);

Every suggestions wil be welcome. Thank You


Solution

  • You can use:

    $I->waitForJS("return $.active == 0;",10);
    

    if you use webdriver in codeception. Tested it just now and works like charm.