/**
  * Ожидаем завершения обновления страницы при ajax запросе
  * @param  RemoteWebDriver $driver
  * @param  string $framework
  */
 function waitForAjax($driver, $framework = 'jquery')
 {
     // javascript framework
     switch ($framework) {
         case 'jquery':
             $code = "return jQuery.active;";
             break;
         case 'prototype':
             $code = "return Ajax.activeRequestCount;";
             break;
         case 'dojo':
             $code = "return dojo.io.XMLHTTPTransport.inFlight.length;";
             break;
         default:
             throw new Exception('Not supported framework');
     }
     do {
         sleep(2);
     } while ($driver->executeScript($code));
 }
Beispiel #2
0
 /**
  * Executes custom JavaScript
  * 
  * In this example we will use jQuery to get a value and assign this value to a variable.
  *
  * ```php
  * <?php
  * $myVar = $I->executeJS('return $("#myField").val()');
  * ?>
  * ```
  *
  * @param $script
  * @return mixed
  */
 public function executeJS($script)
 {
     return $this->webDriver->executeScript($script);
 }