/** * * @param StoryTeller $st * @return void */ public function start(StoryTeller $st) { $httpProxy = new BrowserMobProxyClient(); $httpProxy->enableFeature('enhancedReplies'); $this->proxySession = $httpProxy->createProxy(); // start recording $this->proxySession->startHAR(); // create the browser session $webDriver = new WebDriverClient($this->browserDetails->url); $this->browserSession = $webDriver->newSession($this->browserDetails->browser, array('proxy' => $this->proxySession->getWebDriverProxyConfig()) + $this->browserDetails->desiredCapabilities); }
/** * * @param StoryTeller $st * @return void */ public function start(StoryTeller $st) { // Sauce Labs handles proxying for us (if required) // via the Sauce Connect app // build the Sauce Labs url $url = "http://" . urlencode($this->browserDetails->saucelabs->username) . ':' . urlencode($this->browserDetails->saucelabs->accesskey) . '@ondemand.saucelabs.com/wd/hub'; // build the Sauce Labs capabilities array $desiredCapabilities = $this->browserDetails->desiredCapabilities; // add the story's name, so that someone looking at the Sauce Labs // list of jobs can see what this browser was used for // // due to encoding errors at SauceLabs, we can't use '>' as a // delimiter in the story's name $story = $st->getStory(); $desiredCapabilities['name'] = $st->getTestEnvironmentName() . ' / ' . $st->getCurrentPhase() . ': ' . $st->getCurrentPhaseName() . ' / ' . $story->getName(); // create the browser session $webDriver = new WebDriverClient($url); $this->browserSession = $webDriver->newSession($this->browserDetails->browser, $desiredCapabilities); }
/** * * @param StoryTeller $st * @return void */ public function start(StoryTeller $st) { // are we using browsermob-proxy? $useProxy = false; if (fromConfig()->hasModuleSetting('device.browsermob.enable')) { $useProxy = fromConfig()->getModuleSetting('device.browsermob.enable'); } // do we have a URL to use? $browserUrl = 'http://localhost:4444/wd/hub'; if (fromConfig()->hasModuleSetting('device.localwebdriver.url')) { $browserUrl = fromConfig()->getModuleSetting('device.localwebdriver.url'); } try { // by default, we have no proxy session $this->proxySession = null; // start the proxy if we want it if ($useProxy) { $httpProxy = new BrowserMobProxyClient(); $httpProxy->enableFeature('enhancedReplies'); $this->proxySession = $httpProxy->createProxy(); // start recording $this->proxySession->startHAR(); } // build our requirements for Selenium $desiredCapabilities = $this->browserDetails->desiredCapabilities; if (is_object($this->proxySession)) { $desiredCapabilities['proxy'] = $this->proxySession->getWebDriverProxyConfig(); } // create the browser session $webDriver = new WebDriverClient($browserUrl); $this->browserSession = $webDriver->newSession($this->browserDetails->browser, $desiredCapabilities); } catch (Exception $e) { // something went wrong throw new E5xx_CannotStartDevice(); } }