Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
behat_app Class Reference
Inheritance diagram for behat_app:
behat_base behat_session_interface

Public Member Functions

 getSession ($name=null)
 Returns the Mink session. More...
 
 i_close_the_browser_tab_opened_by_the_app ()
 Closes the current browser tab. More...
 
 i_close_the_popup_in_the_app ()
 Closes a popup by clicking on the 'backdrop' behind it. More...
 
 i_enter_the_app ()
 Opens the Moodle app in the browser. More...
 
 i_press_in_the_app (string $text)
 Clicks on / touches something that is visible in the app. More...
 
 i_press_near_in_the_app (string $text, string $near)
 Clicks on / touches something that is visible in the app, near some other text. More...
 
 i_press_the_standard_button_in_the_app (string $button)
 Presses standard buttons in the app. More...
 
 i_set_the_field_in_the_app (string $field, string $value)
 Sets a field to the given text value in the app. More...
 
 i_switch_offline_mode (string $offline)
 Switch navigator online mode. More...
 
 i_switch_to_the_browser_tab_opened_by_the_app ()
 Switches to a newly-opened browser tab. More...
 
 login (string $username)
 Carries out the login steps for the app, assuming the user is on the app login page. More...
 
 start_scenario ()
 Called from behat_hooks when a new scenario starts, if it has the app tag. More...
 
 the_header_should_be_in_the_app (string $text)
 Checks that the current header stripe in the app contains the expected text. More...
 

Static Public Member Functions

static close_ionic ()
 Closes Ionic (if it was started) at end of test suite. More...
 

Public Attributes

const EXTENDED_TIMEOUT = 10
 And extended timeout for specific cases. More...
 
const PAGE_READY_JS
 The JS code to check that the page is ready. More...
 
const REDUCED_TIMEOUT = 2
 Small timeout. More...
 
const TIMEOUT = 6
 The timeout for each Behat step (load page, wait for an element to load...). More...
 

Protected Member Functions

 check_behat_setup ()
 Checks the Behat setup - tags and configuration. More...
 
 fix_moodle_setup ()
 Fixes the Moodle admin settings to allow mobile app use (if not already correct). More...
 
 prepare_browser (string $url)
 Goes to the app page and then sets up some initial JavaScript so we can use it. More...
 
 press (string $text, string $near='')
 Clicks on / touches something that is visible in the app, near some other text. More...
 
 start_or_reuse_ionic ()
 Starts an Ionic server if necessary, or uses an existing one. More...
 

Static Protected Member Functions

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

Protected Attributes

string $ionicurl = ''
 URL for running Ionic server.
 

Static Protected Attributes

static stdClass $ionicrunning = null
 Object with data about launched Ionic instance (if any)
 

Member Function Documentation

◆ check_behat_setup()

behat_app::check_behat_setup ( )
protected

Checks the Behat setup - tags and configuration.

Exceptions
DriverException

◆ close_ionic()

static behat_app::close_ionic ( )
static

Closes Ionic (if it was started) at end of test suite.

@AfterSuite

◆ fix_moodle_setup()

behat_app::fix_moodle_setup ( )
protected

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

Exceptions
dml_exceptionIf there is any problem changing Moodle settings

◆ getSession()

behat_session_interface::getSession (   $name = null)
inherited

Returns the Mink session.

Parameters
string | null$namename of the session OR active session will be used
Return values
Behat::Mink::Session

Implemented in behat_form_field.

◆ i_close_the_browser_tab_opened_by_the_app()

behat_app::i_close_the_browser_tab_opened_by_the_app ( )

Closes the current browser tab.

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

@Given /^I close the browser tab opened by the app$/

Exceptions
DriverExceptionIf there aren't exactly 2 tabs open

◆ i_close_the_popup_in_the_app()

behat_app::i_close_the_popup_in_the_app ( )

Closes a popup by clicking on the 'backdrop' behind it.

@Given /^I close the popup in the app$/

Exceptions
DriverExceptionIf there isn't a popup to close

◆ i_enter_the_app()

behat_app::i_enter_the_app ( )

Opens the Moodle app in the browser.

Requires JavaScript.

@Given /^I enter the app$/

Exceptions
DriverExceptionIssue with configuration or feature file
dml_exceptionProblem with Moodle setup
ExpectationExceptionProblem with resizing window

◆ i_press_in_the_app()

behat_app::i_press_in_the_app ( string  $text)

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.

@Given /^I press "(?P<text_string>(?:[^"]|::")*)" in the app$/

Parameters
string$textText identifying click target
Exceptions
DriverExceptionIf the press doesn't work

◆ i_press_near_in_the_app()

behat_app::i_press_near_in_the_app ( string  $text,
string  $near 
)

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.

@Given /^I press "(?P<text_string>(?:[^"]|::")*)" near "(?P<nearby_string>(?:[^"]|")*)" in the app$/

Parameters
string$textText identifying click target
string$nearText identifying a nearby unique piece of text
Exceptions
DriverExceptionIf the press doesn't work

◆ i_press_the_standard_button_in_the_app()

behat_app::i_press_the_standard_button_in_the_app ( string  $button)

Presses standard buttons in the app.

@Given /^I press the (?P<button_name>back|main menu|page menu) button in the app$/

Parameters
string$buttonButton type
Exceptions
DriverExceptionIf the button push doesn't work

◆ i_set_the_field_in_the_app()

behat_app::i_set_the_field_in_the_app ( string  $field,
string  $value 
)

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.

@Given /^I set the field "(?P<field_name>(?:[^"]|::")*)" to "(?P<text_string>(?:[^"]|")*)" in the app$/

Parameters
string$fieldText identifying field
string$valueValue for field
Exceptions
DriverExceptionIf the field set doesn't work

◆ i_switch_offline_mode()

behat_app::i_switch_offline_mode ( string  $offline)

Switch navigator online mode.

@Given /^I switch offline mode to "(?P<offline_string>(?:[^"]|::")*)"$/

Parameters
string$offlineNew value for navigator online mode
Exceptions
DriverExceptionIf the navigator.online mode is not available

◆ i_switch_to_the_browser_tab_opened_by_the_app()

behat_app::i_switch_to_the_browser_tab_opened_by_the_app ( )

Switches to a newly-opened browser tab.

This assumes the app opened a new tab.

@Given /^I switch to the browser tab opened by the app$/

Exceptions
DriverExceptionIf there aren't exactly 2 tabs open

◆ is_windows()

static behat_app::is_windows ( )
staticprotected

Checks if the current OS is Windows, from the point of view of task-executing-and-killing.

Return values
boolTrue if Windows

◆ login()

behat_app::login ( string  $username)

Carries out the login steps for the app, assuming the user is on the app login page.

Called from behat_auth.php.

Parameters
string$usernameUsername (and password)
Exceptions
ExceptionAny error

◆ prepare_browser()

behat_app::prepare_browser ( string  $url)
protected

Goes to the app page and then sets up some initial JavaScript so we can use it.

Parameters
string$urlApp URL
Exceptions
DriverExceptionIf the app fails to load properly

◆ press()

behat_app::press ( string  $text,
string  $near = '' 
)
protected

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.

Parameters
behat_base$baseBehat context
string$textText identifying click target
string$nearText identifying a nearby unique piece of text
Exceptions
DriverExceptionIf the press doesn't work

◆ start_or_reuse_ionic()

behat_app::start_or_reuse_ionic ( )
protected

Starts an Ionic server if necessary, or uses an existing one.

Return values
stringURL to Ionic server
Exceptions
DriverExceptionIf there's a system error starting Ionic

◆ start_scenario()

behat_app::start_scenario ( )

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.

◆ the_header_should_be_in_the_app()

behat_app::the_header_should_be_in_the_app ( string  $text)

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.

@Then /^the header should be "(?P<text_string>(?:[^"]|::")*)" in the app$/

Parameters
string$textExpected header text
Exceptions
DriverExceptionIf the header can't be retrieved
ExpectationExceptionIf the header text is different to the expected value

Member Data Documentation

◆ EXTENDED_TIMEOUT

const behat_session_interface::EXTENDED_TIMEOUT = 10
inherited

And extended timeout for specific cases.

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_extended_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_extended_timeout()

◆ PAGE_READY_JS

const behat_session_interface::PAGE_READY_JS
inherited
Initial value:
= "document.readyState === 'complete' && " .
"(typeof M !== 'object' || typeof M.util !== 'object' || " .
"typeof M.util.pending_js === 'undefined' || M.util.pending_js.length === 0)"

The JS code to check that the page is ready.

The document must be complete and either M.util.pending_js must be empty, or it must not be defined at all.

◆ REDUCED_TIMEOUT

const behat_session_interface::REDUCED_TIMEOUT = 2
inherited

Small timeout.

A reduced timeout for cases where self::TIMEOUT is too much and a simple $this->getSession()->getPage()->find() could not be enough.

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_reduced_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_reduced_timeout()

◆ TIMEOUT

const behat_session_interface::TIMEOUT = 6
inherited

The timeout for each Behat step (load page, wait for an element to load...).

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_timeout()

The documentation for this class was generated from the following file: