Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Mobile/desktop app steps definitions.

Copyright: 2018 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 551 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/behat/behat_base.php

Defines 1 class


Class: behat_app  - X-Ref

Mobile/desktop app steps definitions.

is_windows()   X-Ref
Checks if the current OS is Windows, from the point of view of task-executing-and-killing.

return: bool True if Windows

start_scenario()   X-Ref
Called from behat_hooks when a new scenario starts, if it has the app tag.

This updates Moodle configuration and starts Ionic running, if it isn't already.

i_enter_the_app()   X-Ref
Opens the Moodle app in the browser.

Requires JavaScript.


check_behat_setup()   X-Ref
Checks the Behat setup - tags and configuration.


fix_moodle_setup()   X-Ref
Fixes the Moodle admin settings to allow mobile app use (if not already correct).


start_or_reuse_ionic()   X-Ref
Starts an Ionic server if necessary, or uses an existing one.

return: string URL to Ionic server

close_ionic()   X-Ref
Closes Ionic (if it was started) at end of test suite.


prepare_browser(string $url)   X-Ref
Goes to the app page and then sets up some initial JavaScript so we can use it.

param: string $url App URL

login(string $username)   X-Ref
No description

i_press_the_standard_button_in_the_app(string $button)   X-Ref
No description

i_close_the_popup_in_the_app()   X-Ref
Closes a popup by clicking on the 'backdrop' behind it.


i_press_in_the_app(string $text)   X-Ref
Clicks on / touches something that is visible in the app.

Note it is difficult to use the standard 'click on' or 'press' steps because those do not
distinguish visible items and the app always has many non-visible items in the DOM.

param: string $text Text identifying click target

i_press_near_in_the_app(string $text, string $near)   X-Ref
Clicks on / touches something that is visible in the app, near some other text.

This is the same as the other step, but when there are multiple matches, it picks the one
nearest (in DOM terms) the second text. The second text should be an exact match, or a partial
match that only has one result.

param: string $text Text identifying click target
param: string $near Text identifying a nearby unique piece of text

press(string $text, string $near = '')   X-Ref
Clicks on / touches something that is visible in the app, near some other text.

If the $near is specified then when there are multiple matches, it picks the one
nearest (in DOM terms) $near. $near should be an exact match, or a partial match that only
has one result.

param: behat_base $base Behat context
param: string $text Text identifying click target
param: string $near Text identifying a nearby unique piece of text

i_set_the_field_in_the_app(string $field, string $value)   X-Ref
Sets a field to the given text value in the app.

Currently this only works for input fields which must be identified using a partial or
exact match on the placeholder text.

param: string $field Text identifying field
param: string $value Value for field

the_header_should_be_in_the_app(string $text)   X-Ref
Checks that the current header stripe in the app contains the expected text.

This can be used to see if the app went to the expected page.

param: string $text Expected header text

i_switch_to_the_browser_tab_opened_by_the_app()   X-Ref
Switches to a newly-opened browser tab.

This assumes the app opened a new tab.


i_close_the_browser_tab_opened_by_the_app()   X-Ref
Closes the current browser tab.

This assumes it was opened by the app and you will now get back to the app.


i_switch_offline_mode(string $offline)   X-Ref
Switch navigator online mode.

param: string $offline New value for navigator online mode