PK "?Vu`2n n phpunit.xml.distnu W+A
tests/unit
tests/functional/
PK "?VpK lib/WebDriverTargetLocator.phpnu W+A executor = $executor;
}
/**
* Move back a single entry in the browser's history, if possible.
*
* @return WebDriverNavigation The instance.
*/
public function back() {
$this->executor->execute(DriverCommand::GO_BACK);
return $this;
}
/**
* Move forward a single entry in the browser's history, if possible.
*
* @return WebDriverNavigation The instance.
*/
public function forward() {
$this->executor->execute(DriverCommand::GO_FORWARD);
return $this;
}
/**
* Refresh the current page.
*
* @return WebDriverNavigation The instance.
*/
public function refresh() {
$this->executor->execute(DriverCommand::REFRESH);
return $this;
}
/**
* Navigate to the given URL.
*
* @param string $url
* @return WebDriverNavigation The instance.
*/
public function to($url) {
$params = array('url' => (string)$url);
$this->executor->execute(DriverCommand::GET, $params);
return $this;
}
}
PK "?VE7 7 5 lib/Support/Events/EventFiringWebDriverNavigation.phpnu W+A navigator = $navigator;
$this->dispatcher = $dispatcher;
return $this;
}
/**
* @return WebDriverDispatcher
*/
public function getDispatcher() {
return $this->dispatcher;
}
/**
* @param mixed $method
* @return void
*/
protected function dispatch($method) {
if (!$this->dispatcher) {
return;
}
$arguments = func_get_args();
unset($arguments[0]);
$this->dispatcher->dispatch($method, $arguments);
}
/**
* @return WebDriverNavigation
*/
public function getNavigator() {
return $this->navigator;
}
/**
* @return $this
* @throws WebDriverException
*/
public function back() {
$this->dispatch(
'beforeNavigateBack',
$this->getDispatcher()->getDefaultDriver()
);
try {
$this->navigator->back();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterNavigateBack',
$this->getDispatcher()->getDefaultDriver()
);
return $this;
}
/**
* @return $this
* @throws WebDriverException
*/
public function forward() {
$this->dispatch(
'beforeNavigateForward',
$this->getDispatcher()->getDefaultDriver()
);
try {
$this->navigator->forward();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterNavigateForward',
$this->getDispatcher()->getDefaultDriver()
);
return $this;
}
/**
* @return $this
* @throws WebDriverException
*/
public function refresh() {
try {
$this->navigator->refresh();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @param mixed $url
* @return $this
* @throws WebDriverException
*/
public function to($url) {
$this->dispatch(
'beforeNavigateTo',
$url,
$this->getDispatcher()->getDefaultDriver()
);
try {
$this->navigator->to($url);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterNavigateTo',
$url,
$this->getDispatcher()->getDefaultDriver()
);
return $this;
}
private function dispatchOnException($exception) {
$this->dispatch('onException', $exception);
throw $exception;
}
}
PK "?Viřa! a! , lib/Support/Events/EventFiringWebElement.phpnu W+A element = $element;
$this->dispatcher = $dispatcher;
return $this;
}
/**
* @return WebDriverDispatcher
*/
public function getDispatcher() {
return $this->dispatcher;
}
/**
* @param mixed $method
* @return void
*/
protected function dispatch($method) {
if (!$this->dispatcher) {
return;
}
$arguments = func_get_args();
unset($arguments[0]);
$this->dispatcher->dispatch($method, $arguments);
}
/**
* @return WebDriverElement
*/
public function getElement() {
return $this->element;
}
/**
* @param WebDriverElement $element
* @return EventFiringWebElement
*/
private function newElement(WebDriverElement $element) {
return new EventFiringWebElement($element, $this->getDispatcher());
}
/**
* @param mixed $value
* @return $this
* @throws WebDriverException
*/
public function sendKeys($value) {
$this->dispatch('beforeChangeValueOf', $this);
try {
$this->element->sendKeys($value);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterChangeValueOf', $this);
return $this;
}
/**
* @return $this
* @throws WebDriverException
*/
public function click() {
$this->dispatch('beforeClickOn', $this);
try {
$this->element->click();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterClickOn', $this);
return $this;
}
/**
* @param WebDriverBy $by
* @return EventFiringWebElement
* @throws WebDriverException
*/
public function findElement(WebDriverBy $by) {
$this->dispatch(
'beforeFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver());
try {
$element = $this->newElement($this->element->findElement($by));
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
return $element;
}
/**
* @param WebDriverBy $by
* @return array
* @throws WebDriverException
*/
public function findElements(WebDriverBy $by) {
$this->dispatch(
'beforeFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
try {
$elements = array();
foreach ($this->element->findElements($by) as $element) {
$elements[] = $this->newElement($element);
}
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch(
'afterFindBy',
$by,
$this,
$this->dispatcher->getDefaultDriver()
);
return $elements;
}
/**
* @return $this
* @throws WebDriverException
*/
public function clear() {
try {
$this->element->clear();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @param string $attribute_name
* @return string
* @throws WebDriverException
*/
public function getAttribute($attribute_name) {
try {
return $this->element->getAttribute($attribute_name);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @param string $css_property_name
* @return string
* @throws WebDriverException
*/
public function getCSSValue($css_property_name) {
try {
return $this->element->getCSSValue($css_property_name);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverPoint
* @throws WebDriverException
*/
public function getLocation() {
try {
return $this->element->getLocation();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverPoint
* @throws WebDriverException
*/
public function getLocationOnScreenOnceScrolledIntoView() {
try {
return $this->element->getLocationOnScreenOnceScrolledIntoView();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverCoordinates
*/
public function getCoordinates() {
try {
return $this->element->getCoordinates();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverDimension
* @throws WebDriverException
*/
public function getSize() {
try {
return $this->element->getSize();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getTagName() {
try {
return $this->element->getTagName();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getText() {
try {
return $this->element->getText();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return bool
* @throws WebDriverException
*/
public function isDisplayed() {
try {
return $this->element->isDisplayed();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return bool
* @throws WebDriverException
*/
public function isEnabled() {
try {
return $this->element->isEnabled();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return bool
* @throws WebDriverException
*/
public function isSelected() {
try {
return $this->element->isSelected();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return $this
* @throws WebDriverException
*/
public function submit() {
try {
$this->element->submit();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getID() {
try {
return $this->element->getID();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* Test if two element IDs refer to the same DOM element.
*
* @param WebDriverElement $other
* @return bool
*/
public function equals(WebDriverElement $other) {
try {
return $this->element->equals($other);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
private function dispatchOnException($exception) {
$this->dispatch(
'onException',
$exception,
$this->dispatcher->getDefaultDriver()
);
throw $exception;
}
}
PK "?Vv&$ $ + lib/Support/Events/EventFiringWebDriver.phpnu W+A dispatcher = $dispatcher ?: new WebDriverDispatcher();
if (!$this->dispatcher->getDefaultDriver()) {
$this->dispatcher->setDefaultDriver($this);
}
$this->driver = $driver;
return $this;
}
/**
* @return WebDriverDispatcher
*/
public function getDispatcher() {
return $this->dispatcher;
}
/**
* @param mixed $method
* @return void
*/
protected function dispatch($method) {
if (!$this->dispatcher) {
return;
}
$arguments = func_get_args();
unset($arguments[0]);
$this->dispatcher->dispatch($method, $arguments);
}
/**
* @return WebDriver
*/
public function getWebDriver() {
return $this->driver;
}
/**
* @param WebDriverElement $element
* @return EventFiringWebElement
*/
private function newElement(WebDriverElement $element) {
return new EventFiringWebElement($element, $this->getDispatcher());
}
/**
* @param mixed $url
* @return $this
* @throws WebDriverException
*/
public function get($url) {
$this->dispatch('beforeNavigateTo', $url, $this);
try {
$this->driver->get($url);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterNavigateTo', $url, $this);
return $this;
}
/**
* @param WebDriverBy $by
* @return array
* @throws WebDriverException
*/
public function findElements(WebDriverBy $by) {
$this->dispatch('beforeFindBy', $by, null, $this);
try {
$elements = array();
foreach ($this->driver->findElements($by) as $element) {
$elements[] = $this->newElement($element);
}
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterFindBy', $by, null, $this);
return $elements;
}
/**
* @param WebDriverBy $by
* @return EventFiringWebElement
* @throws WebDriverException
*/
public function findElement(WebDriverBy $by) {
$this->dispatch('beforeFindBy', $by, null, $this);
try {
$element = $this->newElement($this->driver->findElement($by));
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterFindBy', $by, null, $this);
return $element;
}
/**
* @param $script
* @param array $arguments
* @return mixed
* @throws WebDriverException
*/
public function executeScript($script, array $arguments = array()) {
if (!$this->driver instanceof JavaScriptExecutor) {
throw new UnsupportedOperationException(
'driver does not implement JavaScriptExecutor'
);
}
$this->dispatch('beforeScript', $script, $this);
try {
$result = $this->driver->executeScript($script, $arguments);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterScript', $script, $this);
return $result;
}
/**
* @param $script
* @param array $arguments
* @return mixed
* @throws WebDriverException
*/
public function executeAsyncScript($script, array $arguments = array()) {
if (!$this->driver instanceof JavaScriptExecutor) {
throw new UnsupportedOperationException(
'driver does not implement JavaScriptExecutor'
);
}
$this->dispatch('beforeScript', $script, $this);
try {
$result = $this->driver->executeAsyncScript($script, $arguments);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
$this->dispatch('afterScript', $script, $this);
return $result;
}
/**
* @return $this
* @throws WebDriverException
*/
public function close() {
try {
$this->driver->close();
return $this;
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getCurrentURL() {
try {
return $this->driver->getCurrentURL();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getPageSource() {
try {
return $this->driver->getPageSource();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getTitle() {
try {
return $this->driver->getTitle();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return string
* @throws WebDriverException
*/
public function getWindowHandle() {
try {
return $this->driver->getWindowHandle();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return array
* @throws WebDriverException
*/
public function getWindowHandles() {
try {
return $this->driver->getWindowHandles();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @throws WebDriverException
*/
public function quit() {
try {
$this->driver->quit();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @param null|string $save_as
* @return string
* @throws WebDriverException
*/
public function takeScreenshot($save_as = null) {
try {
return $this->driver->takeScreenshot($save_as);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @param int $timeout_in_second
* @param int $interval_in_millisecond
* @return WebDriverWait
* @throws WebDriverException
*/
public function wait($timeout_in_second = 30,
$interval_in_millisecond = 250) {
try {
return $this->driver->wait($timeout_in_second, $interval_in_millisecond);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverOptions
* @throws WebDriverException
*/
public function manage() {
try {
return $this->driver->manage();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return EventFiringWebDriverNavigation
* @throws WebDriverException
*/
public function navigate() {
try {
return new EventFiringWebDriverNavigation(
$this->driver->navigate(),
$this->getDispatcher()
);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverTargetLocator
* @throws WebDriverException
*/
public function switchTo() {
try {
return $this->driver->switchTo();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
/**
* @return WebDriverTouchScreen
* @throws WebDriverException
*/
public function getTouch() {
try {
return $this->driver->getTouch();
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
private function dispatchOnException($exception) {
$this->dispatch('onException', $exception, $this);
throw $exception;
}
public function execute($name, $params) {
try {
return $this->driver->execute($name, $params);
} catch (WebDriverException $exception) {
$this->dispatchOnException($exception);
}
}
}
PK "?V/ lib/Firefox/FirefoxProfile.phpnu W+A extensions[] = $extension;
return $this;
}
/**
* @param string $key
* @param string|bool|int $value
* @return FirefoxProfile
*/
public function setPreference($key, $value) {
if (is_string($value)) {
$value = sprintf('"%s"', $value);
} else if (is_int($value)) {
$value = sprintf('%d', $value);
} else if (is_bool($value)) {
$value = $value ? 'true' : 'false';
} else {
throw new WebDriverException(
'The value of the preference should be either a string, int or bool.');
}
$this->preferences[$key] = $value;
return $this;
}
/**
* @return string
*/
public function encode() {
$temp_dir = $this->createTempDirectory('WebDriverFirefoxProfile');
foreach ($this->extensions as $extension) {
$this->installExtension($extension, $temp_dir);
}
$content = "";
foreach ($this->preferences as $key => $value) {
$content .= sprintf("user_pref(\"%s\", %s);\n", $key, $value);
}
file_put_contents($temp_dir.'/user.js', $content);
$zip = new ZipArchive();
$temp_zip = tempnam('', 'WebDriverFirefoxProfileZip');
$zip->open($temp_zip, ZipArchive::CREATE);
$dir = new RecursiveDirectoryIterator($temp_dir);
$files = new RecursiveIteratorIterator($dir);
foreach ($files as $name => $object) {
if (is_dir($name)) {
continue;
}
$dir_prefix = preg_replace(
'#\\\\#',
'\\\\\\\\',
$temp_dir.DIRECTORY_SEPARATOR
);
$path = preg_replace("#^{$dir_prefix}#", "", $name);
$zip->addFile($name, $path);
}
$zip->close();
$profile = base64_encode(file_get_contents($temp_zip));
return $profile;
}
/**
* @param string $extension The path to the extension.
* @param string $profile_dir The path to the profile directory.
* @return string The path to the directory of this extension.
*/
private function installExtension($extension, $profile_dir) {
$temp_dir = $this->createTempDirectory();
$this->extractTo($extension, $temp_dir);
$install_rdf_path = $temp_dir.'/install.rdf';
// This is a hacky way to parse the id since there is no offical
// RDF parser library.
$matches = array();
$xml = file_get_contents($install_rdf_path);
preg_match('#([^<]+)#', $xml, $matches);
$ext_dir = $profile_dir.'/extensions/'.$matches[1];
mkdir($ext_dir, 0777, true);
$this->extractTo($extension, $ext_dir);
return $ext_dir;
}
/**
* @param string $prefix Prefix of the temp directory.
*
* @return string The path to the temp directory created.
* @throws WebDriverException
*/
private function createTempDirectory($prefix = '') {
$temp_dir = tempnam('', $prefix);
if (file_exists($temp_dir)) {
unlink($temp_dir);
mkdir($temp_dir);
if (!is_dir($temp_dir)) {
throw new WebDriverException('Cannot create firefox profile.');
}
}
return $temp_dir;
}
/**
* @param string $xpi The path to the .xpi extension.
* @param string $target_dir The path to the unzip directory.
*
* @return FirefoxProfile
* @throws \Exception
*/
private function extractTo($xpi, $target_dir) {
$zip = new ZipArchive();
if ($zip->open($xpi)) {
$zip->extractTo($target_dir);
$zip->close();
} else {
throw new \Exception("Failed to open the firefox extension. '$xpi'");
}
return $this;
}
}
PK "?VH lib/Firefox/FirefoxDriver.phpnu W+A x = $x;
$this->y = $y;
parent::__construct($touch_screen);
}
public function perform() {
$this->touchScreen->up($this->x, $this->y);
}
}
PK "?V$ lib/WebDriverDimension.phpnu W+A width = $width;
$this->height = $height;
}
/**
* Get the height.
*
* @return int The height.
*/
public function getHeight() {
return $this->height;
}
/**
* Get the width.
*
* @return int The width.
*/
public function getWidth() {
return $this->width;
}
/**
* Check whether the given dimension is the same as the instance.
*
* @param WebDriverDimension $dimension The dimension to be compared with.
* @return bool Whether the height and the width are the same as the
* instance.
*/
public function equals(WebDriverDimension $dimension) {
return $this->height === $dimension->getHeight() &&
$this->width === $dimension->getWidth();
}
}
PK "?V2ك; ; $ lib/Exception/WebDriverException.phpnu W+A results = $results;
}
/**
* @return mixed
*/
public function getResults() {
return $this->results;
}
/**
* Throw WebDriverExceptions.
* For $status_code >= 0, they are errors defined in the json wired protocol.
* For $status_code < 0, they are errors defined in php-webdriver.
*
* @param int $status_code
* @param string $message
* @param mixed $results
*
* @throws ElementNotSelectableException
* @throws ElementNotVisibleException
* @throws ExpectedException
* @throws IMEEngineActivationFailedException
* @throws IMENotAvailableException
* @throws IndexOutOfBoundsException
* @throws InvalidCookieDomainException
* @throws InvalidCoordinatesException
* @throws InvalidElementStateException
* @throws InvalidSelectorException
* @throws MoveTargetOutOfBoundsException
* @throws NoAlertOpenException
* @throws NoCollectionException
* @throws NoScriptResultException
* @throws NoStringException
* @throws NoStringLengthException
* @throws NoStringWrapperException
* @throws NoSuchCollectionException
* @throws NoSuchDocumentException
* @throws NoSuchDriverException
* @throws NoSuchElementException
* @throws NoSuchFrameException
* @throws NoSuchWindowException
* @throws NullPointerException
* @throws ScriptTimeoutException
* @throws SessionNotCreatedException
* @throws StaleElementReferenceException
* @throws TimeOutException
* @throws UnableToSetCookieException
* @throws UnexpectedAlertOpenException
* @throws UnexpectedJavascriptException
* @throws UnknownCommandException
* @throws UnknownServerException
* @throws UnrecognizedExceptionException
* @throws WebDriverCurlException
* @throws XPathLookupException
*/
public static function throwException($status_code, $message, $results) {
switch ($status_code) {
case -1:
throw new WebDriverCurlException($message);
case 0:
// Success
break;
case 1:
throw new IndexOutOfBoundsException($message, $results);
case 2:
throw new NoCollectionException($message, $results);
case 3:
throw new NoStringException($message, $results);
case 4:
throw new NoStringLengthException($message, $results);
case 5:
throw new NoStringWrapperException($message, $results);
case 6:
throw new NoSuchDriverException($message, $results);
case 7:
throw new NoSuchElementException($message, $results);
case 8:
throw new NoSuchFrameException($message, $results);
case 9:
throw new UnknownCommandException($message, $results);
case 10:
throw new StaleElementReferenceException($message, $results);
case 11:
throw new ElementNotVisibleException($message, $results);
case 12:
throw new InvalidElementStateException($message, $results);
case 13:
throw new UnknownServerException($message, $results);
case 14:
throw new ExpectedException($message, $results);
case 15:
throw new ElementNotSelectableException($message, $results);
case 16:
throw new NoSuchDocumentException($message, $results);
case 17:
throw new UnexpectedJavascriptException($message, $results);
case 18:
throw new NoScriptResultException($message, $results);
case 19:
throw new XPathLookupException($message, $results);
case 20:
throw new NoSuchCollectionException($message, $results);
case 21:
throw new TimeOutException($message, $results);
case 22:
throw new NullPointerException($message, $results);
case 23:
throw new NoSuchWindowException($message, $results);
case 24:
throw new InvalidCookieDomainException($message, $results);
case 25:
throw new UnableToSetCookieException($message, $results);
case 26:
throw new UnexpectedAlertOpenException($message, $results);
case 27:
throw new NoAlertOpenException($message, $results);
case 28:
throw new ScriptTimeoutException($message, $results);
case 29:
throw new InvalidCoordinatesException($message, $results);
case 30:
throw new IMENotAvailableException($message, $results);
case 31:
throw new IMEEngineActivationFailedException($message, $results);
case 32:
throw new InvalidSelectorException($message, $results);
case 33:
throw new SessionNotCreatedException($message, $results);
case 34:
throw new MoveTargetOutOfBoundsException($message, $results);
default:
throw new UnrecognizedExceptionException($message, $results);
}
}
}
PK "?VE
. lib/Exception/InvalidCookieDomainException.phpnu W+A &