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

Behat: Setting a file upload in form works only in single scenario

    XMLWordPrintable

Details

    • MOODLE_27_STABLE
    • Hide

      As a workaround, you can use the following, horribler Behat steps that do it individually (4 steps instead of one, but not the end of the world):

          And I add a "File" to section "1"
          And I set the following fields to these values:
            | Name         | FileResource                  |
            | Description  | x                             |
          And I upload "/lib/tests/fixtures/empty.txt" file to "Select files" filemanager
          And I press "Save and return to course"
      

      Show
      As a workaround, you can use the following, horribler Behat steps that do it individually (4 steps instead of one, but not the end of the world): And I add a "File" to section "1" And I set the following fields to these values: | Name | FileResource | | Description | x | And I upload "/lib/tests/fixtures/empty.txt" file to "Select files" filemanager And I press "Save and return to course"

    Description

      The Behat step to set form fields for a Resource including the file to upload is:

          And I add a "File" to section "1" and I fill the form with:
            | Name         | FileResource                  |
            | Description  | x                             |
            | Select files | /lib/tests/fixtures/empty.txt |
      

      This works perfectly, when run in a single scenario. When you run another scenario previously, the step fails.

      To reproduce:

      1. Download the attached issue_test.feature file.
      2. Put this in the lib/tests/behat folder.
      3. Run behat init.
      4. Run behat with --tags=behatworks

      Observe that the scenario completes successfully.

      5. Run behat with --tags=behatbug

      Observe that the same scenario now fails, just by virtue of having another scenario run previously (which does nothing).

      (Tested on current master and 2.7.x.)

      Attachments

        Issue Links

          Activity

            People

              rajeshtaneja Rajesh Taneja
              quen Sam Marshall
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: