class Execute
WebDriver\Execute class
@package WebDriver
Hierarchy
- class \WebDriver\AbstractWebDriver
- class \WebDriver\Execute extends \WebDriver\AbstractWebDriver
Expanded class hierarchy of Execute
5 string references to 'Execute'
- CommandDataCollector::getCommand in vendor/
symfony/ console/ DataCollector/ CommandDataCollector.php - CurlMultiHandler::__invoke in vendor/
guzzlehttp/ guzzle/ src/ Handler/ CurlMultiHandler.php - EntityQueryDynamicReturnTypeExtension::getTypeFromMethodCall in vendor/
mglaman/ phpstan-drupal/ src/ Type/ EntityQuery/ EntityQueryDynamicReturnTypeExtension.php - EntityQueryDynamicReturnTypeExtension::isMethodSupported in vendor/
mglaman/ phpstan-drupal/ src/ Type/ EntityQuery/ EntityQueryDynamicReturnTypeExtension.php - EntityQueryHasAccessCheckRule::processNode in vendor/
mglaman/ phpstan-drupal/ src/ Rules/ Drupal/ EntityQuery/ EntityQueryHasAccessCheckRule.php
File
-
vendor/
lullabot/ php-webdriver/ lib/ WebDriver/ Execute.php, line 19
Namespace
WebDriverView source
class Execute extends AbstractWebDriver {
/**
* {@inheritdoc}
*/
protected function methods() {
return array();
}
/**
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. (asynchronous)
*
* @param array{script: string, args: array} $jsonScript
*
* @return mixed
*/
public function async(array $jsonScript) {
$jsonScript['args'] = $this->serializeArguments($jsonScript['args']);
$result = $this->curl('POST', '/async', $jsonScript);
return $this->unserializeResult($result['value']);
}
/**
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. (synchronous)
*
* @param array{script: string, args: array} $jsonScript
*
* @return mixed
*/
public function sync(array $jsonScript) {
$jsonScript['args'] = $this->serializeArguments($jsonScript['args']);
$result = $this->curl('POST', '/sync', $jsonScript);
return $this->unserializeResult($result['value']);
}
/**
* Serialize script arguments (containing web elements and/or shadow roots)
*
* @see https://w3c.github.io/webdriver/#executing-script
*
* @param array $arguments
*
* @return array
*/
protected function serializeArguments(array $arguments) {
foreach ($arguments as $key => $value) {
if ($value instanceof LegacyElement) {
$arguments[$key] = [
LegacyElement::LEGACY_ELEMENT_ID => $value->getID(),
];
}
elseif ($value instanceof Element) {
$arguments[$key] = [
Element::WEB_ELEMENT_ID => $value->getID(),
];
}
elseif ($value instanceof Shadow) {
$arguments[$key] = [
Shadow::SHADOW_ROOT_ID => $value->getID(),
];
}
elseif (is_array($value)) {
$arguments[$key] = $this->serializeArguments($value);
}
}
return $arguments;
}
/**
* Unserialize result (containing web elements and/or shadow roots)
*
* @param mixed $result
*
* @return mixed
*/
protected function unserializeResult($result) {
$element = is_array($result) ? $this->makeElement($result) : null;
if ($element !== null) {
return $element;
}
if (is_array($result)) {
foreach ($result as $key => $value) {
$result[$key] = $this->unserializeResult($value);
}
}
return $result;
}
/**
* Factory method for elements
*
* @param array $value
*
* @return \WebDriver\Element|\WebDriver\Shadow|null
*/
protected function makeElement($value) {
if (array_key_exists(LegacyElement::LEGACY_ELEMENT_ID, $value)) {
$identifier = $value[LegacyElement::LEGACY_ELEMENT_ID];
return new LegacyElement($this->getIdentifierPath('/element/' . $identifier), $identifier);
}
if (array_key_exists(Element::WEB_ELEMENT_ID, $value)) {
$identifier = $value[Element::WEB_ELEMENT_ID];
return new Element($this->getIdentifierPath('/element/' . $identifier), $identifier);
}
if (array_key_exists(Shadow::SHADOW_ROOT_ID, $value)) {
$identifier = $value[Shadow::SHADOW_ROOT_ID];
return new Shadow($this->getIdentifierPath('/shadow/' . $identifier), $identifier);
}
return null;
}
/**
* {@inheritdoc}
*/
protected function getIdentifierPath($identifier) {
return preg_replace('~/execute$~', '', $this->url) . $identifier;
// remove /execute from path
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AbstractWebDriver::$curlService | private | property | Curl service | ||
AbstractWebDriver::$transientOptions | private | property | Transient options | ||
AbstractWebDriver::$url | protected | property | URL | ||
AbstractWebDriver::assertSerializable | private | function | Sanity check | ||
AbstractWebDriver::curl | protected | function | Curl request to webdriver server. | ||
AbstractWebDriver::getCurlService | public | function | Get curl service | ||
AbstractWebDriver::getRequestMethod | private | function | Get default HTTP request method for a given WebDriver command | ||
AbstractWebDriver::getTransientOptions | public | function | |||
AbstractWebDriver::getURL | public | function | Returns URL to Selenium server | ||
AbstractWebDriver::obsoleteMethods | protected | function | Return array of obsolete method names and corresponding HTTP request methods | 4 | |
AbstractWebDriver::offsetGet | private | function | Extract value from result | ||
AbstractWebDriver::setCurlService | public | function | Set curl service | ||
AbstractWebDriver::setTransientOptions | public | function | Set transient options | ||
AbstractWebDriver::__call | public | function | Magic method that maps calls to class methods to execute WebDriver commands | 1 | |
AbstractWebDriver::__construct | public | function | Constructor | 3 | |
AbstractWebDriver::__toString | public | function | Magic method which returns URL to Selenium server | ||
Execute::async | public | function | Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. (asynchronous) | 1 | |
Execute::getIdentifierPath | protected | function | 1 | ||
Execute::makeElement | protected | function | Factory method for elements | ||
Execute::methods | protected | function | Return array of supported method names and corresponding HTTP request methods | Overrides AbstractWebDriver::methods | 1 |
Execute::serializeArguments | protected | function | Serialize script arguments (containing web elements and/or shadow roots) | ||
Execute::sync | public | function | Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. (synchronous) | 1 | |
Execute::unserializeResult | protected | function | Unserialize result (containing web elements and/or shadow roots) |