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

behat_course::i_add_to_section() fails without javascript

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a new file at lib/tests/behat/test_foo.feature

        @mod @mod_test
        Feature: Add test activity
         
          Scenario: Add a activity 
            Given the following "users" exist:
              | username | firstname | lastname | email                |
              | teacher1 | Teacher   | 1        | teacher1@example.com |
            And the following "courses" exist:
              | fullname | shortname | category |
              | Course 1 | C1        | 0        |
            And the following "course enrolments" exist:
              | user     | course | role           |
              | teacher1 | C1     | editingteacher |
            When I log in as "teacher1"
            And I am on "Course 1" course homepage
            And I turn editing mode on
            Then I add a "File" to section "1"
        

      2. Initialise behat
      3. Run the test (with --tags='@mod_test')
        1. Confirm that it Errored out with an informative message telling you how to fix it
      Show
      Create a new file at lib/tests/behat/test_foo.feature @mod @mod_test Feature: Add test activity Scenario: Add a activity Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | When I log in as "teacher1" And I am on "Course 1" course homepage And I turn editing mode on Then I add a "File" to section "1" Initialise behat Run the test (with --tags='@mod_test' ) Confirm that it Errored out with an informative message telling you how to fix it
    • Affected Branches:
      MOODLE_311_STABLE, MOODLE_400_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull 3.11 Branch:
      MDL-71874-311
    • Pull Master Branch:
      MDL-71874-master

      Description

      When running the step without javascript, behat_course::i_add_to_section() fails. This was tested with selenium chrome.

      We first encountered the problem in this feature with the CI failing for example here https://github.com/learnweb/moodle-mod_moodleoverflow/runs/2774655894#step:12:141 .

      This minimal example fails as well.

      @mod @mod_test
      Feature: Add test activity
       
        Scenario: Add a activity 
          Given the following "users" exist:
            | username | firstname | lastname | email                |
            | teacher1 | Teacher   | 1        | teacher1@example.com |
          And the following "courses" exist:
            | fullname | shortname | category |
            | Course 1 | C1        | 0        |
          And the following "course enrolments" exist:
            | user     | course | role           |
            | teacher1 | C1     | editingteacher |
          When I log in as "teacher1"
          And I am on "Course 1" course homepage
          And I turn editing mode on
          Then I add a "File" to section "1"
      

            Behat\Mink\Exception\ElementNotFoundException: Xpath matching locator "//li[@id='section-1']/descendant::div[contains(concat(' ', normalize-space(@class), ' '), ' section_add_menus ')]/descendant::select[option[normalize-space(.)='File']]" not found. in /var/www/public/moodle311/lib/behat/classes/behat_session_trait.php:133
            Stack trace:
            #0 /var/www/public/moodle311/lib/behat/classes/behat_session_trait.php(91): behat_base->find_all()
            #1 /var/www/public/moodle311/course/tests/behat/behat_course.php(266): behat_base->find()
      

      When running these steps with javascript, they pass as expected. This seems to be a bug, as course/tests/behat/behat_course::i_add_to_section() has a special distinction for when javascript is deactivated. (Line 259)

        Attachments

          Activity

            People

            Assignee:
            dobedobedoh Andrew Lyons
            Reporter:
            justusdieckmann Justus Dieckmann
            Peer reviewer:
            Huong Nguyen Huong Nguyen
            Integrator:
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Tester:
            Carlos Castillo Carlos Castillo
            Participants:
            Component watchers:
            Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            8 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              29/Jul/21

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 10 minutes
                1h 10m