Writing Behat tests with filepicker

Writing Behat tests with filepicker

by Yuliya Bozhko -
Number of replies: 4

Hi everyone!

First of all I would like to say that Behat integration with Moodle completely blew my mind big grin. This is really awesome and turning into a great fan of acceptance testing! approve

I started writing my own acceptance tests for openbadges feature yesterday, and came across a problem. It might be a silly question, but is there any way of using filepicker in Behat tests? My forms have compulsory badge images... and all tests fail because filepicker is a modal window... mixed Anyone can give me any advice on how to work around this problem?

Any help would be appeciated! Thanks!

Yuliya

Average of ratings: -
In reply to Yuliya Bozhko

Re: Writing Behat tests with filepicker

by David Monllaó -

Hi Yuliya,

At the moment the set of steps definitions is limited and there is no way to interact with the filepicker with the current ones, the same with other complex moodleform fields. We will be adding more steps definitions, don't hesitate to contribute if you have steps definitions that can be reused across Moodle or to open new issues.

About the filepicker and other complex fields, the design takes it into account but we should define a format for each of those complex form fields in order to continue using simple steps which makes tests writers life's easier, something like:

And I add a "Activityname" to section "3" and I fill the form with:

  | Name | basdasdasd |

  | Description | asdfasdf |

  | Attached file | URL Downloader ::  | (this was supposed to be an URL)

  | Another attached file | Upload a file :: blocks/tests/behat/fixtures/example.txt |

Considering also all the filepicker uses (single or multiple files..) dynamic parameters (it will all depend on the repository used) ... and the same with other moodleform fields as well; advanced, groups...

The quick alternative is to use XPath or CSS selectors step by step to interact with the filepicker HTML nodes, soon we will add some of those flexible steps definitions, which are not very BDD or human-friendly as they require CSS selectors or XPath, but can be used when there are no alternatives.

Average of ratings: Useful (1)
In reply to David Monllaó

Re: Writing Behat tests with filepicker

by Yuliya Bozhko -

Hi David,

Thanks for your advice! I will have a look what I can do. It will probably be a quick fix using XPath as I am not sure how much time I can spend on acceptance testing.

Yuliya

In reply to Yuliya Bozhko

Re: Writing Behat tests with filepicker

by David Monllaó -

Work done in https://tracker.moodle.org/browse/MDL-38184 currently waiting for peer review and depending on other blocker issues.

Average of ratings: Useful (1)