Got it!
replace
And I click on "Save changes" "button"
with
And I press "id_submitbutton"
PS.- Another rubber duck moment!
Got it!
replace
And I click on "Save changes" "button"
with
And I press "id_submitbutton"
PS.- Another rubber duck moment!
In my regexp Behat tests I would like to check that the validation error messages work. I have this scenario:
Scenario: Create a Regexp question
When I am on the "Course 1" "core_question > course question bank" page logged in as teacher
And I add a "Regular expression short answer" question filling the form with:
| Question name | regularshortanswer-001 |
| Question text | How much does this computer cost? |
| Default mark | 1 |
| Case sensitivity | Yes, case must match |
| id_answer_0 | 799.99$ |
| id_fraction_0 | 100% |
| id_feedback_0 | OK. |
| id_answer_1 | approximately 800$ |
| id_fraction_1 | 90% |
| id_feedback_1 | Almost. |
Then I should see "In Answers with a grade > 0 these unescaped metacharacters are not allowed: . ^ $ * + { } \"
And I set the field with xpath "//input[contains(@id, 'id_answer_1')]" to "approximately 800\$"
And I click on "Save changes" "button"
Then I should see "regularshortanswer-001"
Error message: "regularshortanswer-001" text was not found in the page (Behat\Mink\Exception\ExpectationException)
The reason for this error is that the scenario never presses the Save changes button on the question edit form. Do I have to issue a special command after setting a field with xpath? Be more specific in the location of the Save changes button? Or should I simply give up on this validation test?
Then "Submit and finish" "button" should exist
does exactly what I need; it was perhaps too obvious for me to find it. But I still have not found a full list of all the Behat "commands" in the Moodle Behat docs ...
Thanks, Tim
The windows resize workaround mentioned by @Renaat does work.
However, I was still curious to know why my regexp question type behat edit.feature test threw that 'Element not clickable' error, while the original shortanswer edit.feature test did not throw an error. I systematically compared my test with the original shortanswer test, and finally found out the culprit.
In the shortanswer test we have:
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | shortanswer | shortanswer-001 for editing | frogtoad |
In my regexp test I changed this to:
And the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | shortanswer | regexpshortanswer-001 for editing | frenchflag |
The name I have given to my question is too long and causes the error. I shortened it to regexp-001 and the error is gone!
On the other hand if, in the shortanswere question test, I change shortanswer-001 to e.g. a-really-very-short-answer-001, the error message appears.
quod erat demonstrandum