352
edits
(→Switching frames and system frame: system frame added) |
(content added) |
||
Line 101: | Line 101: | ||
</source> | </source> | ||
== Handling browser | == Handling Browser Instances == | ||
As mentioned above, there is a difference between Browser and Browser Tabs. Also, the browser elements (URL bar, dialogs, buttons, etc.) are on a separate frame (system frame) from the displayed web contents. <br>In order to properly detect and manipulate all of them, it is necessary to switch between separate frames. | |||
<source python> | |||
search = Search(self.marionette) | |||
search.launch() | |||
# Note that within the go_to_url() method, it switches to the system frame, | |||
# operates with the URL bar, and then returns the browser instance object | |||
browser = search.go_to_url(self.test_url) | |||
# here, it switches to the iframe of the browser, to check the web content | |||
browser.switch_to_content() | |||
Wait(self.marionette).until(lambda m: m.title == 'Mozilla') | |||
link = self.marionette.find_element(By.CSS_SELECTOR, '#community a') | |||
link.tap() | |||
Wait(self.marionette).until(lambda m: m.title == 'Mozilla Community') | |||
# need to go back to the system frame in order to tap the back button. | |||
browser.switch_to_chrome() | |||
browser.tap_back_button() | |||
# need to switch into the iframe to check the displayed content | |||
browser.switch_to_content() | |||
Wait(self.marionette).until(lambda m: m.title == 'Mozilla') | |||
</source> | |||
== Returning the page object after completing an action == | == Returning the page object after completing an action == | ||
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 invoking a certain UI action causes the phone to open a new page, it is recommended to return the appropriate page object. <br /> |
edits