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

Behat: Add step to check attribute

    Details

    • Testing Instructions:
      Hide

      0. Place attached temporary file mdl44891.feature in the location course/tests/behat within your Moodle installation.
      1. Ensure Behat is working in general, including running the behat init script.
      2. Run Behat with --tags=mdl44891

      EXPECTED: You should see 2 scenarios both passed (usually takes a minute or two).

      3. Edit the .feature file to change both instances of 'has-region-side-pre' by inserting an x in the name (so that the attribute does not in fact contain that value).
      4. Rerun the same test

      EXPECTED:
      This time there should be 2 failures indicated and you should see a message like:
      01. The attribute "class" does not contain "haxs-region-side-pre" (actual value: "format-site course path-site [...and so on, it's kind of a long attribute....]")

      Show
      0. Place attached temporary file mdl44891.feature in the location course/tests/behat within your Moodle installation. 1. Ensure Behat is working in general, including running the behat init script. 2. Run Behat with --tags=mdl44891 EXPECTED: You should see 2 scenarios both passed (usually takes a minute or two). 3. Edit the .feature file to change both instances of 'has-region-side-pre' by inserting an x in the name (so that the attribute does not in fact contain that value). 4. Rerun the same test EXPECTED: This time there should be 2 failures indicated and you should see a message like: 01. The attribute "class" does not contain "haxs-region-side-pre" (actual value: "format-site course path-site [...and so on, it's kind of a long attribute....] ")
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull 2.6 Branch:
      MDL-44891-m26
    • Pull Master Branch:
      MDL-44891-master

      Description

      Behat is intended to check user-visible effects in the resulting HTML. Sometimes these effects are implemented using attribute values (two common examples are the alt= attribute, which is visible to screenreader users, and the title= attribute, which is visible to all users; there's also the src attribute of images, and lots of other possibilities too).

      There is currently no step that checks an attribute value. This seems like a simple and generic step. I propose the following:

      Then the "title" attribute of "Amphibians" "select" should contain "Choose your amphibian"

      This step is necessary for MDL-44070 so that I can check that a toggle icon changes status when clicked (it changes its alt=, title=, and src= so I need to check one of them!).

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            quen Sam Marshall added a comment -

            Note: This is not really blocked by MDL-44890 but I made it based on that commit (otherwise they conflict - a trivial conflict but still, why make headaches). If MDL-44890 were rejected and this approved, I can remake the commit so it isn't based on the other one.

            Show
            quen Sam Marshall added a comment - Note: This is not really blocked by MDL-44890 but I made it based on that commit (otherwise they conflict - a trivial conflict but still, why make headaches). If MDL-44890 were rejected and this approved, I can remake the commit so it isn't based on the other one.
            Show
            cibot CiBoT added a comment - Results for MDL-44891 Remote repository: https://github.com/sammarshallou/moodle.git Remote branch MDL-44891 -m25 to be integrated into upstream MOODLE_25_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2657 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2657/artifact/work/smurf.html Remote branch MDL-44891 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2658 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2658/artifact/work/smurf.html Remote branch MDL-44891 -master to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/2659 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/2659/artifact/work/smurf.html
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            While probably this could be achieved by some other rudimentary available steps, I like this exact one a lot:

            • it's simple.
            • it's generic.
            • it's powerful.

            So my +1 to send it to integration (all branches).

            Note that, if landing "alone" it will need some specific .feature to verify it's working ok. If landing with MDL-44070, testing can be delegated to it, although I find it less optimal as far as this is defined as blocker, hence has to land earlier.

            So I'd suggest to do add some trivial .feature to the issue (does not need to be added to core) and fill testing instructions to run it.

            Ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - While probably this could be achieved by some other rudimentary available steps, I like this exact one a lot: it's simple. it's generic. it's powerful. So my +1 to send it to integration (all branches). Note that, if landing "alone" it will need some specific .feature to verify it's working ok. If landing with MDL-44070 , testing can be delegated to it, although I find it less optimal as far as this is defined as blocker, hence has to land earlier. So I'd suggest to do add some trivial .feature to the issue (does not need to be added to core) and fill testing instructions to run it. Ciao
            Hide
            quen Sam Marshall added a comment -

            Thanks very much for the review Eloy. I've rebased the branches and added a temporary feature file in the testing instructions, as suggested. Will submit to integration.

            Show
            quen Sam Marshall added a comment - Thanks very much for the review Eloy. I've rebased the branches and added a temporary feature file in the testing instructions, as suggested. Will submit to integration.
            Hide
            quen Sam Marshall added a comment -

            I've rebased again to latest code. There was also a slight change (thanks Marina) to correct the format of the regular expression, so that it shows up correctly on the documentation page with the dropdown thingy.

            Show
            quen Sam Marshall added a comment - I've rebased again to latest code. There was also a slight change (thanks Marina) to correct the format of the regular expression, so that it shows up correctly on the documentation page with the dropdown thingy.
            Hide
            cibot CiBoT added a comment -

            Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

            Show
            cibot CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
            Hide
            marina Marina Glancy added a comment -

            Thanks Sam, this looks like a good step.

            I tested on existing behat feature by making the change:

            diff --git a/course/tests/behat/activities_group_icons.feature b/course/tests/behat/activities_group_icons.feature
            index 35dbee9..88a9575 100644
            --- a/course/tests/behat/activities_group_icons.feature
            +++ b/course/tests/behat/activities_group_icons.feature
            @@ -27,7 +27,7 @@ Feature: Toggle activities groups mode from the course page
                   | Force group mode | No |
                 When I press "Save changes"
                 Then "No groups (Click to change)" "link" should exist
            -    And "//a/child::img[contains(@src, 'groupn')]" "xpath_element" should exist
            +    And the "src" attribute of "a.cm-edit-action img" "css_element" should contain "groupn"
                 And I click on "No groups (Click to change)" "link" in the "Test forum name" activity
                 And "Separate groups (Click to change)" "link" should exist
                 And "//a/child::img[contains(@src, 'groups')]" "xpath_element" should exist
            

            We usually create pairs of steps i.e. "should contain" and "should not contain". Will it be too much to ask for an opposite step?

            Show
            marina Marina Glancy added a comment - Thanks Sam, this looks like a good step. I tested on existing behat feature by making the change: diff --git a/course/tests/behat/activities_group_icons.feature b/course/tests/behat/activities_group_icons.feature index 35dbee9..88a9575 100644 --- a/course/tests/behat/activities_group_icons.feature +++ b/course/tests/behat/activities_group_icons.feature @@ -27,7 +27,7 @@ Feature: Toggle activities groups mode from the course page | Force group mode | No | When I press "Save changes" Then "No groups (Click to change)" "link" should exist - And "//a/child::img[contains(@src, 'groupn')]" "xpath_element" should exist + And the "src" attribute of "a.cm-edit-action img" "css_element" should contain "groupn" And I click on "No groups (Click to change)" "link" in the "Test forum name" activity And "Separate groups (Click to change)" "link" should exist And "//a/child::img[contains(@src, 'groups')]" "xpath_element" should exist We usually create pairs of steps i.e. "should contain" and "should not contain". Will it be too much to ask for an opposite step?
            Hide
            marina Marina Glancy added a comment -

            Since it's blocking the conditional availability, I'm integrating it as is. I'll create another issue for opposite step.

            Thanks, integrated in master, 2.6 and 2.5

            Show
            marina Marina Glancy added a comment - Since it's blocking the conditional availability, I'm integrating it as is. I'll create another issue for opposite step. Thanks, integrated in master, 2.6 and 2.5
            Hide
            marina Marina Glancy added a comment -

            Created an issue MDL-44991 for opposite step

            Show
            marina Marina Glancy added a comment - Created an issue MDL-44991 for opposite step
            Hide
            rajeshtaneja Rajesh Taneja added a comment -

            Thanks for fixing this Sam,

            Works great, passing...

            FYI: I used "pagelayout-frontpage" css name in feature file to test on 26 and 25 branches, as default theme is standard on them.

            Show
            rajeshtaneja Rajesh Taneja added a comment - Thanks for fixing this Sam, Works great, passing... FYI: I used "pagelayout-frontpage" css name in feature file to test on 26 and 25 branches, as default theme is standard on them.
            Hide
            quen Sam Marshall added a comment -

            Thanks! Sorry for bad example, I hadn't realised that was different between themes.

            Show
            quen Sam Marshall added a comment - Thanks! Sorry for bad example, I hadn't realised that was different between themes.
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks for your efforts, this change is now part of Moodle!

            Show
            poltawski Dan Poltawski added a comment - Thanks for your efforts, this change is now part of Moodle!

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/May/14