Now that #2775653: JavascriptTests with webDriver is in both 8.5.x and 8.6.x we should convert all the existing phantomjs tests over to using seleniumdriver.

This can save a significant amount of testing costs as we'll be able to parallelize the tests instead of running them serially, as well as eventually drop support for phantomjs in drupalCI, since phantom is now abandonware.

Tasks:
- Add a new TestBaseClass that uses Webdriver
- Deprecate the old PhantomJS classes
- Convert the tests that can be converted safely
- Open followups for the tests that need work to be converted (see #13 for the different categories)
- Add a change record to indicate PhantomJS tests are now deprecated

CommentFileSizeAuthor
#131 interdiff-2942900.txt977 bytesdawehner
#131 2942900-131.patch93.06 KBdawehner
#127 interdiff-2942900.txt776 bytesdawehner
#127 2942900-127.patch93.08 KBdawehner
#125 interdiff-2942900.txt1.36 KBdawehner
#125 2942900-123.patch92.66 KBdawehner
#124 interdiff-2942900.txt15.91 KBdawehner
#124 2942900-123.patch107.21 KBdawehner
#113 interdiff-2942900-110-113.txt871 bytesmartin107
#113 2942900-113.patch91.62 KBmartin107
#110 2942900-110.patch97.26 KBmartin107
#105 2942900-104.patch90.8 KBjibran
#105 interdiff-40d970.txt799 bytesjibran
#102 2942900-102.patch90.02 KBlendude
#100 2942900-100.patch89.83 KBlendude
#94 interdiff-90-94.txt7.88 KBAnonymous (not verified)
#94 2942900-convert-js-to-webdriver-94.patch89.84 KBAnonymous (not verified)
#90 interdiff-89-90.patch862 bytesAnonymous (not verified)
#90 2942900-convert-js-to-webdriver-90.patch90.34 KBAnonymous (not verified)
#89 diff-patches-84-89.txt1.87 KBAnonymous (not verified)
#89 2942900-convert-js-to-webdriver-89.patch89.5 KBAnonymous (not verified)
#85 part5_js_concurrency.patch747 bytesMixologic
#85 part4_harder_conversions.patch35.19 KBMixologic
#85 part3_easy_conversions.patch38.56 KBMixologic
#85 part2_convert_jstb2wbtb.patch10.93 KBMixologic
#85 part1_webdriver_curl.patch5.27 KBMixologic
#84 2942900-convert-js-to-webdriver-84.patch89.5 KBMixologic
#83 interdiff-79-83.txt8.51 KBAnonymous (not verified)
#83 2942900-83.patch91.22 KBAnonymous (not verified)
#79 interdiff-74-79.txt2.01 KBAnonymous (not verified)
#79 2942900-79.patch88.87 KBAnonymous (not verified)
#78 interdiff-74-76.txt1.38 KBAnonymous (not verified)
#78 2942900-76-actually.patch88.23 KBAnonymous (not verified)
#74 2942900-74-actually.patch88.23 KBMixologic
#72 interdiff-63-74.txt13.55 KBAnonymous (not verified)
#72 2942900-74.patch86.71 KBAnonymous (not verified)
#72 interdiff-63-reroll.txt7.61 KBAnonymous (not verified)
#72 2942900-63-reroll.patch89.67 KBAnonymous (not verified)
#63 interdiff-57-63.txt9.99 KBAnonymous (not verified)
#63 2942900-63.patch92.89 KBAnonymous (not verified)
#61 interdiff-57-61.txt13.62 KBAnonymous (not verified)
#61 2942900-61.patch90.16 KBAnonymous (not verified)
#58 2942900-convert-js-to-webdriver-58.patch86.4 KBMixologic
#57 2942900-convert-js-to-webdriver-57.patch87.11 KBMixologic
#57 interdiff-57.txt1.1 KBMixologic
#55 2942900-convert-js-to-webdriver-55.patch86.95 KBMixologic
#53 2942900-convert-js-to-webdriver-52.patch86.95 KBMixologic
#53 interdiff-52.txt557 bytesMixologic
#51 2942900-convert-js-to-webdriver-51.patch86.9 KBMixologic
#50 2942900-convert-js-to-webdriver-50.patch86.2 KBMixologic
#50 interdiff-50.txt40.51 KBMixologic
#49 c1-2942900-selenium-tests-login.patch21.46 KBAnonymous (not verified)
#46 2942900-46.patch50.17 KBlendude
#46 interdiff-2942900-37-46.txt1.28 KBlendude
#37 interdiff-23.txt1.36 KBMixologic
#37 2942900-37.patch50.17 KBMixologic
#30 2942900-30.patch51.28 KBjibran
#30 interdiff-71d77d.txt2.47 KBjibran
#23 2942900-2944291-combined-23.patch52.82 KBjibran
#23 2942900-23.patch50.16 KBjibran
#23 interdiff-375ab7.txt7.61 KBjibran
#22 2942900-2944291-combined-22.patch52.52 KBjibran
#22 2942900-22.patch49.86 KBjibran
#18 2942900-18.patch49.86 KBlendude
#17 interdiff-17.txt599 bytesMixologic
#17 2942900-convert-js-to-webdriver-17.patch55.97 KBMixologic
#11 interdiff.txt1.09 KBMixologic
#11 2942900-convert-js-to-webdriver-11.patch55.73 KBMixologic
#9 interdiff.txt50.75 KBMixologic
#9 2942900-convert-js-to-webdriver-9.patch55.73 KBMixologic
#7 i2942900-convert-js-to-webdriver-7-interdiff.txt2.01 KBMixologic
#7 2942900-convert-js-to-webdriver-7.patch12.01 KBMixologic
#5 2942900-convert-js-to-webdriver-5.patch11.27 KBMixologic
#2 2942900-convert-js-to-webdriver-2.patch639 bytesMixologic

Comments

Mixologic created an issue. See original summary.

Mixologic’s picture

StatusFileSize
new639 bytes

This crude patch makes DrupalSelenium2Driver the default class just to see what tests will pass without any work, and which tests will need adjusting.

Mixologic’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2942900-convert-js-to-webdriver-2.patch, failed testing. View results

Mixologic’s picture

Status: Needs work » Needs review
StatusFileSize
new11.27 KB

This patch takes a BC breaking shortcut to run all of the javascriptTestBase tests as DrupalSelenium2Driver, and adjusts the breaking tests to use PhantomJS.

(There were 15 failing tests out of 63, with 48 that can be converted right away. We probably should have a "ModernJavascriptTestBase" instead of "LegacyJavascriptTestBase" for BC purposes

Of the 15 failing tests, there were a couple of abstract classes that extended JavascriptTestBase - OffCanvasTestBase, MediaSourceTestBase, and MediaJavascriptTestBase.

All of the tests that extended OffCanvasTestBase were failures, so I made OffCanvasTestBase itself extend LegacyJavascriptTestBase.

The other media tests were a combination of failures and passes, so it was simpler to directly set the $minkDefaultDriver class on those tests.

Status: Needs review » Needs work

The last submitted patch, 5: 2942900-convert-js-to-webdriver-5.patch, failed testing. View results

Mixologic’s picture

Status: Needs work » Needs review
StatusFileSize
new12.01 KB
new2.01 KB

Here's one with the missing use statements I forgot.

dawehner’s picture

+++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
@@ -16,10 +16,9 @@

@@ -16,10 +16,9 @@
   /**
    * {@inheritdoc}
    *
-   * To use a webdriver based approach, please use DrupalSelenium2Driver::class.
-   * We will switch the default later.
+   * To use a legacy phantomjs based approach, please use PhantomJSDriver::class.
    */
-  protected $minkDefaultDriverClass = PhantomJSDriver::class;
+  protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
 

Mh, I'm not sure we can actually do that :( Wouldn't this potentially break contrib tests? I wonder what for example @xjm thinks about it

Mixologic’s picture

StatusFileSize
new55.73 KB
new50.75 KB

Mh, I'm not sure we can actually do that

Yah, as I mentioned above:

This patch takes a BC breaking shortcut to run all of the javascriptTestBase tests as DrupalSelenium2Driver, and adjusts the breaking tests to use PhantomJS.

These were just some preliminary patches to figure out the scope and depth of the conversion requirements.

But what if we inverted the API : Make LegacyJavascriptTestBase into JavascriptTestBase, rename current JavascriptTestBase to WebDriverTestBase and rename all the classes that pass on WebDriver. Then the API is still there, still uses phantom, can be @deprecated, and we can easily convert our existing webdriver ready tests over.

There would just be those 4 weird media tests that dont inherit directly from JavascriptTestBase that would still need the driver class set directly on them (maybe we convert those first)

Perhaps this should be 2 patches, one to wrangle the api around, one to do the renames, but here's my current attempt to do both)

Status: Needs review » Needs work

The last submitted patch, 9: 2942900-convert-js-to-webdriver-9.patch, failed testing. View results

Mixologic’s picture

Status: Needs work » Needs review
StatusFileSize
new55.73 KB
new1.09 KB

Apparently if one uploads a patch on the form, then makes tweaks, reloads the issue, and re-uploads the same patch filename, it keeps the first patch. These were just some things that leaked through.

Anonymous’s picture

#11: Exactly, the substitution of files is really a dangerous thing. I have a similar case in #2891911-20: Random fail in Drupal\Tests\locale\Functional\LocaleTranslationUiTest::testStringTranslation. When the patch ends with a fail after this - it's a lucky chance. Much worse, if it does not cause visual problems. Then typing errors or accidental scraps may fall into the core. And your interdiff and conscience will be clear, because you really think that you posted a good patch.


We also have already discovered a useful stability effect from the new engine in #2936122: Find out why JavscriptTestBase occasionally needs a waitForElement on a normal page load. Therefore, the conversion of tests will definitely reduce the number of random failures due to pressButton(), press(), clickLink(), click() methods. Woot!
Mixologic’s picture

I did a failure analysis of the 15 remaining phantomjs tests that fail, and they fit into the following four categories:

1. They check the response code or headers and they shouldnt, as per https://www.drupal.org/node/2827014 (2 tests)

Drupal\FunctionalJavascriptTests\Ajax\AjaxFormPageCacheTest

    Behat\Mink\Exception\UnsupportedDriverActionException: Response headers are
    not available from Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver

Drupal\Tests\action\FunctionalJavascript\ActionFormAjaxTest

Behat\Mink\Exception\UnsupportedDriverActionException: Status code is not
    available from Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver

2. The test makes assumptions about visibility that is different under chrome than it was under phantomjs (4 tests)

Drupal\Tests\field_ui\FunctionalJavascript\EntityDisplayTest

Probably has to do with element visibility.
WebDriver\Exception\ElementNotVisible: element not visible: Element is not
    currently visible and may not be manipulated

Drupal\Tests\media\FunctionalJavascript\MediaDisplayTest

Probably has to do with element visibility.
WebDriver\Exception\ElementNotVisible: element not visible: Element is not
    currently visible and may not be manipulated

Drupal\Tests\node\FunctionalJavascript\TestSettingSummariesContentType

WebDriver\Exception\ElementNotVisible: element not visible

Drupal\Tests\system\FunctionalJavascript\OffCanvasTest

    Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::testOffCanvasLinks
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -' '
    +' '

I wasnt totally sure how to categorize this test, as the expected vs actual seems to be equivalent to me.

3. They upload a file as part of the test, which doesnt seem to work like its supposed to (6 tests)

Drupal\Tests\system\FunctionalJavascript\ThemeFormSettingsTest

Exception: invalid argument: File not found :
    /var/www/html/sites/simpletest/52969857/files/image-test.png

Drupal\Tests\file\FunctionalJavascript\MaximumFileSizeExceededUploadTest

File uploads with selenium
Exception: invalid argument: File not found :
    /var/www/html/sites/simpletest/50550782/files/exceeding_post_max_size.txt

Drupal\Tests\image\FunctionalJavascript\QuickEditImageTest

Exception: invalid argument: File not found :
    /var/www/html/sites/simpletest/93323378/files/image-1.png

This test doesnt always fail.

Drupal\Tests\media\FunctionalJavascript\MediaSourceAudioVideoTest

File uploads Again.
Exception: invalid argument: File not found :
    /var/www/html/sites/simpletest/32962472/files/file.mp3

Drupal\Tests\media\FunctionalJavascript\MediaSourceFileTest

Going to guess file uploads again: 
 Exception: invalid argument: File not found :
    /var/www/html/sites/simpletest/29644671/files/wEYJGMD8.txt

Drupal\Tests\media\FunctionalJavascript\MediaSourceImageTest

    Exception: invalid argument: File not found :
    /var/www/html/core/modules/media/tests/fixtures/example_1.jpeg

4. PhantomJS was hiding real failures, or theres something else wrong with the tests (3 tests)

Drupal\FunctionalJavascriptTests\Ajax\AjaxCallbacksTest

There is an error on the page. This test is probably broken and phantom was somehow hiding it: 
Notice: Undefined index: #default_value in Drupal\Core\Datetime\Element\Datetime::valueCallback() (line 99 of core/lib/Drupal/Core/Datetime/Element/Datetime.php).
Drupal\Core\Datetime\Element\Datetime::valueCallback(Array, , Object)
call_user_func_array(Array, Array) (Line: 1269)
Drupal\Core\Form\FormBuilder->handleInputElement('ajax_forms_test_ajax_elements_form', Array, Object) (Line: 986)
Drupal\Core\Form\FormBuilder->doBuildForm('ajax_forms_test_ajax_elements_form', Array, Object) (Line: 1056)
Drupal\Core\Form\FormBuilder->doBuildForm('ajax_forms_test_ajax_elements_form', Array, Object) (Line: 557)
Drupal\Core\Form\FormBuilder->processForm('ajax_forms_test_ajax_elements_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('ajax_forms_test_ajax_elements_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 184)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 121)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 75)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest

