Problem/Motivation
This is a follow-on from #3240792: Use lullabot/mink-selenium2-driver and lullabot/php-webdriver for functional browser testing. This issue enables W3C-compliant webdriver testing, thereby allowing Drupal's core tests, contrib module tests and custom tests to be run against modern browsers using selenium.
Proposed resolution
- Fix Drupal code that uses non-W3C commands to use work on both W3C and non-W3C webdrivers.
- Test against both W3C and non-W3C
Remaining tasks
Decide what mix of W3C and non-W3C tests we need to run.
All nightwatch and functional JS tests to usingselenium/standalone-chrome:latest- this is inline with our browser support policy and if it becomes an issue we will pin it to a verion.Decide whether to add a manual job to run tests against Firefox
This has to be a follow-up there are issues we need to resolve.Decide whether to run W3C tests using drupalci/chromedriver or selenium/chromium. Our chromedriver image gets out of date and unmaintained quickly. This would help ensure Drupal is being tested on up-to-date browsers. The Selenium image also drops jsonwire support, which chromedriver still directly supports. This would force us to use the W3C standard, and allow us to test on other browsers in future.
Usingselenium/standalone-chrome:latestis inline with our browser support policy and we no longer have to maintain an image that gets out of date as quickly as we update it.Decide what to run Performance tests and Test-only changes jobs using
Moved to W3C / selenium
Followups:
- #3462680: Add ability to test on Firefox using selenium
- #3462681: Add W3C compliant JS testing
- #3462682: Deprecate non-W3C compliant testing
- #3463286: Fix selenium performance/stampede issues in gitlab config and BrowserTestBase
User interface changes
None
API changes
\Drupal\FunctionalJavascriptTests\WebDriverCurlService is deprecated. This was added in #2942900-50: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver. @longwave is pretty sure this has been fixed by https://issues.chromium.org/issues/42321790
Data model changes
None
Release notes snippet
Drupal core now tests using selenium/standalone-chrome:latest via a W3C compliant webdriver. To enable W3C mode in WebDriverTestBase tests, the MINK_DRIVER_ARGS_WEBDRIVER environment variable must pass "w3c": true in the options. To enable W3C mode in Nightwatch tests, the DRUPAL_TEST_WEBDRIVER_W3C environment variable must to be set to true.
Issue fork drupal-3421202
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3421202-concurrent-w3c-and-non-w3c-testing-11.0.x
changes, plain diff MR !8996
- 3421202-concurrent-w3c-and-non-w3c-testing-10.4.x
changes, plain diff MR !8995
- 3421202-on-top-of-3240792
changes, plain diff MR !6584
- 3421202-concurrent-w3c-and-non-w3c-testing
changes, plain diff MR !8735
- 3421202-use-seleniumstandalone-chrome-instead
compare
Comments
Comment #4
alexpottCrediting @justafish as a tonne of the effort here is theirs.
Comment #5
smustgrave commentedCan you rerun the javascript tests? Want to make sure they aren't random but even I request access I can't rerun.
Comment #6
alexpott@smustgrave it's definitely not random.
Comment #7
smustgrave commentedGlad I asked!
Comment #8
justafishComment #9
catchI've started using/recommending this locally too fwiw - a lot of people (more than 2-3 I could name) have trouble with the drupalci one which they don't run into with the selenium one.
Comment #10
andypostComment #11
justafishI've split the part about upgrading the tests to https://www.drupal.org/project/drupal/issues/3432099 as we can test this is working using geckodriver
Comment #12
catchAfter #3240792: Use lullabot/mink-selenium2-driver and lullabot/php-webdriver for functional browser testing I wasn't able run test locally with selenium/standalone-chrome, which I'd otherwise been using successfully for months, gave up trying to debug it and went back to the drupalci image (which has been working OK). I haven't seen anyone else run into issues since that commit, but presumably people will start to switch over if we switch gitlab, so just making a note here in case other people do indeed run into issues down the line.
Comment #13
andyf commentedJust to chime in re #12 I was seeing exactly the same thing (see https://github.com/ddev/ddev-selenium-standalone-chrome/issues/41). It appears that
\WebDriver\WebDriver::session()is checking for thew3cflag one level higher up than where it's being set. I'm not sure if the issue should be fixed inlullabot/php-webdriveror by changing the capabilities we're passing. Locally I've just changed the capabilities, but I've seen plenty of examples on Stack Exchange etc. of thew3cflag being withingoog:chromeOptionsand I can't find a canonical reference on the matter.Comment #14
tintoI was seeing the same problem as #12, running test on my local machine with Drupal 11.x-dev.
I fixed it by implementing the workaround posted in #13 - I simply replaced line 15 in
config.selenium-standalone-chrome.yamlto this:Thank you @AndyF!
Comment #17
longwaveThe change record needs to be written but otherwise the tests are green so marking NR, hopefully someone else familiar with Chrome testing can take a look.
We still need to decide how to deprecate non-W3C mode and what to do about tests in that time, do we run them in both modes or for core do we just switch to W3C mode only?
Comment #18
alexpottMy plan was to run a limited subset tests using non-W3C mode. while we still support it - i.e. until Drupal 12 and then in Drupal 12 we should only support W3C testing.
I think we should also add a manual job to run tests using Firefox.
Comment #19
andypostnice idea, there's
selenium/standalone-firefoximageComment #20
alexpottComment #21
alexpottComment #23
andypostLocally in docker I got few tests running fine using Firefox image with following arguments
MINK_DRIVER_ARGS_WEBDRIVER: '["firefox", {"browserName":"fixrefox","moz:firefoxOptions":{"args":["--headless"]}}, "http://browser:4444"]'Comment #24
alexpottFixed up issue summary and title to be inline with current MR. Also added more to remaining tasks for things that we need to decide.
Comment #25
alexpottComment #26
alexpottComment #27
andypostSomehow FIrefox tests are x2 faster then selenium jobs
Comment #28
alexpott@andypost that's not the case... they were skipping every test :D we should fail instead of skip when a WebDriverTestBase test fails to connect to a browser. Once I fixed the webdriver json string we can see that the tests are about the same speed - see https://git.drupalcode.org/project/drupal/-/pipelines/227038
Also Firefox has a different approach when elements are not in the viewport and you do a click - see https://stackoverflow.com/questions/44777053/selenium-movetargetoutofbou... - I think we should address this in our webdriver in the same way that webdriver-classic-driver does - see https://github.com/minkphp/webdriver-classic-driver/blob/73ad0b6ce21cf69...
Comment #29
alexpottLolz previous me pointed out that PHPUnit would skip if something required by the test is not available - see #3187577-11: FunctionalJavascript tests should fail when ChromeDriver is not running - I guess that comment is still correct. But it would be great if somehow the reason things are skipped was actually listed in the test output.
Comment #30
alexpottTo be fair you can see the skipped tests in the report on gitlab - see https://git.drupalcode.org/project/drupal/-/pipelines/227006/test_report
Comment #31
andypostThanks! it explains difference (all skipped for ff)
btw performance metrics also could be collected from FF, at least it has
tracingout of box and allows to enable dev-tools (even via remote somehow) and get better details... for follow-upComment #32
andypostMoreover it makes sense to explore optimizations related to
--headlessmode in browsersComment #34
alexpottAnswered questions in the issue summary and update MR to reflect the answers.
Comment #35
alexpottCreated the follow-ups.
I think this is ready for review.
Comment #36
alexpottOne thing for reviewers to not is the move from 2 runners to 4 runners for the JS testing job. This is because testing on selenium is slower. There is not much we can do about this as far as I can see and the benefits of actually testing against current browsers and not maintaining our own chromedriver image are large.
Comment #37
catchAn interesting thing with the four vs. two javascript runners is that overall time still seems to be constrained by the slowest individual tests (either Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest or Drupal\Tests\ckeditor5\FunctionalJavascript\SourceEditingTest seem to be the longest running) and overall run duration is also similar to what it is now. I would kind of have expected the bottleneck to shift to the number of http requests away from installing Drupal, although maybe those tests also do loads of http requests too.
I wonder if we're hitting concurrency/cpu limits. However anything like that we can explore in a follow-up - four runners seems fine and there's no overall regression in the pipeline feedback.
Comment #38
longwaveIf we're just moving Nightwatch entirely to w3c mode then we can drop the separate
seleniumenvironment and just turn on the w3c switch in thedefaultenvironment.Comment #39
longwaveAdded some nits/comments to the MR.
Comment #40
alexpottI've run
core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php --filter testMultipleReplacementson both old chromedriver and selenium and the test fails with 2000 and the fix from #3390178: big_pipe sometimes fails to load blocks reverted so reducing to 2000 seems fine and we don't need a comment. That was useful to explain why we have reduced it but will be meaningless in the future.I've answered the rest of @longwave's feedback on the MR - but back to needs review. I think we need to add a nightwatch section to the MR.
Comment #41
longwaveLet's update the CR for Nightwatch and also add a followup to investigate Selenium switches, otherwise this is ready to go.
Comment #42
alexpottAdded testing performance follow-up as requested.
Comment #43
alexpottI've tweaked the way W3C mode is set in nightwatch to negate the need for an extra environment. I realised that the selenium environment was missing the merge of chrome args etc... and changing how this is set up seemed best.
I've also update the Cr to reflect the test configuration changes someone would need to make to use W3C compliant browser testing.
Comment #44
alexpottComment #45
alexpottComment #46
longwaveAlright, let's ship this - tests are green, and the test and configuration changes are the minimum required to enable W3C mode. This then unlocks some future improvements including hopefully being able to upgrade Nightwatch to a more recent version.
Comment #48
catchCommitted/pushed to 11.x, thanks!
If this does indeed make functional js tests a lot slower, it may break the performance tests dashboard. I've opened #3463351: Consolidate Umami performance tests which should cover that.
Alongside that, I also opened #3463456: Consolidate ckeditor5's FunctionalJavascript tests for core's other longest running functional js tests.
I think we should open a follow-up to revisit concurrency once those two issues are in, since they may be enough to lower it again, I'll open it postponed now.
I am assuming that we don't want to try to backport this to 10.4.x, but if we do, please re-open with a backport MR.
edit: #3463286: Fix selenium performance/stampede issues in gitlab config and BrowserTestBase covers the concurrency follow-up.
Comment #50
alexpottI think we do want to get this in 10.4.x and maybe even get the test base class changes into 10.3.x and 11.x so that projects can move to W3C driver testing early. I'll open when I get round to making the MR for 10.4.x
Comment #51
catchPerformance test job is broken since this went in #3463534: Performance test gitlab job is broken - revert to use chromedriver.
Comment #54
alexpottCreated two MRs - one for 11.0.x and one for 10.4.x (and 10.3.x) so we can backport this so that projects can start the process of testing on modern browsers...
Comment #55
andypostThe only question is deprecation message, let's update it to "deprecated in 10.0.4 and removed in 12.0.0"
Comment #56
alexpott@andypost - ah the best thing to do here is to remove the deprecation... makes core/tests/Drupal/Tests/Core/Test/PhpUnitCliTest.php pass on 10.x without modification which is nice.
Comment #57
longwaveAdded some comments about being slightly more conservative in the 11.0/10.4 backports. Should this also go back to 10.3 to keep in sync?
Comment #58
alexpottIt'd be great if this went into 10.3 too.
Comment #59
alexpottGreat review point @longwave - I've addressed them on both 10.4.x and 11.0.x branches. The 10.4.x also works on 10.3.x
Comment #60
longwaveVarious tests are broken.
Comment #61
alexpottSuperfluous dump() doh!
Comment #62
longwave#3463286: Fix selenium performance/stampede issues in gitlab config and BrowserTestBase landed so that change needs to be incorporated here now.
Unit tests also failed on 10.4.x in WebAssertTest.
Comment #63
wim leersWhat's the status of this? #47 landed, but then this issue was reopened, without a revert. The two change records are still .
EDIT: ah I guess #3463534: Performance test gitlab job is broken - revert to use chromedriver is the partial revert?
Can contrib follow core's example/lead? Should it?
Comment #64
catch@Wim This was re-opened for backport, not due to regressions.
However #3463286: Fix selenium performance/stampede issues in gitlab config and BrowserTestBase landed in 11.x, and needs to be incorporated into the backport here to avoid serious performance/instability issues on pipelines. The gitlab YAML files have diverged quite a lot between branches so it is a real backport not just a cherry-pick unfortunately.
Contrib w3c testing is happening in #3463894: Update templates so 11.0 is the default/current branch.
Comment #66
andypostIt looks like a blocker for deprecation #3462682: Deprecate non-W3C compliant testing
PS: not clear state of w3c testing in contrib as it reported blocked too #3462681: Add W3C compliant JS testing
Comment #67
longwaveWe never finished the backport, I think it's too late to bother with that now. Let's just keep both sets of tests in 11 and then remove non-w3c testing in 12.
Comment #69
quietone commentedThis was released with 11.1