Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the W3C webdriver spec #293

Closed
stof opened this issue Sep 24, 2018 · 36 comments
Closed

Support the W3C webdriver spec #293

stof opened this issue Sep 24, 2018 · 36 comments

Comments

@stof
Copy link
Member

stof commented Sep 24, 2018

Support for the JsonWire selenium protocol is fading out in favor of the W3C spec:

We will have some work to do to make this happen.

The instaclick/php-webdriver library that we are using has a beta version of 2.0 which adds support for interacting with a W3C server. But they won't provide an abstraction layer to make the same code work for both variants (see instaclick/php-webdriver#84). It will be up to our code to choose the right way (and we will need instaclick/php-webdriver#86 to be able to know which one we need).
Due to the fact that we expose the webdriver session to userland, we would have to consider this upgrade as a BC break.

Another option could be to migrate to facebook/webdriver, which seems a bit more popular this days (https://packagist.org/?query=webdriver). It is currently adding support for the W3C spec (WIP is at php-webdriver/php-webdriver#560), and does so by abstracting the differences internally).
Doing such migration would also require making it a major release, as we would change the API we expose when exposing the session.

@stof
Copy link
Member Author

stof commented Sep 24, 2018

#288 was created to refer to the first solution for this topic (but does not describe the implication, and does not seem to care about the W3C support in the PR implementing it)

@stof
Copy link
Member Author

stof commented Sep 24, 2018

#287 should be done first before this work (we should switch to Chrome on Travis, as there is no way to run recent Firefox versions with the JsonWire protocol).

@stof
Copy link
Member Author

stof commented Oct 3, 2018

The more I look at instaclick/php-webdriver 2 "supporting" the WEC protocol (currently in RC), the more I think we should rather migrate to the facebook package (for which the PR supporting the W3C protocol inside their abstraction is almost ready AFAICT).

@stof
Copy link
Member Author

stof commented Oct 3, 2018

Btw, if we look at https://packagist.org/packages/instaclick/php-webdriver/dependents and the download counts on https://packagist.org/?query=webdriver, I think most of the downloads of instaclick/php-webdriver are coming from Mink using it (our driver has 11 176 049 downloads, the library has 11 517 849, so this only means 340k downloads not coming from us, which is 3%).
Among the 12 packages depending on instaclick/php-webdriver on Packagist, here is my analysis:

  • 1 is us
  • 2 are (abandoned) forks of us, (one direct fork, and a ghost-driver which duplicated our codebase instead of depending on us)
  • 3 are about locking exact versions of deps in the Drupal ecosystem and so are related to us (as Drupal is using Mink)
  • 1 is an abandoned experiment from the Laravel ecosystem, but laravel/dusk has been based on the facebook library instead.
  • 1 is a fork of the previous experiment
  • the remaining 4 look abandoned (last commits either in 2016 or 2014)

So we are the only ones keeping instaclick/php-webdriver alive in the open.

@aik099
Copy link
Member

aik099 commented Oct 3, 2018

#293 (comment)

Unfortunately Facebook Web Driver is now requiring PHP 7 and that was main reason why PR still isn't merged.

@stof
Copy link
Member Author

stof commented Oct 4, 2018

@aik099 as we need to make a new major release of the driver anyway, I'm fine with requiring PHP 7.1+ for it. All older PHP versions will be EOLed by the end of December.

People really wanting to use PHP 5.x could still use Selenium2Driver 1.x and use Chrome (or another browser with a driver supporting the legacy protocol)

@aik099
Copy link
Member

aik099 commented Oct 4, 2018

Agreed. We'll then have new driver require PHP 7.1, but Mink itself stays with current 5.x requirement.

@stof
Copy link
Member Author

stof commented Oct 4, 2018

Well, Mink itself will probably bump its own requirement in the future too, but I don't have a roadmap for that (as long as we don't make changes benefiting from it, there is no strong need)

@nirbhaypatil
Copy link

nirbhaypatil commented Oct 9, 2018

just wanted to know how to use instaclick/php-webdriver:2.0.0-RC2 with mink and mink extension ?
dependencies mismatch error comes up.

{
"require": {
"behat/behat":"~3",
"behat/mink": "1.7.1",
"behat/mink-extension": "2.2",
"behat/mink-selenium2-driver": "1.3.1",
"behat/mink-goutte-driver": "1.2.1",
"drupal/drupal-extension":"3.1.5",
"sensiolabs/behat-page-object-extension": "dev-master"
},
"config": {
"bin-dir": "bin/"
}
}

Your requirements could not be resolved to an installable set of packages.

@stof
Copy link
Member Author

stof commented Oct 9, 2018

currently, you cannot do it directly.

@nirbhaypatil
Copy link

nirbhaypatil commented Oct 10, 2018

even with facebook/webdriver + minkextension?
can you suggest other ways to do .

@stof
Copy link
Member Author

stof commented Oct 10, 2018

I don't understand your question. You asked whether you can use instaclick/php-webdriver:2.0.0-RC2, and now you say even with facebook/webdriver ?. I don't see how they are related.

@nirbhaypatil
Copy link

Sorry about confusion ,my question is
Can we use

  1. mink + minkextension + instaclick/php-webdriver:2.0.0-RC2
    OR
  2. mink + minkextension + facebook/webdriver
    to execute tests on firefox > 48

@stof
Copy link
Member Author

stof commented Oct 10, 2018

none of that is possible today, which is precisely what this issue is about:

So we are still discussing in which direction we want to rewrite the driver (supporting the W3C spec on top of instaclick/php-webdriver:2 also involves lots of rewriting in the driver).

@oleg-andreyev
Copy link
Contributor

@stof recently we've been trying to migrate this library to facebook/php-webdriver, mostly because of syn.js which bundled into this library and because instaclick/php-webdriver is not supported that actively.

So far my results:
Diff: master...oleg-andreyev:master
Travis Build (with Chrome): https://travis-ci.org/oleg-andreyev/MinkSelenium2Driver/jobs/462514905
Travis Build (with FF): https://travis-ci.org/oleg-andreyev/MinkSelenium2Driver/jobs/462514904
Travis: https://travis-ci.org/oleg-andreyev/MinkSelenium2Driver/builds/462514900

There are few issues with Chrome eg: Keyboard event, but it it's related to assert of driver-testsuite.
Also there are issues with facebook/webdriver and with FF

@phil-davis
Copy link

Note: chrome+chromedriver 75 has recently come out and now defaults to w3c
So now I think MinkSelenium2Driver users need to set chromeOption w3c to false

Also see SeleniumHQ/docker-selenium#922 where I am having this trouble with the latest https://github.com/SeleniumHQ/docker-selenium 3.141.59-palladium which has chrome 75.

@AlexSkrypnyk
Copy link

AlexSkrypnyk commented Jun 6, 2019

@phil-davis Looks like we were debugging this at the same time :))

This is the full fix in behat.yml:

  extensions:
    Behat\MinkExtension:
      selenium2:
         capabilities: { "browser": "chrome", "version": "*", "marionette": true, "extra_capabilities": { "chromeOptions": { "w3c": false } } }

Until https://github.com/instaclick/php-webdriver implements support for w3c protocol, we need to use the workaround above.

@phil-davis
Copy link

@alexdesignworks I have been trying that in owncloud/core#35445
In BEHAT_PARAMS I end up with

"capabilities": {"marionette":null, "browser": "chrome", "platform": "Linux", "name": "owncloud/core - ", "extra_capabilities": {"chromeOptions":{"w3c":false},"maxDuration":"3600"}}

https://drone.owncloud.com/owncloud/core/18090/681