Behat\Mink\Exception\ExpectationException: An element matching css
    ".contextual .trigger:not(.visually-hidden)" appears on this
    page, but it should not.

Drupal\Tests\toolbar\FunctionalJavascript\ToolbarIntegrationTest

    Toolbar tray is open by default.
    Failed asserting that false is true. 
tstoeckler’s picture

Nice work!

In switching to webdriver for my own testing, I hit a bug in Chromedriver which seems to arise when switching in and out of iframes. See https://bugs.chromium.org/p/chromedriver/issues/detail?id=2198 for the upstream bug. This is not relevant for core, as far as I know, but the test was testing the contrib entity browser module which uses an iframe currently. I was able to get it to work though, by downgrading Chromedriver to 2.33. I built a Docker image for that purpose, as well, based on the upstream selenium/standalone-chrome container: https://hub.docker.com/r/tstoeckler/standalone-chrome/ Not sure if that's useful to anyone, and not sure if there's a better place to leave this info, but I thought this might catch some people following along at home who might be having the same problem.

jibran’s picture

@Mixologic this is some seriously nice work so thank you. Patch looks solid. I think we need a change notice here.
I have a couple of questions not entirely related to the dev work:

  1. Did switching to webdriver improve the testing time?
  2. What is the resource usage difference before and after this patch?
