Separated from the #2942900-85: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver.
Problem/Motivation
The ultimate goal is convert all the existing PhantomJS tests over to using Selenium driver. But this is not such a simple process. And until it happened it would be great to provide an opportunity to create Selenium tests without having to adjust them in the future.
Now, to create a Selenium test, we need to do next:
<?php
...
+ use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
...
class MySeleniumTest extends JavascriptTestBase {
+ /**
+ * {@inheritdoc}
+ */
+ protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
...
In the future, when JavascriptTestBase will be deprecated, we need next:
<?php
...
- use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
- use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+ use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
...
- class MySeleniumTest extends JavascriptTestBase {
+ class MySeleniumTest extends WebDriverTestBase {
- /**
- * {@inheritdoc}
- */
- protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
...
The more we create the Selenium tests, the more such boring work will have to be done.
But why do may need Selenium to create tests? Why not just wait with PhantomJS? Here are a few flaws of PhantomJS (with all due respect to its creators):
- Very loyal verification of the visibility of the elements, as a result of which you can interact even with hidden elements. Example TestSettingSummariesContentType works with unvisible tab now.
- Incorrect visibility checking, as a result, sometimes you have to do an assert, relying on the class of elements, rather than on the isVisible() method. Example, FieldTest Waits when the item becomes visible by adding to the selector
[aria-hidden="false"]part. Otherwise, a random fails occurs. Because css-style used aria-* for display element. - Improper rendering of some modern elements (for example, you can not work with svg). We were able to provide a full test for #736066: ajax.js insert command sometimes wraps content in a div, potentially producing invalid HTML and other bugs only after switch to Selenium due to this problem.
- The problem with the imitation of typing (@Wim Leers found solution for it via deprecated js-event, but this is not exactly what you expect from the test-api tools).
- Unstable support
pressButton(), press(), clickLink(), click()methods. See #2936122-5: Find out why JavscriptTestBase occasionally needs a waitForElement on a normal page load. - There is no possibility of interaction during the test, in contrast to the Selenium, where you can put a breakpoint and continue experiments / researches manually in your favorite browser.
- The support of Phantom is officially terminated, there are not even suitable libraries for updating to the last PhantomJS version. Hardly many will have enough motivation to learn it from scratch, only to write a test on Drupal. Selenium is more promising in this regard (i hope).
Nota bene: Selenium is not ideal, it also has unpleasant or/and unusual features. See #2960784: Document a FAQ for Selenium tests. So this issue is not calling everyone to switch to it. Just provide a convenient way to write selenium tests for those who want use it now.
Proposed resolution
Provide WebDriverTestBase like #2942900-85: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver, but without deprecated JavascriptTestBase.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | interdiff-2942900-85-part-2.txt | 2.26 KB | Anonymous (not verified) |
| #2 | 2977386-2.patch | 11.42 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedvaplas created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedPatch from part-2 of #2942900-85: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver more thanks to the participants of this issues.
Also updated ImageFieldTestBase, that already using Selenium driver.
Comment #5
joachim commentedI think this is outdated -- WebDriverTestBase now exists.