Problem/Motivation

In #2775653: JavascriptTests with webDriver we added instructions on how to set up webdriver. We should extend these instructions to cover other OSes other than OSX.

Proposed resolution

Extend instructions. From @droplet in #2775653-126: JavascriptTests with webDriver:

This is even neater and for every platform than MacOS:
https://github.com/vvo/selenium-standalone

If we run out of time, simply 2 lines:

npm install selenium-standalone@latest -g
selenium-standalone install

If we have little time to polish it:
- Add a npm script (install part only). Even a single line adding to package.json

npm install selenium-standalone@latest -g && selenium-standalone install

In the future follow up:
- A npm script for config
- A npm script for test runner

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

alexpott created an issue. See original summary.

Anonymous’s picture

Well, here's the instruction for Windows (maybe not the best):

Prepare (only once):

  1. Install npm (part of node.js)
  2. Open console (cmd) and run:
    npm install selenium-standalone@latest -g && selenium-standalone install
  3. If the tests are started using phpunit.xml.dist, add to this file the next <env> config:
    <env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", null, "http://localhost:4444/wd/hub"]'/>
    Otherwise, it need to be exported in some other way. See also /core/tests/README.md for more options.

Run selenium:

  1. open cmd and run: selenium-standalone start -port 4444 (or click by .bat file with this command)

Run tests:

  1. Just run your Test via the IDE (with preconfigured phpunit.xml.dist).
  2. Or run via command line like:
    php ../vendor/phpunit/phpunit/phpunit --testsuite --class tests\Drupal\FunctionalJavascriptTests\Tests\JSWebWithWebDriverAssertTest

Note: If your Test extends JavascriptTestBase, add the following line to it:
protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;

or switch the parent class to WebDriverTestBase (after #2942900: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver).

Mixologic’s picture

So we've got instructions in core/core.api.php that need to be updated: https://cgit.drupalcode.org/drupal/tree/core/core.api.php?h=8.6.x#n1175

Those become https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.6.x

Those point at this docs page that needs updating:
https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutorial

Change record for reference:
https://www.drupal.org/node/2941464

All of the docs, so far, give several different ways to accomplish the goal of having a service that implements the webdriver api running somewhere that the testing framework can access. Some of those involve installing node.js, or java, depending on the method used.

Im not entirely sure what we should keep in scope for the docs - i.e the testbots are running *solely* chromedriver, in headless mode, with no selenium server at all. There's geckodriver for the folks who want to see if the tests run on FF, but it looks like theres some bugs with it: https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver... and then theres using selenium standalone using nodejs (which would also require java, because selenium is written in java).

And as far as "installing on various OS'es" we should keep in mind that theres additional options for people to erect a webdriver service, like running a docker container that provides it, or firing up a vagrant box that has it already configured. So perhaps we could use a boundary around how much howto we provide, and what choices we emphasize.

Mixologic’s picture

Anonymous’s picture

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

larowlan’s picture

After some pointers from @Mixologic, I was able to get testing going with docker-compose. I updated the docs here https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutoria...

andypost’s picture

@larowlan I see problem in dev/shm which exists only for linux and will fail for macos & win

larowlan’s picture

OSX has dev/shm

No idea about windows

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

I'm using following docker-compose snippet to run it everywhere

  chrome:
#    image: drupalci/webdriver-chromedriver:production
    image: zenika/alpine-chrome:with-chromedriver
    container_name: "chrome"
    ulimits:
      core:
        soft: -1
        hard: -1
    cap_add:
      - SYS_ADMIN
    volumes:
      - /dev/shm:/dev/shm
    ports:
      - "4444:4444"
    entrypoint:
      - chromedriver
      - "--port=4444"
      - "--no-sandbox"
      - "--allowed-ips="
      - "--allowed-origins=*"
#      - "--log-path=/tmp/chromedriver.log"
#      - "--log-level=INFO"
      - "--log-level=WARNING"
#      - "--verbose"
    networks:
      - front

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.