Mixologic’s picture

@jibran: The testing time improvement is major, and my primary focus here. Phantomjs was never able to be run concurrently, so testing time is significant due to running 63 tests, one at a time, took about 21 minutes. Once everything is webdriver, the tests can be run in parallel, and I was seeing testing times of about 3 minutes for the entire suite for a concurrency of 24.

So now you see why Im motivated to get this work done. It'll save us about 18 minutes per test, which at our current costs of roughly .42/hr, and the fact that we run about 60,000 tests of core per year, well, thats a good chunk of money the DA can save ((.42/60)*18*60000 = $7,560).

The other side effect is that phantomjs is *brittle* and results in random failures, which is disruptive. If we can get on a stack that many, many, many other people use, then we can be more likely to find upstream bugs, like @tstoeckler found in #14

Im not sure what you mean by resource usage. I dont think the webdriver mink classes vs the phantomjs mink classes are materially different, resource wise. If you're planning on running chromedriver with 32 concurrency, then yeah, you need a lot of resources. but otherwise its roughly equivalent.

Mixologic’s picture

StatusFileSize
new55.97 KB
new599 bytes

I realized that in true backwards compatibility fashion, that we need to keep a proxy of LegacyJavascriptTestBase if any contrib projects or custom modules have for some reason extended that class already.

lendude’s picture

Issue summary: View changes
Issue tags: +Needs change record
StatusFileSize
new49.86 KB

@Mixologic++ really great stuff!

Updated the IS with steps that are done and I think are still needed, anything I missed?

So we need the CR (and 'see' to the CR in the deprecation messages) and the follow ups.

Rolled a version of the patch in #17 with --find-copies (no actual changes) that is a little smaller and more clearly shows that WebDriverTestBase is a good copy of JavascriptTestBase with only the needed changes.

similarity index 96%
copy from core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
copy to core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php

jibran’s picture

Thanks, @Mixologic that was insight full.

Im not sure what you mean by resource usage.

I meant memory usage of PhantomJS and Selenium binaries.

Mixologic’s picture

I meant memory usage of PhantomJS and Selenium binaries

We're switching out phantomjs for anything that implements the webdriver protocol, so its not just selenium, but can be standalone chromedriver, geckodriver, edgedriver or selenium, so the testbots just run headless chrome + chromedriver, with no selenium at all. So I dont know that a valid comparison can really be made as we're going from one specific software, to many options/choices.