But I get a WebDriver Exception:

    When user "user1" logs in using the webUI                                                           # WebUILoginContext::theUserLogsInUsingTheWebUI()
      WebDriver\Exception\CurlExec: Webdriver http error: 400, payload :{"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"#0 0x55c24baff299 \u003Cunknown>\n"}} in /drone/src/vendor-bin/behat/vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:155
      Stack trace:
      #0 /drone/src/vendor-bin/behat/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(132): WebDriver\Exception::factory(-1, 'Webdriver http ...')
      #1 /drone/src/vendor-bin/behat/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php(218): WebDriver\AbstractWebDriver->curl('POST', '/click', NULL)
      #2 /drone/src/vendor-bin/behat/vendor/instaclick/php-webdriver/lib/WebDriver/Container.php(224): WebDriver\AbstractWebDriver->__call('click', Array)
      #3 /drone/src/vendor-bin/behat/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php(781): WebDriver\Container->__call('click', Array)
      #4 /drone/src/vendor-bin/behat/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php(769): Behat\Mink\Driver\Selenium2Driver->clickOnElement(Object(WebDriver\Element))
      #5 /drone/src/vendor-bin/behat/vendor/behat/mink/src/Element/NodeElement.php(153): Behat\Mink\Driver\Selenium2Driver->click('(//html/.//*[./...')
      #6 /drone/src/tests/acceptance/features/lib/LoginPage.php(71): Behat\Mink\Element\NodeElement->click()
      #7 /tmp/ProxyManagerGeneratedProxy__PM__PageLoginPageGenerated6312256563dff9947346b9792a817253.php(34): Page\LoginPage->loginAs('user1', '1234', 'FilesPage')

Any clues are welcome!

@leymannx
Copy link

Temporarily pinning to Chromedriver 74 seems to be the best workaround for now. See https://github.com/acquia/blt/pull/3708/files/9aa7d8cf28025b957f1e628d9c6de6e63a0a5aac#diff-586532737a140c4f8e2079e2c33fc217

@jimarasim
Copy link

When setting w3c to false, use "goog:chromeOptions" instead of "chromeOptions"
extra_capabilities:
"goog:chromeOptions":
w3c:
false

Hoping this issue is resolved before Chrome decides to no longer support jsonwire at all.

@emodric
Copy link

emodric commented Jul 31, 2019

Is it only me, or this started to work on its own in latest versions of Chrome Driver 75 and even in the new v76?

@phil-davis
Copy link

I am using selenium/standalone-chrome-debug in drone-docker. latest of that still fails, and I have to specify 3.141.59-oxygen

@emodric
Copy link

emodric commented Aug 1, 2019

Here is a build that works with latest chrome and chrome driver that previously failed: https://travis-ci.org/netgen-layouts/layouts-core/jobs/566143335

Previous failing build: https://travis-ci.org/netgen-layouts/layouts-core/jobs/545643705

@shwetaneelsharma
Copy link

@alexdesignworks Thanks a ton for this solution #293 (comment)
However, does it work for headless execution too? I am only able to get it working for browser-based execution

@shwetaneelsharma
Copy link

shwetaneelsharma commented Aug 9, 2019

I have got this working on Chrome 75 in headless mode by using the following configuration:
`

Behat\MinkExtension:  
    base_url: "your_base_url"  
    browser_name: 'chrome'
    goutte: ~
    javascript_session: selenium2
    selenium2:
      wd_host: http://127.0.0.1:4444/wd/hub
      capabilities:
        browser: chrome
        extra_capabilities:
          chromeOptions:
            args: ['--headless', '--disable-gpu']
            w3c: false`

@jimarasim
Copy link

With Chrome 76.0.3809.100 / Chromedriver Version = 76.0.3809.68 '--headless' only works for me if "chromeOptions:" is "goog:chromeOptions"; otherwise, it still runs headed.

@marcusanderss
Copy link

The problem is possible 'fix' it by inserting the following 3 lines at the start of the webDriverElement function in Behat, vendor/instaclick/php-webdriver/lib/WebDriver/Container.php:
protected function webDriverElement($value)
{
if (!array_key_exists('ELEMENT', $value)) {
$value['ELEMENT'] = $value['element-6066-11e4-a52e-4f735466cecf'];
}

@robbieaverill
Copy link

Hi everyone, facebook/php-webdriver support for the W3C protocol is nearly ready: php-webdriver/php-webdriver#560 (comment). Would be worth testing an update to use it now? I'm happy to assemble a PR from @tractorcow's fork (to use facebook/php-webdriver) if it would help as well.

@AntoscencoVladimir
Copy link

When setting w3c to false, use "goog:chromeOptions" instead of "chromeOptions"
extra_capabilities:
"goog:chromeOptions":
w3c:
false

Hoping this issue is resolved before Chrome decides to no longer support jsonwire at all.

Thank you!

@Scobee
Copy link

Scobee commented Oct 26, 2021

@stof can you please tell me if latest version of Edge & Firefox are supported with Mink selenium2driver, using selenium 4 ?

@stof
Copy link
Member Author

stof commented Aug 6, 2024

Closing this as we have created the mink/webdriver-classic-driver package.

@stof stof closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.