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

Behat run crashes if there is an exception thrown while taking a screenshot

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Set up:

      • You will need a behat testing environment configured to use Chrome/Chromium (Selenium will need chromedriver loaded, and you will need a chrome profile in your behat config).
      • Ensure $CFG->behat_faildump_path is set
      • Download the attached testing.zip, and place the testing folder within in /local. This contains a page with some simple javascript which opens an alert, and a behat test for that page which will fail due to the alert.

      Test script:

      1. Run behat init.
      2. Run the following behat command: behat --profile=chrome --tags=broken_test.
      3. The first scenario will run, but will fail at the second step as an alert is open. The second scenario will run and pass.
      4. Look in the behat faildump folder.
      5. (3.0) There should be an HTML dump for the failed test, and a text file, but no screenshot. The text file should contain the exception message from an UnexpectedAlertOpen exception.
      6. (3.1) There should be a text file, and an HTML file. Both files should contain the exception message from an UnexpectedAlertOpen exception.
      Show
      Set up: You will need a behat testing environment configured to use Chrome/Chromium (Selenium will need chromedriver loaded, and you will need a chrome profile in your behat config). Ensure $CFG->behat_faildump_path is set Download the attached testing.zip, and place the testing folder within in /local. This contains a page with some simple javascript which opens an alert, and a behat test for that page which will fail due to the alert. Test script: Run behat init. Run the following behat command: behat --profile=chrome --tags=broken_test . The first scenario will run, but will fail at the second step as an alert is open. The second scenario will run and pass . Look in the behat faildump folder. (3.0) There should be an HTML dump for the failed test, and a text file, but no screenshot. The text file should contain the exception message from an UnexpectedAlertOpen exception. (3.1) There should be a text file, and an HTML file. Both files should contain the exception message from an UnexpectedAlertOpen exception.
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull Master Branch:
      MDL-54180_master

      Description

      It is possible for an exception to be thrown while taking a screenshot in the after_step_javascript() behat hook. One such case is where these is an alert open, ChromeDriver cannot take a screenshot and throws UnexpectedAlertException instead. It appears that \WebDriver\Exception\ScriptTimeout can be thrown in some cases, but I've not managed to reproduce this reliably.

      Steps to reproduce:

      • Unzip the attached plugin and place it in /local
      • Ensure you have behat faildumps configured.
      • Run the behat init script
      • Run /local/testing/tests/behat/broken.feature in Chrome.
      • The first scenario will run, reach the second step, then the behat run will crash with a \WebDriver\Exception\UnexpectedAlertOpen exception
      • The faildump directory for the run will be empty.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jul/16