Phantomjs itself can even run in webdriver mode (with the --webdriver flag) but our mink-selenium2-driver library doesnt seem to support it all that well, (https://github.com/minkphp/MinkSelenium2Driver/issues/258), and I tried it out and it failed on every test attempting to set the cookie with "WebDriver\Exception\UnableToSetCookie:". If that setcookie issue can be sorted out, then in theory there is potentially *no* change to a developers testing resource needs as they could possibly still run phantomjs. (though, I would still advise against encouraging that).

@lendude:

Rolled a version of the patch in #17 with --find-copies

That is super handy! thanks, makes it much easier to review, and I learned a new git option as well.

Mixologic’s picture

I did some research on #2942900-13: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver, point 3, to see if there was a fix for the file uploads. There is, sorta. I opened a followup: #2944291: Upgrade behat/mink-selenium2-driver to 1.3.x-dev

jibran’s picture

Title: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver » [PP-1] Convert JavascriptTestBase Tests to use DrupalSelenium2Driver
Related issues: +#2944291: Upgrade behat/mink-selenium2-driver to 1.3.x-dev
StatusFileSize
new49.86 KB
new52.52 KB

Here is the combined patch to fix the #13.3 and reuploading #18.

jibran’s picture

StatusFileSize
new7.61 KB
new50.16 KB
new52.82 KB

Updated all the tests in #13.3 to use \Drupal\FunctionalJavascriptTests\WebDriverTestBase

wim leers’s picture

Issue tags: +JavaScript

/me cheers from the sidelines!

jibran’s picture

Title: [PP-1] Convert JavascriptTestBase Tests to use DrupalSelenium2Driver » Convert JavascriptTestBase Tests to use DrupalSelenium2Driver
jibran’s picture

I think we should create rest of follow-ups and commit this patch after agreeing on the naming of the new class.

dawehner’s picture

+++ b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
@@ -11,7 +11,7 @@
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;

Mh, I'm wondering whether JavascriptWebDriverTestBase would be a better name overall to indicate it is about JS, but well, I also agree that putting web driver into it is the important idea.

Mixologic’s picture

I was thinking that WebDriver could have other uses beyond Javascript testing, like, if we wanted to run a visual regression testing tool, we could power it with the webdriver api to gather browser screenshots.

Mixologic’s picture

Also:

+++ b/core/tests/Drupal/FunctionalJavascriptTests/LegacyJavascriptTestBase.php
@@ -2,26 +2,13 @@
+ * @deprecated in Drupal 8.6.x, will be removed before Drupal 9.0.0.

Maybe, being a testing thing, this goes into 8.5.x ?

Otherwise, I agree with #26, the patch in #23 is a great start.

jibran’s picture

Related issues: +#2945051: Restore AjaxFormPageCacheTest cache hit test coverage
StatusFileSize
new2.47 KB
new51.28 KB

Thanks, for the input.

  1. Created #2945051: Restore AjaxFormPageCacheTest cache hit test coverage for #13.1.1 point.
  2. Fixed #13.1.2 as it was just one line fix and doesn't really need for the test.
  3. Fixed #19
jibran’s picture

Issue tags: -Needs change record

Status: Needs review » Needs work

The last submitted patch, 30: 2942900-30.patch, failed testing. View results

dawehner’s picture

@jibran
Do you understand the remaining two failures?

Mixologic’s picture

@dawehner: Im pretty sure that moving ActionFormAjaxTest to be a WebDriverTestBase and removed the check on the status code, fixed the issue it had in 13.1, but revealed another instance of a 13.2 type failure.

Mixologic’s picture

Also, maybe we can get Berdir's advice on how to handle the 13.2 type failures, as it appears he had some experience in fixing them for his own suite: https://www.drupal.org/project/drupal/issues/2775653#comment-12401946

jibran’s picture

@dawehner I have an idea how to fix them but I think we should move ActionFormAjaxTest conversion to follow up.

Mixologic’s picture

StatusFileSize
new50.17 KB
new1.36 KB

Here's the patch from #30, minus the ActionFormAjaxTest changes.. so essentially #23 with the deprecation fix from #29

Mixologic’s picture

Status: Needs work » Needs review
jibran’s picture

Issue tags: +Needs followup

Let's create follow-ups and mark it RTBC.

tedbow’s picture

I was looking at OffCanvasTestBase and created #2946294: Fix race conditions in OffCanvasTestBase which I guess is really follow up to this.

tedbow’s picture

Great work on this. but it seems like this issue should wait on #2941560: Add testing with webdriver instructions for other operating systems

It seem like there should be basic documentation on how to use DrupalSelenium2Driver before convert most of our tests. Otherwise any one how wants make a change that will affect any of these tests is going to have a very bad day.

alexpott’s picture

At the moment HEAD is failing badly on PHP 7.1-dev and PHP 7.2-dev on javascripttestbase tests - queue up tests to see if this improves that.

alexpott’s picture

@tedbow for experience the instructions only really get better once the change has been made. That's because people testing in all the different possible environments is better than trying to pre-empt what the problems might be.

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/tests/Drupal/FunctionalJavascriptTests/LegacyJavascriptTestBase.php
@@ -2,26 +2,14 @@
+ * @deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0.

This needs to be updated for 8.6.x. Also I think we should deprecate JavascriptTestBase too in favour of WebDriverTestBase

tacituseu’s picture

Re #42: the reason seems to be that PHPUnit-FunctionalJavascript tests are started with --concurrency "36" in command line, assumed someone was testing something.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new1.28 KB
new50.17 KB

#44 addressed

Also I think we should deprecate JavascriptTestBase too in favour of WebDriverTestBase

We are @deprecated'ing it, we just can't add the trigger_error yet because it's still in use.

Mixologic’s picture

@tacituseu nice spot, I had made some changes so that concurrency was set by the number of processors, but it looks like it only works when we're explicitly setting an environment variable upstream.

I've opened https://www.drupal.org/project/drupalci_testbot/issues/2951617 to address it.

Mixologic’s picture

Fixed #2951617: concurrency should respect the settings of the yaml file if it is set.. 7.1.x and 7.2.x are back to having 1 concurrency.

Anonymous’s picture

Patch with the passing of the remains red tests. Based on #2 way for simplicity, so certainly is not a candidate for RTBC. It also contains unnecessary changes. But if someone is working on it now, it might be useful. See also #2960784: Document a FAQ for Selenium tests.

Mixologic’s picture

StatusFileSize
new40.51 KB
new86.2 KB

#49 nerdsniped me something fierce, and I've been spending pretty much every day since drupalcon wrestling with this patch.

So, I incorporated @vaplas's wonderful findings from #49, and rerolled it together with #46, and put the patch through its paces. Needless to say, there were a lot of random failure scenarios, and it took me a while to track them down.

The primary one is that chromedriver does not entirely support having multiple processes all requesting data from it at the same time. There are race conditions where chromedriver will refuse the curl attempt from within the instaclick lib, causing whatever was happening in the test to appear to fail, but only if there just happened to be some overlap.

So one thing I've added here is core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php.
It overrides the default curl service that comes with the instaclick driver, by replacing it in the DrupalSelenium2Driver class's constructor.
We need to do this because:

  • We need to override the configuration options that we pass into curl's options so that it will CURLOPT_FAILONERROR,
  • When it errors out, we need it to throw a \WebDriver\Exception\CurlExec Exception, and the *existing* code in the current CurlService class is broken as its passing the wrong number of arguments to its exception factory (Todo:file a bug upstream)
  • When an exception is thrown, we need to at least attempt to retry. The race condition is rareish, and this retry should give retry room to cut down the random fails significantly.

A second thing that I had to do to make these work is that the DragTo class would also fail randomly, very consistently, so I had to override that with retries as well, and make less assumptions about keeping an element to reuse it. Now dragto gets the element from the webdriver server each time it has plans to manipulate it.

If this comes up all green, then what we'll be seeing is *all* of the PhantomJS tests converted to Webdriver.

Mixologic’s picture

StatusFileSize
new86.9 KB

And because Im impatient, here's the same patch with an accompanying drupalci.yml file that only runs the javascript tests, and allows them to be parallelized.

Status: Needs review » Needs work

The last submitted patch, 51: 2942900-convert-js-to-webdriver-51.patch, failed testing. View results

Mixologic’s picture

StatusFileSize
new557 bytes
new86.95 KB

#51 showed us that curl is definitely failing sometimes, I oopsed on a use statement.

Mixologic’s picture

Status: Needs work » Needs review
Mixologic’s picture

StatusFileSize
new86.95 KB

#50 shows us that we've got passing tests,
#51 shows us that we do indeed need the extra stuff for running them in parallel because curl fails, and
#52 shows us that the parallel fix, fully implemented, drops the test time to about 7 minutes. - the majority of which is just the SettingsTrayBlockFormTest.

I still have a whole mountain of nasty side eye for SettingsTrayBlockFormTest that for some reason needs to check every single block for every single theme to prove that the settings tray works, all in one test.

Anyhow, here's the patch from #50 with the fix from #52.

Status: Needs review » Needs work

The last submitted patch, 55: 2942900-convert-js-to-webdriver-55.patch, failed testing. View results

Mixologic’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB
new87.11 KB

#55 shows us that 3 retries might not be enough, and that if it fails it should probably throw the exception again. Lets see what happens with that.

Mixologic’s picture

StatusFileSize
new86.4 KB

still had the drupalci.yml in that last patch, because sunday afternoon, and thoroughness, do not go hand in hand.

Anonymous’s picture

@Mixologic, titanic work as always!

+++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
@@ -3,11 +3,20 @@
+    ServiceFactory::getInstance()->setServiceClass('service.curl', '\\Drupal\\FunctionalJavascriptTests\\WebDriverCurlService');

Super elegant decoration!

I still have a whole mountain of nasty side eye for SettingsTrayBlockFormTest that for some reason needs to check every single block for every single theme to prove that the settings tray works, all in one test.

I'm one of those who did it :) Sorry! We just wanted to neutralize any random falls that might occur in this test (#2902191: Determine cause and fix random fail in \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks). But I'm sure that we can achieve what we want without dataProvider. I will try to do it in the coming days.

Now I just wanted to be pleased with the #58 result! 🎉🎉🎉

lendude’s picture

@mixologic++++++++, wow

@vaplas If you are looking to take out the dataprovider, take a look at \Drupal\Tests\link\Functional\LinkFieldUITest::testFieldUI
There we sort of made a pseudo-dataProvider using a yield to make sure that setUp isn't run for every item in the dataprovider, since setUp usually takes up the bulk of the test time. Maybe it will help, maybe you need setup to be run in this case (although a quick look makes me think it might not).

Anonymous’s picture

StatusFileSize
new90.16 KB
new13.62 KB

@Lendude, thanks for this hint, it is really usefull! I'll take this trick into armament.

I combined #57 + #60 + #2946294: Fix race conditions in OffCanvasTestBase, where @tedbow already done big work to improve the stability of this test for Selenium!

Also included fixes for the random fail that @tedbow described in #11.

Also added some WebDriverCurlService refactoring + reinforcement, to fight with StaleElementReference exception. Unfortunately, this is not enough for multiple repeat testing in parallel mode. But it copes well with a single-threaded mode.

Unfortunately, the dataProvider imitation did not give a x20 acceleration (only x2).

Added a @todo to go back to the data provider after the test runs are more lightweight.

Status: Needs review » Needs work

The last submitted patch, 61: 2942900-61.patch, failed testing. View results

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new92.89 KB
new9.99 KB

Well, the WebDriverCurlService refactoring was clearly wrong :)

