B2G/QA/Automation/Style Guide/Howtos: Difference between revisions

(→‎Handling shadow DOM: content added)
Line 81: Line 81:
== Handling browser instances  ==
== Handling browser instances  ==
TBD - mwargers
TBD - mwargers
== Returning the page object after completing an action ==
== Returning the page object after completing an action <njpark>==
TBD - njpark
When invoking a certain UI action causes the phone to open a new page, it is recommended to return the appropriate page object.  <br />
When writing methods that is doing some action on the device, for instance opening an app or opening a subpage, make sure that the resulting action is finished and return the object of the resulting action, e.g. the app or the subpage (PageRegion)
On a related note, each page should have its own class definition, where it lists methods that manipulates and checks the associated UI elements.
<br>
<source python>
      music_app.wait_for_music_tiles_displayed()
 
        # tapping albums tab returns the list_view object,
        # because it opens the new view
        list_view = music_app.tap_albums_tab()
 
        # tapping the first album returns the sublist_view object
        sublist_view = albums[0].tap_first_album()
       
        # tapping the song opens the player view
        player_view = sublist_view.tap_first_song()
 
        # select stop
        player_view.tap_play()
</source>
352

edits