Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-58948

Compatibility with chrome mink driver

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Ensure there are no regressions in the Behat suite.

      • Run all of the Javascript tests.
      • Run all of the core supported drivers (Selenium2, PhantomJS, etc).

      The only other change outside of Behat is a JS change to the course management screen.  It's an event handler on the select element for sorting the course and categories. Ensure that you can still sort categories and courses. In particular, changing the first select menu under Sorting should enable the subsequent select elements. This is also covered by the Behat testing suite.

      Bonus Points: Test the Chrome Driver

      It's rather involved process, but here we go!

      In your Moodle config file, comment out any Behat profiles (EG: $CFG->behat_profiles). Then add this:

      $CFG->behat_config = [
          'default' => [
              'extensions' => [
                  'DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension' => [],
                  'Behat\MinkExtension'                                          => [
                      'browser_name' => 'chrome',
                      'base_url'     => $CFG->behat_wwwroot,
                      'goutte'       => null,
                      'selenium2'    => null,
                      'sessions'     => [
                          'javascript' => [
                              'chrome' => [
                                  'api_url' => 'http://localhost:9222'
                              ]
                          ]
                      ]
                  ]
              ]
          ],
      ];
      

      Grab the Behat extension and Mink driver, run this in the root of Moodle:

      composer require --dev dmore/behat-chrome-extension
      composer require --dev dmore/chrome-mink-driver
      

      Need to install Chrome 59 or later. Then run Chrome:

      chrome --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222
      

      Or in headless mode (required for parallel Behat runs):

      chrome --disable-gpu --headless --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222
      

      Where "chrome" is the path to the Chrome app. On Mac OS, it's in "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome". See https://developers.google.com/web/updates/2017/04/headless-chrome for more details.

      Lastly, initialize the Behat environment and run the JS tests like so:

      php admin/tool/behat/cli/run.php --tags="@javascript&&~@_alert"
      

      The $CFG->behat_faildump_path should work just like when using Selenium. Once set, you can purposefully fail a JS scenario and it should capture a screenshot.

      Show
      Ensure there are no regressions in the Behat suite. Run all of the Javascript tests. Run all of the core supported drivers (Selenium2, PhantomJS, etc). The only other change outside of Behat is a JS change to the course management screen.  It's an event handler on the select element for sorting the course and categories. Ensure that you can still sort categories and courses . In particular, changing the first select menu under Sorting should enable the subsequent select elements. This is also covered by the Behat testing suite. Bonus Points: Test the Chrome Driver It's rather involved process, but here we go! In your Moodle config file, comment out any Behat profiles (EG: $CFG->behat_profiles). Then add this: $CFG->behat_config = [ 'default' => [ 'extensions' => [ 'DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension' => [], 'Behat\MinkExtension' => [ 'browser_name' => 'chrome', 'base_url' => $CFG->behat_wwwroot, 'goutte' => null, 'selenium2' => null, 'sessions' => [ 'javascript' => [ 'chrome' => [ 'api_url' => 'http://localhost:9222' ] ] ] ] ] ], ]; Grab the Behat extension and Mink driver, run this in the root of Moodle: composer require --dev dmore/behat-chrome-extension composer require --dev dmore/chrome-mink-driver Need to install Chrome 59 or later. Then run Chrome: chrome --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 Or in headless mode (required for parallel Behat runs): chrome --disable-gpu --headless --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 Where "chrome" is the path to the Chrome app. On Mac OS, it's in "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome". See https://developers.google.com/web/updates/2017/04/headless-chrome for more details. Lastly, initialize the Behat environment and run the JS tests like so: php admin/tool/behat/cli/run.php --tags="@javascript&&~@_alert" The $CFG->behat_faildump_path should work just like when using Selenium. Once set, you can purposefully fail a JS scenario and it should capture a screenshot.
    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-58948_chrome_mink_driver

      Description

      There is a new project where they built a mink driver to talk directly to Chrome instead of going through Selenium. They saw speed improvements for a test suite go from 60 minutes to 18 minutes.

      Project: https://gitlab.com/DMore/chrome-mink-driver - read the intro for more details.

      Example project using the driver: https://gitlab.com/DMore/behat-chrome-skeleton

      The speed improvements and the reduced complexity (EG: no java, Selenium, xvfb, chrome-driver, etc) warrant a strong look at this driver for inclusion into core.

      My personal wishlist is that if this all works out, it could be backported to Moodle 3.2 so it could be used in moodle-plugin-ci version 2 for Travis CI. If not, that's OK, just asking is all.

        Attachments

        1. alertSupportForChromeDriver.patch
          1 kB
        2. behat_slow_start.patch
          0.5 kB
        3. failed.txt
          12 kB
        4. progress.txt
          502 kB

          Issue Links

            Activity

              People

              • Votes:
                13 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/Nov/17