Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions lib/WebDriver/AbstractWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
$url .= '/' . $parameters;
}

$this->assertNonObjectParameters($parameters);

list($rawResult, $info) = ServiceFactory::getInstance()->getService('service.curl')->execute($requestMethod, $url, $parameters, $extraOptions);

$httpCode = $info['http_code'];
Expand Down Expand Up @@ -197,6 +199,32 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
);
}

/**
* @param mixed $parameters
*/
private function assertNonObjectParameters($parameters)
{
if ($parameters === null || is_scalar($parameters)) {
return;
}

if (is_array($parameters)) {
foreach ($parameters as $value) {
$this->assertNonObjectParameters($value);
}

return;
}

throw WebDriverException::factory(
WebDriverException::UNEXPECTED_PARAMETERS,
sprintf(
"Unable to serialize non-scalar type %s",
is_object($parameters) ? get_class($parameters) : gettype($parameters)
)
);
}

/**
* Magic method that maps calls to class methods to execute WebDriver commands
*
Expand Down
8 changes: 7 additions & 1 deletion lib/WebDriver/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,13 @@ private function serializeArguments(array $arguments)
foreach ($arguments as $key => $value) {
// Potential compat-buster, i.e., W3C-specific
if ($value instanceof Element) {
$arguments[$key] = [Container::WEBDRIVER_ELEMENT_ID => $value->getID()];
// preferably we want to detect W3C support and never set nor parse
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is W3C support somehow reported & nicely detectable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a w3c flag at one point but only on master. I'll need to revisit.

// LEGACY_ELEMENT_ID, until detection is implemented, serialize to both
// variants, tested with Selenium v2.53.1 and v3.141.59
$arguments[$key] = [
Container::WEBDRIVER_ELEMENT_ID => $value->getID(),
Container::LEGACY_ELEMENT_ID => $value->getID(),
];
continue;
}

Expand Down