Just me having problems with Behat "I follow"?

Just me having problems with Behat "I follow"?

by Dave Balch -
Number of replies: 5

Hi,

Is anyone else seeing problems with Behat not finding an element that is definitely on the page? Seems like there may be an XPath problem...

I have a scenario that starts with:

And I log in as "teacher1"
And I follow "Course 1"
And I follow "Test assignment name"
And I follow "View all submissions"

...and when running it, the first two "I follow" steps are navigated, but it fails on the third (View all submissions", html attached), with this error:


001 Scenario: Teacher/Regsitry can add/view a private comment, Director can only view. Student cannot see at all. # /home/balchd/moodledev/instances/study_M33/moodle/mod/assign/feedback/privatecomments/tests/behat/assignfeedback_privatecomments.feature:61
      And I follow "View all submissions"                                                                         # /home/balchd/moodledev/instances/study_M33/moodle/mod/assign/feedback/privatecomments/tests/behat/assignfeedback_privatecomments.feature:67
        The "(//html/.//a
        [./@href][((./@id = 'View all submissions' or contains(normalize-space(string(.)), 'View all submissions') or contains(./@title, 'View all submissions') or contains(./@rel, 'View all submissions')) or .//*[(contains(concat(' ', @class, ' '), ' icon ') or name() = 'img') and (contains(./@alt, 'View all submissions') or contains(./@title, 'View all submissions'))])] | //html/.//*
        [translate(./@role, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'link'][((./@id = 'View all submissions' or contains(./@value, 'View all submissions')) or contains(./@title, 'View all submissions') or contains(normalize-space(string(.)), 'View all submissions'))])[1]" xpath node is not visible and it should be visible (Behat\Mink\Exception\ExpectationException)

I've started trying to debug that XPath, but am currently going round in circles where it seems like I can't even get a basic XSLT "Hello world" working. 

Has anyone else come across this?

Average of ratings: -
In reply to Dave Balch

Re: Just me having problems with Behat "I follow"?

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

And I follow "Course 1"

should be modified to

And I am on "Course 1" course homepage

In reply to Dave Balch

Re: Just me having problems with Behat "I follow"?

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

And there are 2 'View all submissions' links on the page, but they are not visible. 

In reply to Renaat Debleu

Re: Just me having problems with Behat "I follow"?

by Dave Balch -

Thanks for your reply.

Hmm, I know there are two links (which is why I'm surprised that the step fails) - and the one in the actions menu is hidden, but I can see the other, under the grading summary - is that one hidden for you?

Cheers,
Dave.

In reply to Dave Balch

Re: Just me having problems with Behat "I follow"?

by Dave Balch -

Ah, I have found that inserting a "I pause" and using it to open the action menu fixes that step - so presumably the XPath finds the first link with my text, but fails to use it because it is not visible. Umm, just like the error indicates!

Yet again I have to tell myself to read what the error message says, rather than what I think it says sleepy

Edit: So the solution was to use 'When I navigate to "View all submissions" in current page administration', rather than 'And I follow "View all submissions"' (per https://docs.moodle.org/dev/Acceptance_testing/Compatibility_changes#And_I_click_on_.22Edit_settings.22_.22link.22_in_the_.22Administration.22_.22block.22 )