Skip to content

Commit

Permalink
fixes #80 - support new WebDriver spec element ID
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed Oct 4, 2017
1 parent 6fa9594 commit be87042
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/WebDriver/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*/
abstract class Container extends AbstractWebDriver
{
const LEGACY_ELEMENT_ID = 'ELEMENT';
const WEBDRIVER_ELEMENT_ID = 'element-6066-11e4-a52e-4f735466cecf';

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -203,12 +206,19 @@ public function locate($using, $value)
*/
protected function webDriverElement($value)
{
return array_key_exists('ELEMENT', (array) $value)
? new Element(
$this->getElementPath($value['ELEMENT']), // url
$value['ELEMENT'] // id
)
: null;
if (array_key_exists(self::LEGACY_ELEMENT_ID, (array) $value)) {
return new Element(
$this->getElementPath($value[self::LEGACY_ELEMENT_ID]), // url
$value[self::LEGACY_ELEMENT_ID] // id
);
}

if (array_key_exists(self::WEBDRIVER_ELEMENT_ID, (array) $value)) {
return new Element(
$this->getElementPath($value[self::WEBDRIVER_ELEMENT_ID]), // url
$value[self::WEBDRIVER_ELEMENT_ID] // id
);
}
}

/**
Expand Down

4 comments on commit be87042

@cweiske
Copy link

Choose a reason for hiding this comment

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

I actually patched this myself after needing 3 hours to figure out why firefox does not work and chrome does. Only then, when making the pull request, I saw that this is already in master. Could you please release that soon, either by releasing 2.0.0 or putting that patch back into a 1.4.6?

@robocoder
Copy link
Member Author

Choose a reason for hiding this comment

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

@cweiske 2.0.0-BETA tagged

@cweiske
Copy link

Choose a reason for hiding this comment

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

and a beta is never installed because most projects use stable dependency versions.

@robocoder
Copy link
Member Author

Choose a reason for hiding this comment

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

Well, the W3C WebDriver spec is still in flux (only a recommendation right now) and isn't widely implemented by other web drivers.

I'm open to creating a 1.x branch and backporting, but I don't have the time to do extensive regression testing with the translation layer enabled vs disabled.

Please sign in to comment.