Problem/Motivation

DrupalCI chromedriver image has a screen size of 800x600. When running WebDriverTestBase locally it's unlikely you'll have the same screen size.

Proposed resolution

Set a default screen size for more predictable testing.

Remaining tasks

Agree size - currently suggested to be 1024x768 as that's what Thunder has used for a while and it's proved okay. Note that any test can call $this->getSession()->resizeWindow(x, y) to change the size as desired. This size fits most laptop screens so anybody running the tests locally will still see what is going on.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

N/a

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
FileSize
18.9 KB

So Thunder uses 1024x768 as its default JS testing size. I think that that is better that 800x600 which no one uses and is very small. So let's set it in core and see what happens.

Note the patch attached includes #2901792: Disable all animations in Javascript testing as that is necessary for consistent JS testing but it also reverts a change from that.

alexpott’s picture

Hmmmm... so what's weird is that without

/**
 * Prevent youtube and third party content in iFrames from affecting tests.
 */
iframe.media-oembed-content {
  width: 0 !important;
  height: 0 !important;
}

The following command fails...
sudo -u _www ./vendor/bin/phpunit -v -c ./core core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php --filter testWidgetOEmbed

It fails with:

1) Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest::testWidgetOEmbed
Behat\Mink\Exception\ElementNotFoundException: Form field with id|name|label|value|placeholder "Add Type Five via URL" not found.

However if I run it like testbot ie with:
$ sudo MINK_DRIVER_ARGS_WEBDRIVER='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://localhost:4444"]' -u _www ./vendor/bin/phpunit -v -c ./core core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTest.php --filter testWidgetOEmbed

It passes! And then remove the --headless and fails. So there's something about running it in a browser that you can see that is causing issues.

alexpott’s picture

FileSize
149.51 KB
516.72 KB

So taking screenshots of what happens with headless vs not headless you can see that it's the youtube view that is behaving differently. Somehow in the non headless it is playing!!!

Passing test with --headless

Failing test without --headless

alexpott’s picture

So preventing the embedded media loading in the iframe fixes the locally testing when --headless is not present.

Status: Needs review » Needs work

The last submitted patch, 5: 3056008-5.patch, failed testing. View results

alexpott’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.47 KB

Patch without #2901792: Disable all animations in Javascript testing as that's been committed.

The patch no longer attempts to remove the oembedded content. It should work BUT there's a bug in chromedriver - see https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758 so I've added the @todo and left things how there are for now.

We should probably open another issue to discuss whether we should be using real youtube videos in testing. However on the plus side this does mean we are testing with real content doing what a real user would do - which kinda is the point of this type of testing.

Lendude’s picture

Issue summary: View changes
+++ b/core/modules/system/tests/modules/css_disable_transitions_test/css/disable_transitions.theme.css
@@ -29,6 +29,8 @@
+ * @todo Remove once https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758 is fixed.

> 80 characters

Discussed the chosen screen size with @alexpott on slack, 1024x768 makes sense as a default so that it still fits on most laptops when running the tests locally. Updated the IS for this.

alexpott’s picture

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

RTBC assuming this comes back green.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed c7b8bc5 and pushed to 8.8.x. Thanks!

catch’s picture

Version: 8.8.x-dev » 8.7.x-dev

And cherry-picked to 8.7.x.

  • catch committed 373d3f8 on 8.7.x
    Issue #3056008 by alexpott, Lendude: Set default window size in \Drupal\...

  • catch committed c7b8bc5 on 8.8.x
    Issue #3056008 by alexpott, Lendude: Set default window size in \Drupal\...

Status: Fixed » Closed (fixed)

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