Exemplo n.º 1
0
 protected function initCommands()
 {
     $baseUrl = $this->baseUrl;
     $commands = parent::initCommands();
     $commands['contexts'] = 'PHPUnit_Extensions_Selenium2TestCase_SessionCommand_GenericAccessor';
     $commands['context'] = 'PHPUnit_Extensions_AppiumTestCase_SessionCommand_Context';
     return $commands;
 }
Exemplo n.º 2
0
 public function __construct(Nette\DI\Container $serviceLocator, \PHPUnit_Extensions_Selenium2TestCase_Driver $driver, \PHPUnit_Extensions_Selenium2TestCase_URL $url, array $parameters, \PHPUnit_Extensions_Selenium2TestCase_Session_Timeouts $timeouts)
 {
     parent::__construct($driver, $url, $parameters['browserUrl'], $timeouts);
     $this->serviceLocator = $serviceLocator;
     $this->linkGenerator = new LinkGeneratorPresenter($this->serviceLocator);
     $this->httpServerUrl = $serviceLocator->getByType('Nette\\Http\\IRequest')->getUrl();
     $this->parameters = $parameters;
     $this->keysHolder = new \PHPUnit_Extensions_Selenium2TestCase_KeysHolder();
     $this->currentWindow()->maximize();
 }
Exemplo n.º 3
0
 protected function loginIfNecessary()
 {
     $this->session->currentWindow()->maximize();
     if ($this->elementExists('#wpadminbar')) {
         return;
     }
     $this->url(self::$wpAdminPath);
     usleep(100 * 1000);
     // sometimes we need to wait for the page to fully load
     if (!$this->elementExists('#user_login')) {
         return;
     }
     $this->byId('user_login')->value(self::$testConfig->testSite->adminName);
     usleep(100 * 1000);
     // wait for change focus
     $this->byId('user_pass')->value(self::$testConfig->testSite->adminPassword);
     $this->byId("loginform")->submit();
 }
 /**
  * Get Selenium2 current session id
  * @return string
  */
 public function getSessionId()
 {
     if ($this->session) {
         return $this->session->id();
     }
     return FALSE;
 }
Exemplo n.º 5
0
 public function endOfTest(PHPUnit_Extensions_Selenium2TestCase_Session $session)
 {
     $session->stop();
 }
Exemplo n.º 6
0
 /**
  * Executes a WebDriver command and checks if the Nette Bluescreen (aka
  * Tracy or Laděnka) has appeared.
  *
  * Presence of the bluescreen is recognized by a javascript check of presence
  * of an element with ID `$this->blueScreenId`.
  *
  * You may suppress this detection globaly (`$this->checkForBlueScreen`),
  * or for some particular commands (`$this->commandsWithoutCheckForBluescreen`)
  * and also it isn't performed for `$this->url()` (without parameters)
  * and `$this->byId($this->blueScreenId)` to avoid recursion.
  *
  * @param string $command
  * @param array $arguments
  * @return mixed
  */
 public function __call($command, $arguments)
 {
     $result = parent::__call($command, $arguments);
     if ($this->checkForBlueScreen) {
         $checkExecuteArgs = array('script' => 'return document.getElementById(' . json_encode($this->blueScreenId) . ') != undefined', 'args' => array());
         $funcGetArgs = func_get_args();
         if ($funcGetArgs !== array('execute', array($checkExecuteArgs)) && $funcGetArgs !== array('byId', array($this->blueScreenId)) && $funcGetArgs !== array('url', array()) && !in_array($command, $this->commandsWithoutCheckForBluescreen) && $this->execute($checkExecuteArgs)) {
             $text = $this->byId($this->blueScreenId)->text();
             throw new BluescreenException("Na stránce:\n" . $this->url() . "\n se vyskytla chyba:\n" . $text);
         }
     }
     return $result;
 }
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $driver = $this->getDriver();
     if (self::$shareSession and self::$sharedSessionUrl !== NULL) {
         $this->session = new PHPUnit_Extensions_Selenium2TestCase_Session($driver, self::$sharedSessionUrl, $this->browserUrl);
         $this->session->window('');
     } else {
         $this->session = $driver->startSession($this->browser, $this->browserUrl);
         self::$sharedSessionUrl = $this->session->getSessionUrl();
     }
     parent::runTest();
     if (!empty($this->verificationErrors)) {
         $this->fail(implode("\n", $this->verificationErrors));
     }
     if (!self::$shareSession) {
         $this->session->stop();
     }
 }