Ejemplo n.º 1
0
 public function setUp()
 {
     self::$verificationErrors = array();
     self::$log = \Log::singleton('file', $GLOBALS['settings']['logname'], $this->getName());
     if ($GLOBALS['settings']['sauce.ondemand']) {
         $command_executor = "http://" . $GLOBALS['saucelabs']['username'] . ":" . $GLOBALS['saucelabs']['key'] . "@ondemand.saucelabs.com:80/wd/hub";
     } else {
         $command_executor = "http://" . $GLOBALS['settings']['seleniumserver'] . ":" . $GLOBALS['settings']['seleniumport'] . "/wd/hub";
     }
     $this->driver = new \SaunterPHP_Framework_Bindings_SaunterWebDriver($command_executor);
     // var_dump($this->driver);
     // this is inefficient, but...
     $decoded = json_decode($GLOBALS['settings']['browser'], true);
     if ($decoded) {
         $browser = $decoded["browser"];
     } else {
         $browser = $GLOBALS['settings']['browser'];
     }
     // since the config can be shared between, take out the rc *
     if (substr($browser, 0, 1) === "*") {
         $browser = substr($browser, 1);
     }
     if ($GLOBALS['settings']['sauce.ondemand']) {
         $additional_capabilities = array();
         switch ($decoded["os"]) {
             case 'Windows 2003':
                 $additional_capabilities["platform"] = "XP";
                 break;
             case 'Windows 2008':
                 $additional_capabilities["platform"] = "VISTA";
                 break;
             default:
                 $additional_capabilities["platform"] = "LINUX";
         }
         if (substr($decoded["browser-version"], -1, 1) === ".") {
             $additional_capabilities["version"] = substr($decoded["browser-version"], 0, -1);
         } else {
             $additional_capabilities["version"] = $decoded["browser-version"];
         }
     } else {
         $additional_capabilities = array();
     }
     $this->session = $this->driver->session($browser, $additional_capabilities);
     // var_dump($this->session);
     $this->sessionId = substr($this->session->getURL(), strrpos($this->session->getURL(), "/") + 1);
     // var_dump($this->sessionId);
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     self::$verificationErrors = array();
     $this->screenshot_number = 1;
     // screenshot overhead; coupled with php overhead...
     $_inter_one = get_class($this);
     $_inter_two = explode('\\', $_inter_one);
     $this->current_class_name = end($_inter_two);
     $this->prep_screenshot_dirs();
     $this->log = \Log::factory('file', $this->current_test_log_dir . DIRECTORY_SEPARATOR . 'test.log');
     // this is inefficient, but...
     $decoded = json_decode($GLOBALS['settings']['browser'], true);
     if ($decoded) {
         $browser = $decoded["browser"];
     } else {
         $browser = $GLOBALS['settings']['browser'];
     }
     $profile = null;
     if ($browser == 'firefox') {
         $profile_path = null;
         if (array_key_exists('profile-' . strtolower(PHP_OS), $GLOBALS['settings'])) {
             $profile_path = $GLOBALS['settings']['saunter.base'] . DIRECTORY_SEPARATOR . 'support/profiles/' . $GLOBALS['settings']['profile-' . strtolower(PHP_OS)];
         } elseif (array_key_exists('profile', $GLOBALS['settings'])) {
             $profile_path = $GLOBALS['settings']['saunter.base'] . DIRECTORY_SEPARATOR . 'support/profiles/' . $GLOBALS['settings']['profile'];
         }
         if ($profile_path) {
             if (is_dir($profile_path)) {
                 $profile = new \PHPWebDriver_WebDriverFirefoxProfile($profile_path);
             } else {
                 throw new \SaunterPHP_Framework_Exception("Profile directory not found at {$profile_path}");
             }
         }
     }
     if ($GLOBALS['settings']['sauce.ondemand']) {
         $command_executor = "http://" . $GLOBALS['saucelabs']['username'] . ":" . $GLOBALS['saucelabs']['key'] . "@ondemand.saucelabs.com:80/wd/hub";
     } else {
         $command_executor = "http://" . $GLOBALS['settings']['seleniumserver'] . ":" . $GLOBALS['settings']['seleniumport'] . "/wd/hub";
     }
     $this->driver = new \SaunterPHP_Framework_Bindings_SaunterWebDriver($command_executor);
     // var_dump($this->driver);
     // since the config can be shared between, take out the rc *
     if (substr($browser, 0, 1) === "*") {
         $browser = substr($browser, 1);
     }
     $additional_capabilities = array();
     if ($GLOBALS['settings']['sauce.ondemand']) {
         switch ($decoded["os"]) {
             case 'XP':
             case 'Windows XP':
                 $additional_capabilities["platform"] = "Windows XP";
                 break;
             case 'Windows 7':
                 $additional_capabilities["platform"] = "Windows 7";
                 break;
             case 'Windows 8':
                 $additional_capabilities["platform"] = "Windows 8";
                 break;
             case 'OSX':
             case 'MAC':
                 $additional_capabilities["platform"] = "MAC";
                 break;
             case 'Android':
             case 'Linux':
             default:
                 $additional_capabilities["platform"] = "Linux";
         }
         if (substr($decoded["browser-version"], -1, 1) === ".") {
             $additional_capabilities["version"] = substr($decoded["browser-version"], 0, -1);
         } else {
             $additional_capabilities["version"] = $decoded["browser-version"];
         }
         // selenium version
         if (array_key_exists('selenium-version', $GLOBALS['saucelabs'])) {
             $additional_capabilities["selenium-version"] = $GLOBALS['saucelabs']['selenium-version'];
         }
     } else {
         if (array_key_exists('proxy', $GLOBALS['settings']) && $GLOBALS['settings']['proxy']) {
             $proxy = new \PHPWebDriver_WebDriverProxy();
             if (array_key_exists('proxy', $GLOBALS['settings']) && $GLOBALS['settings']['proxy.browsermob']) {
                 $this->client = new \PHPBrowserMobProxy_Client($GLOBALS['settings']['proxy']);
                 $proxy->httpProxy = $this->client->url;
                 $proxy->sslProxy = $this->client->url;
             } else {
                 $proxy->httpProxy = $GLOBALS['settings']['proxy'];
                 $proxy->sslProxy = $GLOBALS['settings']['proxy'];
             }
             $proxy->add_to_capabilities($additional_capabilities);
         }
     }
     $this->session = $this->driver->session($GLOBALS['settings']['browser'], $additional_capabilities, array(), $profile);
     // var_dump($this->session);
     $this->sessionId = substr($this->session->getURL(), strrpos($this->session->getURL(), "/") + 1);
     // var_dump($this->sessionId);
 }