fork download
  1. public function waitForAjax()
  2. {
  3. try
  4. {
  5. //Wait for Angular
  6. if($this->getSession()->evaluateScript("return (typeof angular != 'undefined')"))
  7. {
  8. $angular = 'angular.getTestability(document.body).whenStable(function() {
  9. window.__testable = true;
  10. })';
  11. $this->getSession()->evaluateScript($angular);
  12. $this->getSession()->wait(5000, 'window.__testable == true');
  13. }
  14.  
  15. //Wait for jQuery
  16. if($this->getSession()->evaluateScript("return (typeof jQuery != 'undefined')"))
  17. {
  18. $this->getSession()->wait(5000, '(0 === jQuery.active && 0 === jQuery(\':animated\').length)');
  19. }
  20.  
  21. }catch(Exception $e)
  22. {
  23.  
  24. }
  25. }
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
    public function waitForAjax()
    {
        try
        {
            //Wait for Angular
            if($this->getSession()->evaluateScript("return (typeof angular != 'undefined')"))
            {
                $angular = 'angular.getTestability(document.body).whenStable(function() {
                    window.__testable = true;
                })';
                $this->getSession()->evaluateScript($angular);
                $this->getSession()->wait(5000, 'window.__testable == true');
            }

            //Wait for jQuery
            if($this->getSession()->evaluateScript("return (typeof jQuery != 'undefined')"))
            {
                $this->getSession()->wait(5000, '(0 === jQuery.active && 0 === jQuery(\':animated\').length)');
            }
            
        }catch(Exception $e)
        {

        }
    }