示例#1
0
 public function testShouldNotLogCommandsInNormalMode()
 {
     $this->setDebugMode(false);
     // Make debug mode disabled
     $this->driver->findElement(\WebDriverBy::className('foo'));
     $this->driver->getTitle();
     $this->expectOutputString('');
 }
示例#2
0
 public function execute($command_name, $params = [])
 {
     if (ConfigProvider::getInstance()->debug) {
         $this->log('Executing command "%s" with params %s', $command_name, json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
     }
     return parent::execute($command_name, $params);
 }
示例#3
0
 /**
  * Subroutine to encapsulate creation of real WebDriver. Handles some exceptions that may occur etc.
  * The WebDriver instance is stored to $test->wd when created.
  *
  * @param AbstractTestCase $test
  * @param $remoteServerUrl
  * @param \DesiredCapabilities $capabilities
  * @param $connectTimeoutMs
  * @param $requestTimeoutMs
  */
 protected function createWebDriver(AbstractTestCase $test, $remoteServerUrl, \DesiredCapabilities $capabilities, $connectTimeoutMs, $requestTimeoutMs)
 {
     $browserName = ConfigProvider::getInstance()->browserName;
     for ($startAttempts = 0; $startAttempts < 4; $startAttempts++) {
         try {
             $test->wd = RemoteWebDriver::create($remoteServerUrl, $capabilities, $connectTimeoutMs, $requestTimeoutMs);
             return;
         } catch (\UnknownServerException $e) {
             if ($browserName == 'firefox' && strpos($e->getMessage(), 'Unable to bind to locking port') !== false) {
                 // As a consequence of Selenium issue #5172 (cannot change locking port), Firefox may on CI server
                 // collide with other FF instance. As a workaround, we try to start it again after a short delay.
                 $test->warn('Firefox locking port is occupied; beginning attempt #%d to start it ("%s")', $startAttempts + 2, $e->getMessage());
                 sleep(1);
                 continue;
             } elseif (strpos($e->getMessage(), 'Error forwarding the new session') !== false) {
                 $test->warn("Cannot execute test on the node. Maybe you started just the hub and not the node?");
             }
             throw $e;
         }
     }
     $test->warn('All %d attempts to instantiate Firefox WebDriver failed', $startAttempts + 1);
     throw $e;
 }