public function quit() { try { $this->driver->quit(); } catch (UnknownServerException $e) { } }
/** * This method is called after the last case in the test has been run. * We can safely terminate the webdriver connection here. * * @access public */ public static function tearDownAfterClass() { if (self::$my_webdriver !== null) { self::$my_webdriver->quit(); self::$my_webdriver = null; } }
/** * Set user agent */ public function testSetUserAgent() { $useragent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'; // setup $capabilities = DesiredCapabilities::firefox(); /** @var FirefoxProfile $profile */ $profile = $capabilities->getCapability(FirefoxDriver::PROFILE); $profile->setPreference('general.useragent.override', $useragent); $this->webDriver = RemoteWebDriver::create('http://' . self::HOST . '/wd/hub', $capabilities); // test $this->webDriver->get('http://demo.mobiledetect.net/'); $elements = $this->webDriver->findElements(WebDriverBy::tagName('h1')); static::assertEquals(3, count($elements)); $elementContainingQuestion = $elements[1]; static::assertEquals('Is your device really a phone?', $elementContainingQuestion->getText()); $this->webDriver->quit(); }
public function _afterSuite() { // this is just to make sure webDriver is cleared after suite if (isset($this->webDriver)) { $this->webDriver->quit(); unset($this->webDriver); } }
/** * This method is invoked after a test method */ public function tearDown() { $this->webDriver->quit(); }
public function tearDown() { if ($this->webDriver instanceof RemoteWebDriver) { $this->webDriver->quit(); } }
protected function cleanWebDriver() { foreach ($this->sessions as $session) { $this->_loadSession($session); try { $this->webDriver->quit(); } catch (UnknownServerException $e) { // Session already closed so nothing to do } unset($this->webDriver); } $this->sessions = []; }
protected function tearDown() { if ($this->driver) { $this->driver->quit(); } }