* @author Anthon Pang */ namespace WebDriver; /** * WebDriver class * * @package WebDriver * * @method status */ class WebDriver extends AbstractWebDriver implements WebDriverInterface { /** * {@inheritdoc} */ protected function methods() { return array( 'status' => 'GET', ); } /** * {@inheritdoc} */ public function session($requiredCapabilities = Browser::FIREFOX, $desiredCapabilities = array()) { // for backwards compatibility when the only required capability was browser name if (! is_array($requiredCapabilities)) { $desiredCapabilities[Capability::BROWSER_NAME] = $requiredCapabilities ?: Browser::FIREFOX; $requiredCapabilities = array(); } // required $parameters = array( 'desiredCapabilities' => array_merge($desiredCapabilities, $requiredCapabilities) ); // optional if (! empty($requiredCapabilities)) { $parameters['requiredCapabilities'] = $requiredCapabilities; } $result = $this->curl( 'POST', '/session', $parameters, array(CURLOPT_FOLLOWLOCATION => true) ); return new Session($result['sessionUrl']); } /** * {@inheritdoc} */ public function sessions() { $result = $this->curl('GET', '/sessions'); $sessions = array(); foreach ($result['value'] as $session) { $sessions[] = new Session($this->url . '/session/' . $session['id']); } return $sessions; } }