Reverted to #57 version, just added:

+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
@@ -96,6 +96,12 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions
+        $result = json_decode($rawResult, TRUE);
+        if (isset($result['status']) && $result['status'] === WebDriverException::STALE_ELEMENT_REFERENCE) {
+          usleep(rand(100000, 1000000));
+          $retries++;
+          continue;
+        }

Status: Needs review » Needs work

The last submitted patch, 63: 2942900-63.patch, failed testing. View results

Anonymous’s picture

:(

#57 looks like simultaneous runs on two PHP versions led to a CI hangup.
#63 also works unstable.

I have little faith in this, but is it possible to update the driver and the browser to the latest versions will somehow improve the situation?

Now using:
chrome=62.0.3202.94
chromedriver=2.33.506092

Latest:
chrome=66.0.3359.117
chromedriver=2.38.552522

Although I did not find any information about any changes that might help :(

Or instaclick request implementation is this the only problem?

msankhala’s picture

Issue summary: View changes
Anonymous’s picture

Wow, @Mixologic reran few tests, and they are green now! Do you plan to tell the secret of this focus?)

Mixologic’s picture

@vaplas yeah, Im not really sure if there was a drupalci issue that day, or if the tests are just flaky, and we got lucky. I do find it odd that both managed to stall, and then both managed to succeed. We might want to re-run some more a few consecutive times to make sure that we dont have a hidden random fail with this technique.

Anonymous’s picture

Special issue for check selenium tests #2972833: Check Selenium tests stability.

dawehner’s picture

Here is just some form of quick review. I'm happy to fix these points tomorrow, if noone beats me.

  1. +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
    @@ -93,8 +93,9 @@ public function testFragmentLink() {
         // Add a bottom margin to the title field to be sure the body field is not
         // visible. PhantomJS runs with a resolution of 1024x768px.
    -    $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '800px';");
    +    $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '1200px';");
    

    Note: We are not using phantomjs anymore so we should maybe update the comment too. Running the tests locally said: It it using 1670/1670 by default. I guess the 400 extra pixel reflect that. We should update the comment though.

  2. +++ b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
    @@ -100,12 +100,15 @@ public function testEntityForm() {
    +    $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
    
    @@ -166,6 +171,7 @@ public function testEntityView() {
    +    $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
    

    I really like this check to see whether something changed!

  3. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php
    @@ -51,6 +51,7 @@ public function testBlockConfigAccess() {
         $page->pressButton('Save Site branding');
    +    $web_assert->assertWaitOnAjaxRequest();
         $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
         $web_assert->assertWaitOnAjaxRequest();
         // Confirm we did not save changes to the configuration.
    diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php
    
    +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php
    @@ -58,6 +58,7 @@ public function testOverriddenConfigurationRemoved() {
         $web_assert->fieldNotExists('settings[site_information][site_name]');
         $page->pressButton('Save Site branding');
    +    $web_assert->assertWaitOnAjaxRequest();
         $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
         $web_assert->assertWaitOnAjaxRequest();
         // Confirm we did not save changes to the configuration.
    
    @@ -90,6 +91,7 @@ public function testOverriddenConfigurationRemoved() {
         $page->pressButton('Save Main navigation');
    +    $web_assert->assertWaitOnAjaxRequest();
         $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
         $web_assert->assertWaitOnAjaxRequest();
    

    Are you sure we need those? We do already have a check for some element being visible after that.

  4. +++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
    @@ -2,14 +2,14 @@
    -class ToolbarIntegrationTest extends JavascriptTestBase {
    +class ToolbarIntegrationTest extends WebDriverTestBase {
    
    @@ -27,7 +27,11 @@ public function testToolbarToggling() {
    +    $this->getSession()->resizeWindow(1200, 600);
    

    It would be nice to document why we are resizing things here.

  5. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php
    @@ -2,14 +2,14 @@
       /**
        * {@inheritdoc}
    @@ -17,34 +17,23 @@ class AjaxCallbacksTest extends JavascriptTestBase {
    
    @@ -17,34 +17,23 @@ class AjaxCallbacksTest extends JavascriptTestBase {
       public static $modules = ['ajax_forms_test'];
     
       /**
    -   * Tests if Ajax callback works on date element.
    +   * Tests if Ajax callback works on date/datetime elements.
        */
       public function testDateAjaxCallback() {
    -
    -    // Test Ajax callback when date changes.
         $this->drupalGet('ajax_forms_test_ajax_element_form');
    -    $this->assertSession()->responseContains('No date yet selected');
    -    $this->getSession()->getPage()->fillField('edit-date', '2016-01-01');
    -    $this->assertSession()->assertWaitOnAjaxRequest();
    -    $this->assertSession()->responseNotContains('No date yet selected');
    -    $this->assertSession()->responseContains('2016-01-01');
    -  }
    +    $session = $this->getSession();
    +    $assert = $this->assertSession();
     
    -  /**
    -   * Tests if Ajax callback works on datetime element.
    -   */
    -  public function testDateTimeAjaxCallback() {
    +    // Test Ajax callback when date changes.
    +    $this->assertNotEmpty($session->getPage()->find('xpath', '//div[@id="ajax_date_value"][text()="No date yet selected"]'));
    +    $session->executeScript('jQuery("[data-drupal-selector=edit-date]").val("2016-01-01").trigger("change");');
    +    $this->assertNotEmpty($assert->waitForElement('xpath', '//div[@id="ajax_date_value"]/div[text()="2016-01-01"]'));
     
         // Test Ajax callback when datetime changes.
    -    $this->drupalGet('ajax_forms_test_ajax_element_form');
    -    $this->assertSession()->responseContains('No datetime selected.');
    -    $this->getSession()->getPage()->fillField('edit-datetime-date', '2016-01-01');
    -    $this->assertSession()->assertWaitOnAjaxRequest();
    -    $this->assertSession()->responseNotContains('No datetime selected.');
    -    $this->assertSession()->responseContains('2016-01-01');
    -    $this->getSession()->getPage()->fillField('edit-datetime-time', '12:00:00');
    -    $this->assertSession()->assertWaitOnAjaxRequest();
    -    $this->assertSession()->responseContains('2016-01-01 12:00:00');
    +    $this->assertNotEmpty($session->getPage()->find('xpath', '//div[@id="ajax_datetime_value"][text()="No datetime selected."]'));
    +    $session->executeScript('jQuery("[data-drupal-selector=edit-datetime-date]").val("2016-01-01");');
    +    $session->executeScript('jQuery("[data-drupal-selector=edit-datetime-time]").val("12:00:00").trigger("change");');
    +    $this->assertNotEmpty($assert->waitForElement('xpath', '//div[@id="ajax_datetime_value"]/div[text()="2016-01-01 12:00:00"]'));
       }
    

    It feels like we don't need to merge these two test functions into one in this issue. This makes it simply harder to review.

  6. +++ b/core/tests/Drupal/Tests/BrowserTestBase.php
    @@ -779,6 +781,13 @@ protected function drupalLogin(AccountInterface $account) {
    +    if ($this->getSession()->getDriver() instanceof DrupalSelenium2Driver) {
    +      $page = $this->getSession()->getPage();
    +      $page->waitFor(100, function ($page) {
    +        return $this->getSession()->getPage()->findField('edit-pass') && $this->getSession()->getPage()->findField('edit-name') && $this->getSession()->getPage()->findButton('Log in');
    +      });
    +    }
    

    Isn't it enough to wait for one of the three fields?

Anonymous’s picture

Assigned: Unassigned »

@dawehner, thanks for review! I will reroll patch after #2971472: SettingsTrayBlockFormTest is taking 5 minutes to run and respond to #70.

Anonymous’s picture

Assigned: » Unassigned
Status: Needs work » Needs review
StatusFileSize
new89.67 KB
new7.61 KB
new86.71 KB
new13.55 KB
  • #70.1: Done
  • #70.2: yep :)
  • #70.3: It was a desperate attempt to protect tests from "StaleElementReference" exception. But after WebDriverCurlService maybe we can just remove it. While replace on semantic waitForOffCanvasToClose() by your hint. Also removed another code, like DrupalSelenium2Driver::dragTo() by same reason. Let's see what happens.
  • #70.4: Done. On my machine selenium open browser in narrow mode 929x883 (1920x1080 is real screen). As result vertical toolbar by default.
  • #70.5: Done.
  • #70.6: Removed at all, similar to #70.3

settings_tray tests contain many works of @tedbow from #2946294: Fix race conditions in OffCanvasTestBase. Maybe we should decide about them in that issue.

Mixologic’s picture

re #70.6 - that might have been an artifact left over from my troubleshooting of the curl collisions

Nice work on #2971472: SettingsTrayBlockFormTest is taking 5 minutes to run . My side eye has been healed! 5 min 25 sec!! would be interested to see if you set the concurrency to 17 in the drupalci.yaml based off of what you discovered in #2972833: Check Selenium tests stability

Mixologic’s picture

StatusFileSize
new88.23 KB

Retesting #72 but with concurrency 17, and also we now have a drupalci.yml file in core, so the patch modifies the existing vs adding a new one.

Status: Needs review » Needs work

The last submitted patch, 74: 2942900-74-actually.patch, failed testing. View results

Mixologic’s picture

StatusFileSize
new88.35 KB
new88.37 KB
new488 bytes

Hmm. retrying just that one test, plus a 50x version.

Mixologic’s picture

Status: Needs work » Needs review
Anonymous’s picture

StatusFileSize
new88.23 KB
new1.38 KB

Unfortunately, in my research was flawed:

+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
@@ -98,7 +98,7 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions
          usleep(rand(100000, 1000000));

It makes the winner's choice a bit random. So I will repeat them with:
usleep(100000);
Also I am planning to check test stability with delay css/js files + delay response from index.php.

#75: Looks like the field was filled before it became 'ui-autocomplete'. Fixed.

Anonymous’s picture

StatusFileSize
new88.87 KB
new2.01 KB

Meh, wrong patches :(

heddn’s picture

+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
@@ -11,15 +11,14 @@
-abstract class JavascriptTestBase extends BrowserTestBase {

Should we deprecate w/ a trigger_error JavascriptTestBase since we add WebDriverTestBase?

Mixologic’s picture

That was suggested in #46, and at the time we decided not to because we werent actually converting everything. But now we have everything, so maybe it makes sense to do so?

Anonymous’s picture

At least this trigger will help to detect the leaked PhantomJS tests, until we works on convertion. Done in #2972833-6: Check Selenium tests stability, will be merge here after green result.

Anonymous’s picture

StatusFileSize
new91.22 KB
new8.51 KB

Yep, trigger_error helps find 3 new tests (2 Selenium, 1 PhantomJS). This patch from #2972833-9: Check Selenium tests stability. For more performance, we can decouple SettingsTrayBlockFormTest on 3 tests + run tests in revert order. But it seems this will not give a significant profit (~ 1 minute), so that can be done later.

Mixologic’s picture

StatusFileSize
new89.5 KB

Heres the above patch without the drupalci carveouts.

Mixologic’s picture

Since this patch is pretty hefty, and does several things, I went ahead and split it up into some smaller chunks to make reviewing easier.

  • part 1 is the overriding of the webdriver selenium curl service for reasons outlined in #2942900-50: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver
  • part 2 is where we Make WebDriverTestBase the new JavaScriptTestBase, and Deprecate JavaScriptTestBase and LegacyJavaScriptTestBase
  • part 3 are all the tests that only needed to be renamed from JavaScriptTestBase to WebDriverTestBase, and they all passed
  • part 4 is all of the work we did to fix the existing tests.
  • part 5 is just the switchover from concurrency of 1 to 15 once everything is converted

Part 4 is the real heart of this patch. If we are going to deprecate JavascriptTestBase, then we'll probably need a changerecord that points to documentation that gives the contrib developers who are currently using JavaScriptTestBase some guidelines on how to convert their existing tests over to webdriver.

So what we'll likely need is to take everything we've learned in part4 and combine it into a docs page with everything else that vaplas discovered over in #2960784: Document a FAQ for Selenium tests such that we have a guide for developers on how to convert their existing tests, and then we can write a change record to point at that.

Meanwhile we could also make sure that the docs are updated to ensure that installing chromedriver is clear (seems like we have windows/osx/linux instructions but nothing totally in one place.)

I did see a couple of tests in part4 that didnt remove the use statement on the functionalJavascript, but I didn't fix that at this juncture.

Soon. Soon no more phantomjs on the infra.

Anonymous’s picture

#85: Reading a patch on the parts really brings great pleasure! 🍰

I could not resist the temptation to take the part-2 into a separate issue #2977386: Provide WebDriverTestBase.

Also #2901792: Disable all animations in Javascript testing сan improve the stability of PhantomJS/Selenium tests.

alexpott’s picture

Status: Needs review » Needs work

How can we move this issue on? Should we be breaking the issue up as per #85 or just committing #84.
I'm in favour of committing #84 as long as we can show that the test infra is running imo we're good to go.

Atm the patch needs a reroll and probably to convert anything new that's added.

jibran’s picture

+1 for #84.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new89.5 KB
new1.87 KB

Nit reroll after #2916781: Allow off-canvas dialog to be rendered at the top of the page.

It would be more reliable to start from concurency = 1. And then raise it, if the tests work stably. Yes, it is not a very pleasant idea, but switching to the new driver is better to make gradual.

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch, 90: interdiff-89-90.patch, failed testing. View results

Anonymous’s picture

Status: Needs work » Needs review

My bad with interdiff extension, sorry!

lendude’s picture

Just some nits really.

  1. +++ b/core/drupalci.yml
    @@ -47,7 +47,7 @@ build:
    -        concurrency: 1
    +        concurrency: 15
    

    ++ for going for 15, really the only way to discover if it will hold up, but I would totally get a more reserved approach.

  2. +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
    @@ -105,9 +105,23 @@ protected function getOffCanvasDialog() {
    +  public function waitForNoElement($selector, $timeout = 10000) {
    

    public? can this be protected?

  3. +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php
    @@ -41,7 +41,8 @@ protected function getFormBuildId() {
    +    // @TODO: Move this assert to another level of testing.
    
    @@ -77,7 +78,8 @@ public function testSimpleAJAXFormValue() {
    +    // @TODO: Move this assert to another level of testing.
    

    Open a follow up for this and refer to that and not just set a blanket @todo?

  4. +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
    @@ -0,0 +1,113 @@
    + * @author mark
    

    no @author. But do we need to reference the original code somewhere? Not really into the whole licensing thing.

  5. +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
    @@ -0,0 +1,113 @@
    +class WebDriverCurlService extends CurlService implements CurlServiceInterface {
    +  /**
    

    missing new line

  6. +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
    @@ -0,0 +1,113 @@
    +            // Suppress "Expect: 100-continue" header automatically added by cURL that
    +            // causes a 1 second delay if the remote server does not support Expect.
    

    > 80 characters

  7. +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
    @@ -0,0 +1,113 @@
    +            // Suppress "Expect: 100-continue" header automatically added by cURL that
    +            // causes a 1 second delay if the remote server does not support Expect.
    

    > 80 characters

Anonymous’s picture

StatusFileSize
new89.84 KB
new7.88 KB

Thanks for review!

#93.1 Agree. But still 15 just to spend as much as possible the tests with concurency :) This number can be changed to 1 during the commit, if we all agree with this step.
#93.2: Done.
#93.3: Indeed! Filed to #2945051-5: Restore AjaxFormPageCacheTest cache hit test coverage.
#93.4: Done (i hope)
#93.5: Done.
#93.6: Done.
#93.7: Done.

Also fixed CS errors.

lendude’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs release manager review, -Needs followup

This looks great.

Removing the 'Needs release manager review' tag since that was set when we were trying to do something BC breaking back in #8. We are completely BC now so I don't think we need that anymore.

Removing 'Needs followup' tag because that was set back when we were only doing a partial conversion. We got everything now (wooo!).

alexpott’s picture

So this will impact core but in a good way - faster testing and better js testing. One concern I have about committing this right now is that 8.5.x is still open for bugfixes so this might make it trickier to backport and it is going to be disruptive to things pushing for 8.6.x. So one possibility to minimise disruption we'd commit this after 8.6.0 Feature Freeze: Week of July 18, 2018. @Mixologic - thoughts?

Mixologic’s picture

I think the only disruption that might happen is if people are pushing to get something that requires a javascript test, and they get blocked on not being able to set up their environment, as Im not 100% sure we've responded to #41. I know that some folks have gone through the steps, and made changes to the docs, but I havent re-assessed them.

That being said, I think *that* risk is low. It doesnt seem as though there is a tremendous amount of velocity on things that need these tests, and it seems like we've only needed to chase changes to head in this patch a few times in four months or so.

If I were to referee this change, I'd say that the random phantomjs failures are at least as disruptive as any potential disruptions we'd be introducing.

Either way, I'll go have a look at the docs issues to see where things stand.

alexpott’s picture

Just committed some patches with additional JS tests - #2831944: Implement media source plugin for remote video via oEmbed and #2828528: Add Quick Edit Functional JS test coverage let's see if this breaks.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 94: 2942900-convert-js-to-webdriver-94.patch, failed testing. View results

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new89.83 KB

Reroll was needed:

+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
@@ -54,6 +54,8 @@ public function testMediaDisplay() {
+    $this->getSession()->getPage()->pressButton('Show row weights');
+    $this->assertSession()->waitForElementVisible('css', '[name="fields[name][region]"]');

is now this

    $assert_session->buttonExists('Show row weights')->press();
    $this->assertSession()->waitForElementVisible('css', '[name="fields[name][region]"]');

Status: Needs review » Needs work

The last submitted patch, 100: 2942900-100.patch, failed testing. View results

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new90.02 KB

Hmm somehow the quickedit changes didn't come through when I pulled, *shrug*. Reroll number 2!

changes:

class QuickEditJavascriptTestBase extends WebDriverTestBase

And removed the @todo to this issue.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC after the reroll.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 102: 2942900-102.patch, failed testing. View results

jibran’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new799 bytes
new90.8 KB

Changed the base class for Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 105: 2942900-104.patch, failed testing. View results

lendude’s picture

Status: Needs work » Reviewed & tested by the community

1) Drupal\Tests\system\FunctionalJavascript\OffCanvasTest::testOffCanvasLinks with data set "stark" ('stark')
Element was not on the page after wait.
Failed asserting that an object is empty.

Hmm related or not .... I don't know. Seems pretty stable so far otherwise.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 105: 2942900-104.patch, failed testing. View results

jibran’s picture

Issue tags: +Needs reroll

New JTBs in HEAD
core/modules/file/tests/src/FunctionalJavascript/FileFieldValidateTest.php
core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php
core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
core/modules/media/tests/src/FunctionalJavascript/MediaViewsWizardTest.php

martin107’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new97.26 KB

Rerolled.

lendude’s picture

@martin107++

I think you missed

class FileFieldValidateTest extends JavascriptTestBase

And try rolling the patch with --find-copies, it reduces the size of the patch a little bit.

PS. If you are at DevDays, I'm down in the sprint dungeon

Status: Needs review » Needs work

The last submitted patch, 110: 2942900-110.patch, failed testing. View results

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new91.62 KB
new871 bytes

Thanks .. at some point I must show up to a Drupal event, but not today.

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

borisson_’s picture

rtbc++, great work!

ricardoamaro’s picture

Issue tags: +DevDaysLisbon
alexpott’s picture

Crediting everyone who made constructive comments on the issue. Thanks everyone!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed f55d974 and pushed to 8.6.x. Thanks!

  • alexpott committed f55d974 on 8.6.x
    Issue #2942900 by Mixologic, vaplas, jibran, Lendude, martin107,...
alexpott’s picture

Status: Fixed » Needs work

We missed something :(

If you run a test without a webdriver service running you get this message:

PhantomJS is either not installed or not running. Start it via phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768&

Not that helpful :(

  • alexpott committed ff99cb2 on 8.6.x
    Revert "Issue #2942900 by Mixologic, vaplas, jibran, Lendude, martin107...
dawehner’s picture

Assigned: Unassigned » dawehner

I'm looking into that quickly

alexpott’s picture

Actually I was wrong the message doesn't mention phantomjs. The message is:

An unexpected error occurred while starting Mink: Could not open connection: Curl error thrown for http POST to http://localhost:4444//session with params: {"desiredCapabilities":{"browserName":"chrome","version":"9","platform":"ANY","browserVersion":"9","browser":"firefox","name":"Behat Test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0"}}

Failed to connect to localhost port 4444: Connection refused

However this shows us something else. The old message was super helpful. This one is not. Let's try to make it better before going forward.

dawehner’s picture

Assigned: dawehner » Unassigned
Status: Needs work » Needs review
StatusFileSize
new107.21 KB
new15.91 KB

Here is a better error handling. I am wondering whether including the original message is still helpful.

Before

~/w/d8|2942900⚡✖$ ./vendor/bin/phpunit -c core "core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php" -v
PHPUnit 6.5.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.1.16 with Xdebug 2.6.0
Configuration: /Users/dawehner/www/d8/core/phpunit.xml

Testing Drupal\FunctionalJavascriptTests\Core\MachineNameTest
S                                                                   1 / 1 (100%)

Time: 28.07 seconds, Memory: 6.00MB

There was 1 skipped test:

1) Drupal\FunctionalJavascriptTests\Core\MachineNameTest::testMachineName
An unexpected error occurred while starting Mink: Could not open connection: Curl error thrown for http POST to http://localhost:4444/wd/hub/session with params: {"desiredCapabilities":{"browserName":"chrome","version":"9","platform":"ANY","browserVersion":"9","browser":"firefox","name":"Behat Test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0"}}

Failed to connect to localhost port 4444: Connection refused

/Users/dawehner/www/d8/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:49
/Users/dawehner/www/d8/core/tests/Drupal/Tests/BrowserTestBase.php:493
/Users/dawehner/www/d8/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php:28

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 1, Skipped: 1.

After

~/w/d8|2942900⚡✖$ ./vendor/bin/phpunit -c core "core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php" -v
PHPUnit 6.5.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.1.16 with Xdebug 2.6.0
Configuration: /Users/dawehner/www/d8/core/phpunit.xml

Testing Drupal\FunctionalJavascriptTests\Core\MachineNameTest
S                                                                   1 / 1 (100%)

Time: 26.96 seconds, Memory: 6.00MB

There was 1 skipped test:

1) Drupal\FunctionalJavascriptTests\Core\MachineNameTest::testMachineName
The test wasn't able to connect to your webdriver instance. Read more on core/tests/README.md how to install one on your system.

 The original message while starting Mink: Could not open connection: Curl error thrown for http POST to http://localhost:4444/wd/hub/session with params: {"desiredCapabilities":{"browserName":"chrome","version":"9","platform":"ANY","browserVersion":"9","browser":"firefox","name":"Behat Test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0"}}

Failed to connect to localhost port 4444: Connection refused

/Users/dawehner/www/d8/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:51
/Users/dawehner/www/d8/core/tests/Drupal/Tests/BrowserTestBase.php:493
/Users/dawehner/www/d8/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php:28

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 1, Skipped: 1.
dawehner’s picture

StatusFileSize
new92.66 KB
new1.36 KB

Good try. This is the same but with the right interdiff/patch file.

alexpott’s picture

Status: Needs review » Needs work

Whilst testing the patch I've realised that the default driver args for webdriver are wrong which makes config-less startup with chromedriver more difficult than it should be.

$this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444/'];

should be

$this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444'];

The current code results in URLs like http://localhost:4444//session and errors:

1) Drupal\FunctionalJavascriptTests\Core\MachineNameTest::testMachineName
An unexpected error occurred while starting Mink: Could not open connection: Curl error thrown for http POST to http://localhost:4444//session with params: {"desiredCapabilities":{"browserName":"chrome","version":"9","platform":"ANY","browserVersion":"9","browser":"firefox","name":"Behat Test","deviceOrientation":"portrait","deviceType":"tablet","selenium-version":"2.31.0"}}

The requested URL returned error: 404 Not Found

If we fix that then running tests using chromedriver should only need you to start chromedriver like this:
chromedriver --port=4444
and not have to message about with setting MINK_DRIVER_ARGS etc.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new93.08 KB
new776 bytes

Thank you @alexpott!

alexpott’s picture

We have something that needs to be understood. The test runs as a result of the commit failed :( see https://dispatcher.drupalci.org/job/php-7.2-apache_mysql5.5/1499/console

alexpott’s picture

+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
@@ -46,6 +46,14 @@ protected function initMink() {
+        $this->markTestSkipped("The test wasn't able to connect to your webdriver instance. Read more on core/tests/README.md how to install one on your system. \n \n The original message while starting Mink: {$e->getMessage()}");

I think this message would be better as The test wasn't able to connect to your webdriver instance. Ror more information read core/tests/README.md.\n\nThe original message while starting Mink: {$e->getMessage()}

I discussed the message with @dawehner and @gábor-hojtsy.

If #128 turns out to be nothing and this ends up back at rtbc i'm happy to fix this on commit.

Mixologic’s picture

#128 is the result of an untested scenario in recent drupalci changes, namely "what happens when core commits a drupalci.yml file, and then reverts it right away"

So, somehow drupalci was sent the new drupalci.yml file with the concurrency of 15, but was testing the revert commit, which was phantomjs. I'll look into how this happened on the PIFT side of things, but that explains the timeouts/failures.

dawehner’s picture

StatusFileSize
new93.06 KB
new977 bytes

Here is an updated message.

lendude’s picture

+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
@@ -48,7 +48,7 @@ protected function initMink() {
+        $this->markTestSkipped("The test wasn't able to connect to your webdriver instance. Ror more information read core/tests/README.md.\n\nThe original message while starting Mink: {$e->getMessage()}");

Ror => For

lendude’s picture

Status: Needs review » Reviewed & tested by the community

@alexpott offered to fix the typo on commit, RTBC assuming this comes back green.

dawehner’s picture

You know english has all kind of myths, maybe this is one of them.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Second time lucky. Committed 27740c2 and pushed to 8.6.x. Thanks!

  • alexpott committed 27740c2 on 8.6.x
    Issue #2942900 by Mixologic, vaplas, jibran, dawehner, Lendude,...
Mixologic’s picture

🎆💥 YES💥 🎆

lendude’s picture

@here++

awesome work!

jibran’s picture

Yay!!! to ✂️💵💵💵💵💵

andypost’s picture

It was commited to 8.6 so change record needs update

dawehner’s picture

Yeah! Congratulations

I added a follow up for some better experience: #2983777: Improve the user experience of WebDriverTestBase

lendude’s picture

We missed updating the comment in drupalci.yml about concurrency, so another follow up #2983781: Update drupalci.yml concurrency comment to match the new reality of FunctionalJavascript

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jhodgdon’s picture

Docs were not updated with this change. I opened
#3029813: Testing topic documentation is way out of date
to remedy that situation.