protected function login($username = '******') { $this->add_lang('ucp'); $this->visit('ucp.php'); $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), self::$webDriver->getPageSource()); self::$webDriver->manage()->deleteAllCookies(); self::find_element('cssSelector', 'input[name=username]')->sendKeys($username); self::find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); self::find_element('cssSelector', 'input[name=login]')->click(); $this->assertNotContains($this->lang('LOGIN'), $this->find_element('className', 'navbar')->getText()); $cookies = self::$webDriver->manage()->getCookies(); // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie foreach ($cookies as $cookie) { if (substr($cookie['name'], -4) == '_sid') { $this->sid = $cookie['value']; } } $this->assertNotEmpty($this->sid); }
protected function assertPageSourceNotContains($needle, $message = '') { $this->assertThatItsNot($this->webDriver->getPageSource(), new PageConstraint($needle, $this->_getCurrentUri()), $message); }
public function grabTextFrom($cssOrXPathOrRegex) { $els = $this->match($this->webDriver, $cssOrXPathOrRegex, false); if (count($els)) { return $els[0]->getText(); } if (@preg_match($cssOrXPathOrRegex, $this->webDriver->getPageSource(), $matches)) { return $matches[1]; } throw new ElementNotFound($cssOrXPathOrRegex, 'CSS or XPath or Regex'); }