Example #1
0
 public function tearDown()
 {
     if ($this->driver) {
         if ($this->hasFailed()) {
             $this->driver->set_sauce_context("passed", false);
         } else {
             $this->driver->set_sauce_context("passed", true);
         }
         $this->driver->quit();
     }
     parent::tearDown();
     $time = microtime(true) - $this->startTime;
     $message = '...' . round($time, 2) . 's...';
     echo sprintf('%\'.-15s', trim($message));
 }
Example #2
0
 public function setUp()
 {
     // Choose one of the following
     // For tests running at Sauce Labs
     //     $this->driver = WebDriver_Driver::InitAtSauce("my-sauce-username", "my-sauce-api-key", "WINDOWS", "firefox", "3.6");
     //     $sauce_job_name = get_class($this);
     //     $this->driver->set_sauce_context("name", $sauce_job_name);
     // For a mock driver (for debugging)
     //     $this->driver = new WebDriver_MockDriver();
     //     define('kFestDebug', true);
     // For a local driver
     $this->driver = WebDriver_Driver::InitAtLocal("4444", "firefox");
 }
Example #3
0
 public function wait_for($condition, $params = array(), $expected = true)
 {
     //$time = microtime(true);
     $wait = $this->driver->set_implicit_wait(0);
     $result = false;
     for ($i = 0; $i <= $wait; $i += 100) {
         if (call_user_func_array(array($this, $condition), $params) == $expected) {
             $result = true;
             break;
         }
         usleep(100);
     }
     $this->driver->set_implicit_wait($wait);
     //echo PHP_EOL . 'wait '.$condition.': ' .$this->locator ." time: " . (microtime(true) - $time) ." ";
     return $result;
 }
Example #4
0
 public static function InitAtBrowserStack($browserstack_username, $browserstack_value, $os, $browser, $version = false, $additional_options = array(), $starting_time = null, $attempt = 1)
 {
     if (!$starting_time) {
         $starting_time = time();
     }
     try {
         $capabilities = array_merge(array('browserstack.debug' => true, 'platform' => strtoupper($os), 'browserName' => $browser), $additional_options);
         if ($version) {
             $capabilities["version"] = $version;
         }
         return new WebDriver_Driver("http://" . $browserstack_username . ":" . $browserstack_value . "@hub.browserstack.com/wd/hub", $capabilities);
     } catch (WebDriver_OverParallelLimitException $e) {
         PHPUnit_Framework_Assert::assertTrue(time() < $starting_time + WebDriver::$BrowserStackMaxSeconds, "Reached maximum BrowserStack attempt seconds: " . WebDriver::$BrowserStackMaxSeconds);
         PHPUnit_Framework_Assert::assertTrue($attempt < WebDriver::$BrowserStackMaxAttempts, "Reached maximum BrowserStack attempt number: " . WebDriver::$BrowserStackMaxAttempts);
         sleep(WebDriver::$BrowserStackWaitSeconds);
         return WebDriver_Driver::InitAtBrowserStack($browserstack_username, $browserstack_value, $os, $browser, $version, $additional_options, $starting_time, $attempt + 1);
     }
 }
Example #5
0
 public function setUp()
 {
     // If you want to set preferences in your Firefox profile
     $fp = new WebDriver_FirefoxProfile();
     $fp->set_preference("capability.policy.default.HTMLDocument.compatMode", "allAccess");
     // Choose one of the following
     // For tests running at Sauce Labs
     //     $this->driver = WebDriver_Driver::InitAtSauce(
     //       "my-sauce-username",
     //       "my-sauce-api-key",
     //       "WINDOWS",
     //       "firefox",
     //       "10",
     //       array(
     //         'firefox_profile' => $fp->get_profile()
     //       ));
     //     $sauce_job_name = get_class($this);
     //     $this->driver->set_sauce_context("name", $sauce_job_name);
     // For a mock driver (for debugging)
     //     $this->driver = new WebDriver_MockDriver();
     //     define('kFestDebug', true);
     // For a local driver
     $this->driver = WebDriver_Driver::InitAtLocal("4444", "firefox");
 }