Closed mvorisek closed 2 years ago
Thanks for the PR. This looks like a compat-buster on the 1.x branch since php-webdriver has historically been a (largely) thin wrapper around the W3C and legacy WebDriver protocols.
Can you provide an example of the method call that demonstrates (args and return value) why this is needed?
W3C and legacy WebDriver protocols
Yes, it is supported offcially, see facebook impl. https://github.com/php-webdriver/php-webdriver/blob/8ffa927b270e932449e8015abf4d38bb0eff24b7/lib/Remote/RemoteWebDriver.php#L666
My question is, can this PR target 1.x? LOC will be low, no BC break.
Example usage:
// expecting:
// a) $wdSession with working \WebDriver\Session driver
// b) loaded webpage with at least one <div> element with some ID attribute
$element = $wdSession->element('xpath', '//div'); // returns instance of \WebDriver\Element
$jsResult = $wdSession->execute([
'script' => 'return (function (elem) { return [elem, elem.id]; })(arguments[0])',
'args' => [$element],
]);
// will dump array with:
// [0] (new) instance of \WebDriver\Element to demonstrate conversion from php to webdriver and back
// [1] ID of given element extracted by JS
var_dump($jsResult);
Thanks for fleshing that out.
Thanks. This has been tagged as 1.4.12. I'll try to port to the master branch later tonight.
See 8bb204d8
Thank you ❤️
Session::execute
andSession::execute_async
methods must convert the web driver element to object the same way asContainer::element
andContainer::elements
methods do.