def test_launch_manifest(self): search = Search(self.marionette) search.launch() self.device.touch_home_button() search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') self.device.touch_home_button() # This should open the previous opened browser window search.launch() browser = search.go_to_url('data:text/html;charset=utf-8,<title>hello</title>') browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'hello') browser.switch_to_chrome() # This shouldn't do anything search.launch() self.device.hold_home_button() cards_view = CardsView(self.marionette) cards_view.wait_for_cards_view() cards_view.cards[0].wait_for_centered() self.assertEqual(len(cards_view.cards), 1, 'Should have 1 card to display') self.assertTrue(cards_view.cards[0].is_displayed) self.assertEqual(cards_view.cards[0].title, 'hello')
def test_cost_control_reset_wifi(self): self.data_layer.connect_to_wifi() cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() cost_control.toggle_mobile_data_tracking(False) cost_control.toggle_wifi_data_tracking(True) # open browser to get some data downloaded search = Search(self.marionette) search.launch() search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') self.data_layer.disable_wifi() time.sleep(5) # go back to Cost Control cost_control.launch() # if we can't trigger any data usage, there must be something wrong self.assertNotEqual(cost_control.wifi_data_usage_figure, u'0.00 B', 'No data usage shown after browsing.') # # go to settings section settings = cost_control.tap_settings() settings.reset_wifi_usage() settings.tap_done() # wait for usage to be refreshed self.wait_for_condition( lambda m: cost_control.wifi_data_usage_figure == u'0.00 B', message='Wifi usage did not reset back to 0.00 B')
def test_launch_manifest(self): search = Search(self.marionette) search.launch() self.device.touch_home_button() search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') self.device.touch_home_button() # This should open the previous opened browser window search.launch() browser = search.go_to_url( 'data:text/html;charset=utf-8,<title>hello</title>') browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'hello') browser.switch_to_chrome() # This shouldn't do anything search.launch() self.device.hold_home_button() cards_view = CardsView(self.marionette) cards_view.wait_for_cards_view() cards_view.wait_for_card_ready(search.manifest_url[:-16]) self.assertEqual(len(cards_view.cards), 1, 'Should have 1 card to display') self.assertTrue(cards_view.is_app_displayed(search.manifest_url[:-16]), 'Should have browser in cards view with title hello')
class TestBrowserSearch(GaiaMtbfTestCase): _google_search_input_locator = (By.NAME, 'q') def setUp(self): GaiaMtbfTestCase.setUp(self) self.data_layer.enable_wifi() self.connect_to_local_area_network() self.search = Search(self.marionette) self.search.launch() def test_browser_search(self): search_text = 'Mozilla' self.browser = self.search.go_to_url(search_text) self.browser.switch_to_content() Wait(self.marionette, timeout=120).until( expected.element_displayed(*self._google_search_input_locator)) self.assertTrue(search_text in self.marionette.title) self.assertEqual( search_text, self.marionette.find_element( *self._google_search_input_locator).get_attribute('value')) def tearDown(self): self.data_layer.disable_wifi() GaiaMtbfTestCase.tearDown(self)
def test_browser_clear_history(self): """ https://moztrap.mozilla.org/manage/cases/?filter-id=3582 """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') self.device.touch_home_button() search.launch() search.wait_for_history_to_load(number_of_items=1) self.assertGreater(search.history_items_count, 0) settings = Settings(self.marionette) settings.launch() browsing_privacy = settings.open_browsing_privacy_settings() browsing_privacy.tap_clear_browsing_history() browsing_privacy.tap_clear() self.device.touch_home_button() search.launch() search.wait_for_history_to_load(number_of_items=0) self.assertEqual(0, search.history_items_count)
class TestBrowserCellData(GaiaMtbfTestCase): _page_title_locator = (By.ID, 'page-title') def setUp(self): GaiaMtbfTestCase.setUp(self) self.data_layer.disable_wifi() self.data_layer.disable_cell_data() self.data_layer = GaiaData(self.marionette) self.data_layer.connect_to_cell_data() self.search = Search(self.marionette) self.search.launch() def test_browser_cell_data(self): """https://moztrap.mozilla.org/manage/case/1328/""" self.browser = self.search.go_to_url( 'http://mozqa.com/data/firefox/layout/mozilla.html') self.browser.wait_for_page_to_load(120) self.browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator, timeout=120) heading = self.marionette.find_element(*self._page_title_locator) self.assertEqual( heading.text, 'We believe that the internet should be public, open and accessible.' ) def tearDown(self): self.data_layer.disable_cell_data() GaiaMtbfTestCase.tearDown(self)
class TestBrowserCellData(GaiaMtbfTestCase): _page_title_locator = (By.ID, 'page-title') def setUp(self): GaiaMtbfTestCase.setUp(self) self.data_layer.disable_wifi() self.data_layer.disable_cell_data() self.data_layer = GaiaData(self.marionette) self.data_layer.connect_to_cell_data() self.search = Search(self.marionette) self.search.launch() def test_browser_cell_data(self): """https://moztrap.mozilla.org/manage/case/1328/""" self.browser = self.search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') self.browser.wait_for_page_to_load(120) self.browser.switch_to_content() heading = Wait(self.marionette, timeout=120).until(expected.element_present(*self._page_title_locator)) self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.') def tearDown(self): self.marionette.switch_to_frame() self.data_layer.disable_cell_data() GaiaMtbfTestCase.tearDown(self)
def test_browser_bookmark(self): search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.tap_menu_button() bookmark = browser.tap_add_to_home() bookmark.type_bookmark_title(self.bookmark_title) bookmark.tap_add_bookmark_to_home_screen_dialog_button() # Switch to Home Screen to look for bookmark self.device.touch_home_button() homescreen = Homescreen(self.marionette) homescreen.wait_for_app_icon_present(self.bookmark_title) self._bookmark_added = homescreen.is_app_installed(self.bookmark_title) self.assertTrue(self._bookmark_added, 'The bookmark %s was not found to be installed on the home screen.' % self.bookmark_title) # Delete the bookmark homescreen.activate_edit_mode() homescreen.bookmark(self.bookmark_title).tap_delete_app().tap_confirm(bookmark=True) homescreen.wait_to_be_displayed() self.apps.switch_to_displayed_app() homescreen.wait_for_bookmark_icon_not_present(self.bookmark_title) # Check that the bookmark icon is no longer displayed on the homescreen self._bookmark_added = homescreen.is_app_installed(self.bookmark_title) self.assertFalse(self._bookmark_added, 'The bookmark %s was not successfully removed from homescreen.' % self.bookmark_title)
def test_browser_clear_history(self): """ https://moztrap.mozilla.org/manage/cases/?filter-id=3582 """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette, timeout=30).until(lambda m: m.title == 'Mozilla') self.apps.kill(search.app) self.device.touch_home_button() search.launch() Wait(self.marionette).until(lambda m: len(m.find_elements(*search._history_item_locator)) > 0) self.assertGreater(search.history_items_count, 0) self.settings = Settings(self.marionette) self.settings.launch() browsing_privacy = self.settings.open_browsing_privacy() browsing_privacy.tap_clear_browsing_history() browsing_privacy.tap_clear() self.settings.return_to_prev_menu(self.settings.screen_element) self.device.touch_home_button() search.launch() search.wait_for_history_to_load(number_of_items=0) self.assertEqual(0, search.history_items_count)
def test_browser_save_image(self): """ https://moztrap.mozilla.org/manage/case/6889/ """ # Check that there are no images on sdcard before saving self.assertEqual(0, len(self.data_layer.sdcard_files('.jpeg'))) search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() # Long tap on the image inside the browser content image = self.marionette.find_element('css selector', 'img') Actions(self.marionette).\ press(image).\ wait(3).\ release().\ wait(1).\ perform() activities = Activities(self.marionette) activities.tap_save_image() system = System(self.marionette) system.wait_for_notification_toaster_displayed() system.wait_for_notification_toaster_not_displayed() self.assertEqual(1, len(self.data_layer.sdcard_files('.jpeg')))
class TestBrowserSearch(GaiaMtbfTestCase): _google_search_input_locator = (By.NAME, 'q') def setUp(self): GaiaMtbfTestCase.setUp(self) self.data_layer.enable_wifi() self.connect_to_local_area_network() self.search = Search(self.marionette) self.search.launch() def test_browser_search(self): search_text = 'Mozilla' self.browser = self.search.go_to_url(search_text) self.browser.switch_to_content() Wait(self.marionette, timeout=120).until( expected.element_displayed(*self._google_search_input_locator)) self.assertTrue(search_text in self.marionette.title) self.assertEqual(search_text, self.marionette.find_element(*self._google_search_input_locator).get_attribute('value')) def tearDown(self): self.data_layer.disable_wifi() GaiaMtbfTestCase.tearDown(self)
def test_browser_lan(self): """https://moztrap.mozilla.org/manage/case/1327/""" search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla')
def test_browser_clear_history(self): """ https://moztrap.mozilla.org/manage/cases/?filter-id=3582 """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette, timeout=30).until(lambda m: m.title == 'Mozilla') self.apps.kill(search.app) self.device.touch_home_button() search.launch() Wait(self.marionette).until( lambda m: len(m.find_elements(*search._history_item_locator)) > 0) self.assertGreater(search.history_items_count, 0) self.settings = Settings(self.marionette) self.settings.launch() browsing_privacy = self.settings.open_browsing_privacy() browsing_privacy.tap_clear_browsing_history() browsing_privacy.tap_clear() self.settings.return_to_prev_menu(self.settings.screen_element) self.device.touch_home_button() search.launch() search.wait_for_history_to_load(number_of_items=0) self.assertEqual(0, search.history_items_count)
def test_browser_clear_history(self): """ https://moztrap.mozilla.org/manage/cases/?filter-id=3582 """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette, timeout=30).until(lambda m: m.title == 'Mozilla') self.apps.kill(search.app) self.device.touch_home_button() search.launch() search.wait_for_history_to_load(number_of_items=1) self.assertGreater(search.history_items_count, 0) # This shouldn't be necessary, remove these 2 lines once bug 1216933 is fixed self.apps.kill(search.app) self.device.touch_home_button() settings = Settings(self.marionette) settings.launch() browsing_privacy = settings.open_browsing_privacy() confirm_dialog = browsing_privacy.clear_browsing_history() confirm_dialog.confirm_clear() self.device.touch_home_button() search.launch() search.wait_for_history_to_load(number_of_items=0) self.assertEqual(0, search.history_items_count)
def test_browser_navigation(self): search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() self.verify_home_page() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') self.take_screenshot() community_link = self.marionette.find_element(*self._community_link_locator) # TODO: remove the explicit scroll once bug 833370 is fixed self.marionette.execute_script("arguments[0].scrollIntoView(false);", [community_link]) community_link.tap() self.verify_community_page() self.take_screenshot() browser.switch_to_chrome() browser.tap_back_button() browser.switch_to_content() self.verify_home_page() self.take_screenshot() browser.switch_to_chrome() browser.tap_forward_button() browser.switch_to_content() self.verify_community_page() self.take_screenshot()
def browser_cell(self): # Start browser and load page and verify, code taken from test_browser_cell_data.py search = Search(self.marionette) search.launch() browser = search.go_to_url( 'http://mozqa.com/data/firefox/layout/mozilla.html') browser.wait_for_page_to_load(120) browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator, timeout=120) heading = self.marionette.find_element(*self._page_title_locator) self.assertEqual( heading.text, 'We believe that the internet should be public, open and accessible.' ) # Wait a couple of seconds with page displayed time.sleep(2) # Close browser via cards view self.app_under_test = "search" self.close_app() self.app_under_test = "browser" # Sleep between iterations time.sleep(10)
def test_browser_navigation(self): self.test_url = self.marionette.absolute_url( 'sample_websites/darkness/index.html') search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.wait_for_page_to_load() #TODO: remove the reloading and rechecking for elements when bug 1128034 is resolved, browser.tap_reload_button() browser.wait_for_page_to_load() browser.switch_to_content() Wait(self.marionette).until(lambda m: 'Darkness' == m.title) Wait(self.marionette).until(lambda m: m.find_element( *self._academic_page_locator).is_displayed()) self.take_screenshot() self.marionette.switch_to_frame() GaiaImageCompareTestCase.scroll(self.marionette, 'down', 400, locator=browser._browser_frame_locator) self.take_screenshot()
def test_browser_lan(self): """ https://moztrap.mozilla.org/manage/case/1327/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla')
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() self.assertTrue(cost_control.is_mobile_data_tracking_on) self.assertFalse(cost_control.is_wifi_data_tracking_on) settings = cost_control.tap_settings() self.assertFalse(settings.is_data_alert_switch_checked) settings.toggle_data_alert_switch() self.assertTrue(settings.is_data_alert_switch_checked) settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded search = Search(self.marionette) search.launch(launch_timeout=30000) browser = search.go_to_url( 'http://mozqa.com/qa-testcase-data/Images/sample_png_02.png') browser.wait_for_page_to_load(180) browser.switch_to_content() Wait(self.marionette, timeout=60).until(lambda m: "sample_png_02.png" in m.title) browser.switch_to_chrome() system = System(self.marionette) utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # switch to cost control widget usage_iframe = self.marionette.find_element( *self._cost_control_widget_locator) self.marionette.switch_to_frame(usage_iframe) # make sure the color changed # The timeout is increased, because for some reason, it takes some time # before the limit view is shown (the browser has to finish loading?) usage_view = self.marionette.find_element( *self._data_usage_view_locator) Wait(self.marionette, timeout=40).until( lambda m: 'reached-limit' in usage_view.get_attribute('class'), message='Data usage bar did not breach limit') usage_view.tap() self.wait_for_condition( lambda m: self.apps.displayed_app.name == cost_control.name)
def test_play_video(self): """Confirm video playback https://moztrap.mozilla.org/manage/case/6073/ Note: this test case does not reflect the entire test steps of above test case. """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() player = HTML5Player(self.marionette) player.wait_for_video_loaded() play_time = 20.0 self.wait_for_condition( lambda m: player.current_timestamp == play_time, timeout=30, message='Video did not reach the end') self.take_screenshot() # Tap UI buttons. player must be reinstantiated each time after screenshot is called, because it loses context HTML5Player(self.marionette).tap_mute() self.take_screenshot() HTML5Player(self.marionette).invoke_controls( ) # after tapping mute, the control view disappears HTML5Player(self.marionette).tap_unmute() self.take_screenshot() HTML5Player(self.marionette).tap_full_screen() permission = PermissionDialog(self.marionette) self.marionette.switch_to_default_content() permission.wait_for_permission_dialog_displayed() permission.tap_to_confirm_permission() browser.switch_to_content() Wait(self.marionette).until( lambda m: HTML5Player(self.marionette).is_fullscreen) self.take_screenshot() # Temporary workaround until below methods are fixed (Bug 1163747) # player = HTML5Player(self.marionette) # player.show_controls() # Wait(self.marionette).until(lambda m: player.controls_visible) self.marionette.find_element(*self._video_screen_locator).tap() self.take_screenshot() # exit from fullscreen view player = HTML5Player(self.marionette) player.tap_full_screen() if player.is_fullscreen: # control view has disappeared, # and above tap only brought up control view player.tap_full_screen() Wait(self.marionette).until(lambda m: not player.is_fullscreen) self.take_screenshot()
def test_browser_share_to_messages(self): """ https://moztrap.mozilla.org/manage/case/2027/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.tap_menu_button() browser.tap_share() messages = browser.tap_share_to_messages() messages.wait_for_message_input_displayed() self.assertEqual(messages.message, self.test_url)
def test_cost_control_reset_wifi(self): self.data_layer.connect_to_wifi() cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() cost_control.toggle_mobile_data_tracking(False) cost_control.toggle_wifi_data_tracking(True) # If we don't kill the app manually it might get killed by the oom process. # In that case when we re-launch the app it has a hash attached at the end of the src. - Bug 1091676 self.apps.kill(cost_control.app) # open browser to get some data downloaded search = Search(self.marionette) search.launch() search.go_to_url(self.marionette.absolute_url('mozilla.html')) self.data_layer.disable_wifi() time.sleep(5) # go back to Cost Control cost_control.launch() # if we can't trigger any data usage, there must be something wrong self.assertNotEqual(cost_control.wifi_data_usage_figure, u'0.00 B', 'No data usage shown after browsing.') # # go to settings section settings = cost_control.tap_settings() settings.reset_wifi_usage() settings.tap_done() # wait for usage to be refreshed self.wait_for_condition( lambda m: cost_control.wifi_data_usage_figure == u'0.00 B', message='Wifi usage did not reset back to 0.00 B')
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() self.assertTrue(cost_control.is_mobile_data_tracking_on) self.assertFalse(cost_control.is_wifi_data_tracking_on) settings = cost_control.tap_settings() self.assertFalse(settings.is_data_alert_switch_checked) settings.toggle_data_alert_switch() self.assertTrue(settings.is_data_alert_switch_checked) settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded search = Search(self.marionette) search.launch(launch_timeout=30000) search.go_to_url('http://mozqa.com/qa-testcase-data/Images/sample_png_02.png') system = System(self.marionette) # We could have waited on the page to be loaded, but the toaster can appear before # the end of the load. That's why the timeout is expanded, the webpage loaded just above # might take longer. system.wait_for_notification_toaster_displayed(timeout=180) system.wait_for_notification_toaster_not_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() cost_control_widget = utility_tray.cost_control_widget cost_control_widget.wait_for_limit_to_be_reached() cost_control_widget.tap() Wait(self.marionette).until(lambda m: self.apps.displayed_app.name == cost_control.name)
def test_browser_search(self): search = Search(self.marionette) search.launch() search_text = 'Mozilla' browser = search.go_to_url(search_text) browser.switch_to_content() self.wait_for_element_displayed(*self._google_search_input_locator) self.assertTrue(search_text in self.marionette.title) self.assertEqual(search_text, self.marionette.find_element(*self._google_search_input_locator).get_attribute('value'))
def test_play_video(self): """Confirm video playback https://moztrap.mozilla.org/manage/case/6073/ Note: this test case does not reflect the entire test steps of above test case. """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() player = HTML5Player(self.marionette) player.wait_for_video_loaded() play_time = 20.0 self.wait_for_condition( lambda m: player.current_timestamp == play_time, timeout=30, message='Video did not reach the end') self.take_screenshot() # Tap UI buttons. player must be reinstantiated each time after screenshot is called, because it loses context HTML5Player(self.marionette).tap_mute() self.take_screenshot() HTML5Player(self.marionette).invoke_controls() # after tapping mute, the control view disappears HTML5Player(self.marionette).tap_unmute() self.take_screenshot() HTML5Player(self.marionette).tap_full_screen() permission = PermissionDialog(self.marionette) self.marionette.switch_to_default_content() permission.wait_for_permission_dialog_displayed() permission.tap_to_confirm_permission() browser.switch_to_content() Wait(self.marionette).until(lambda m: HTML5Player(self.marionette).is_fullscreen) self.take_screenshot() # Temporary workaround until below methods are fixed (Bug 1163747) # player = HTML5Player(self.marionette) # player.show_controls() # Wait(self.marionette).until(lambda m: player.controls_visible) self.marionette.find_element(*self._video_screen_locator).tap() self.take_screenshot() # exit from fullscreen view player = HTML5Player(self.marionette) player.tap_full_screen() if player.is_fullscreen: # control view has disappeared, # and above tap only brought up control view player.tap_full_screen() Wait(self.marionette).until(lambda m: not player.is_fullscreen) self.take_screenshot()
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() self.assertTrue(cost_control.is_mobile_data_tracking_on) self.assertFalse(cost_control.is_wifi_data_tracking_on) settings = cost_control.tap_settings() settings.enable_data_alert_switch() settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded search = Search(self.marionette) search.launch(launch_timeout=30000) search.go_to_url( 'http://mozqa.com/qa-testcase-data/Images/sample_png_02.png') system = System(self.marionette) # We could have waited on the page to be loaded, but the toaster can appear before # the end of the load. That's why the timeout is expanded, the webpage loaded just above # might take longer. system.wait_for_notification_toaster_displayed(timeout=180) system.wait_for_notification_toaster_not_displayed() utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() cost_control_widget = utility_tray.cost_control_widget cost_control_widget.wait_for_limit_to_be_reached() cost_control_widget.tap() cost_control.wait_to_be_displayed()
def test_browser_cell_data(self): """https://moztrap.mozilla.org/manage/case/1328/""" search = Search(self.marionette) search.launch() browser = search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') browser.wait_for_page_to_load(120) browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator, timeout=120) heading = self.marionette.find_element(*self._page_title_locator) self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() self.assertTrue(cost_control.is_mobile_data_tracking_on) self.assertFalse(cost_control.is_wifi_data_tracking_on) settings = cost_control.tap_settings() settings.toggle_data_alert_switch(True) settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') settings.reset_mobile_usage() settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded search = Search(self.marionette) search.launch(launch_timeout=30000) browser = search.go_to_url('http://www.mozilla.org/') browser.wait_for_page_to_load(180) browser.switch_to_content() Wait(self.marionette, timeout=60).until( lambda m: "Home of the Mozilla Project" in m.title) browser.switch_to_chrome() # get the notification bar self.device.touch_home_button() self.marionette.switch_to_frame() self.marionette.execute_script( "window.wrappedJSObject.UtilityTray.show()") # switch to cost control widget usage_iframe = self.marionette.find_element( *self._cost_control_widget_locator) self.marionette.switch_to_frame(usage_iframe) # make sure the color changed # The timeout is increased, because for some reason, it takes some time # before the limit view is shown (the browser has to finish loading?) usage_view = self.marionette.find_element( *self._data_usage_view_locator) Wait(self.marionette, timeout=40).until( lambda m: 'reached-limit' in usage_view.get_attribute('class'), message='Data usage bar did not breach limit')
def test_play_video(self): """Confirm video playback https://moztrap.mozilla.org/manage/case/6073/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() player = HTML5Player(self.marionette) # Check that video is playing player.wait_for_video_loaded() self.assertTrue(player.is_video_playing()) # Tap on the edge of the video to make the controls appear player.invoke_controls() # Pause playback player.tap_pause() stopped_at = player.current_timestamp self.assertFalse(player.is_video_playing()) resumed_at = player.current_timestamp # Resume playback player.tap_play() # Ensure that video resumes to play # from the place where it was paused delay = resumed_at - stopped_at self.assertLessEqual( delay, self.acceptable_delay, 'video resumed to play not from place where it was paused, paused at %.3f, resumed at %.3f' % (stopped_at, resumed_at)) # Make sure the video is ready to play again player.wait_for_video_loaded() # This is disabled for now, because of bug 1100333 # self.assertTrue(player.is_video_playing()) # After tapping the play button, the controls disappear, make them appear again player.invoke_controls() # Tap mute button player.tap_mute() player.tap_unmute()
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() self.assertTrue(cost_control.is_mobile_data_tracking_on) self.assertFalse(cost_control.is_wifi_data_tracking_on) settings = cost_control.tap_settings() self.assertFalse(settings.is_data_alert_switch_checked) settings.toggle_data_alert_switch() self.assertTrue(settings.is_data_alert_switch_checked) settings.reset_mobile_usage() settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded search = Search(self.marionette) search.launch(launch_timeout=30000) browser = search.go_to_url('http://mozqa.com/qa-testcase-data/Images/sample_png_02.png') browser.wait_for_page_to_load(180) browser.switch_to_content() Wait(self.marionette, timeout=60).until(lambda m: "sample_png_02.png" in m.title) browser.switch_to_chrome() system = System(self.marionette) utility_tray = system.open_utility_tray() utility_tray.wait_for_notification_container_displayed() # switch to cost control widget usage_iframe = self.marionette.find_element(*self._cost_control_widget_locator) self.marionette.switch_to_frame(usage_iframe) # make sure the color changed # The timeout is increased, because for some reason, it takes some time # before the limit view is shown (the browser has to finish loading?) usage_view = self.marionette.find_element(*self._data_usage_view_locator) Wait(self.marionette, timeout=40).until(lambda m: 'reached-limit' in usage_view.get_attribute('class'), message='Data usage bar did not breach limit') usage_view.tap() self.wait_for_condition(lambda m: self.apps.displayed_app.name == cost_control.name)
def test_browser_cell_data(self): """ https://moztrap.mozilla.org/manage/case/1328/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') browser.wait_for_page_to_load(120) browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator, timeout=120) heading = self.marionette.find_element(*self._page_title_locator) self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')
def test_play_video(self): """Confirm video playback https://moztrap.mozilla.org/manage/case/6073/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() player = HTML5Player(self.marionette) # Check that video is playing player.wait_for_video_loaded() self.assertTrue(player.is_video_playing()) # Tap on the edge of the video to make the controls appear player.invoke_controls() # Pause playback player.tap_pause() stopped_at = player.current_timestamp self.assertFalse(player.is_video_playing()) resumed_at = player.current_timestamp # Resume playback player.tap_play() # Ensure that video resumes to play # from the place where it was paused delay = resumed_at - stopped_at self.assertLessEqual(delay, self.acceptable_delay, 'video resumed to play not from place where it was paused, paused at %.3f, resumed at %.3f' % (stopped_at, resumed_at)) # Make sure the video is ready to play again player.wait_for_video_loaded() # This is disabled for now, because of bug 1100333 # self.assertTrue(player.is_video_playing()) # After tapping the play button, the controls disappear, make them appear again player.invoke_controls() # Tap mute button player.tap_mute() player.tap_unmute()
def test_cost_control_data_alert_mobile(self): """https://moztrap.mozilla.org/manage/case/8938/""" cost_control = CostControl(self.marionette) cost_control.launch() cost_control.switch_to_ftu() cost_control.run_ftu_accepting_defaults() self.assertTrue(cost_control.is_mobile_data_tracking_on) self.assertFalse(cost_control.is_wifi_data_tracking_on) settings = cost_control.tap_settings() settings.toggle_data_alert_switch(True) settings.select_when_use_is_above_unit_and_value(u'MB', '0.1') settings.reset_mobile_usage() settings.tap_done() self.assertTrue(cost_control.is_mobile_data_tracking_on) # open browser to get some data downloaded search = Search(self.marionette) search.launch() browser = search.go_to_url('http://www.mozilla.org/') browser.wait_for_page_to_load(180) browser.switch_to_content() self.wait_for_condition(lambda m: "Home of the Mozilla Project" in m.title) browser.switch_to_chrome() # get the notification bar self.device.touch_home_button() self.marionette.switch_to_frame() self.marionette.execute_script("window.wrappedJSObject.UtilityTray.show()") # switch to cost control widget usage_iframe = self.marionette.find_element(*self._cost_control_widget_locator) self.marionette.switch_to_frame(usage_iframe) # make sure the color changed # The timeout is increased, because for some reason, it takes some time # before the limit view is shown (the browser has to finish loading?) usage_view = self.marionette.find_element( *self._data_usage_view_locator) self.wait_for_condition( lambda m: 'reached-limit' in usage_view.get_attribute('class'), message='Data usage bar did not breach limit', timeout=40)
def test_browser_bookmark(self): search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.tap_menu_button() bookmark = browser.tap_add_to_home() bookmark.type_bookmark_title(self.bookmark_title) bookmark.tap_add_bookmark_to_home_screen_dialog_button() # Switch to Home Screen to look for bookmark self.device.touch_home_button() homescreen = Homescreen(self.marionette) homescreen.wait_for_app_icon_present(self.bookmark_title) self._bookmark_added = homescreen.is_app_installed(self.bookmark_title) self.assertTrue(self._bookmark_added, 'The bookmark %s was not found to be installed on the home screen.' % self.bookmark_title)
def test_browser_navigation(self): self.test_url = self.marionette.absolute_url("sample_websites/darkness/index.html") search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.wait_for_page_to_load() # TODO: remove the reloading and rechecking for elements when bug 1128034 is resolved, browser.tap_reload_button() browser.wait_for_page_to_load() browser.switch_to_content() Wait(self.marionette).until(lambda m: "Darkness" == m.title) Wait(self.marionette).until(lambda m: m.find_element(*self._academic_page_locator).is_displayed()) self.take_screenshot() self.marionette.switch_to_frame() self.scroll(browser._browser_frame_locator, "down", 400) self.take_screenshot()
def test_browser_back_button(self): search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) 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') browser.switch_to_chrome() browser.tap_back_button() browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') browser.switch_to_chrome() browser.tap_forward_button() browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla Community')
def test_play_youtube_video(self): """Confirm YouTube video playback https://moztrap.mozilla.org/manage/case/6073/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() # Tap the video container to load the <video> element and start playing self.wait_for_element_displayed(*self._video_container_locator) self.marionette.find_element(*self._video_container_locator).tap() # Wait HTML5 player to appear self.wait_for_element_displayed(*self._video_element_locator) video = self.marionette.find_element(*self._video_element_locator) player = HTML5Player(self.marionette, video) # Check that video is playing player.wait_for_video_loaded() self.assertTrue(player.is_video_playing()) # Pause playback player.pause() stopped_at = player.current_timestamp self.assertFalse(player.is_video_playing()) # Resume playback player.play() resumed_at = player.current_timestamp self.assertTrue(player.is_video_playing()) # Ensure that video resumes to play # from the place where it was paused delay = resumed_at - stopped_at self.assertLessEqual( delay, self.acceptable_delay, 'video resumed to play not from place where it was paused')
def test_browser_bookmark(self): search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.tap_menu_button() bookmark = browser.tap_add_to_home() bookmark.type_bookmark_title(self.bookmark_title) bookmark.tap_add_bookmark_to_home_screen_dialog_button() # Switch to Home Screen to look for bookmark self.device.touch_home_button() homescreen = Homescreen(self.marionette) homescreen.wait_for_app_icon_present(self.bookmark_title) self._bookmark_added = homescreen.is_app_installed(self.bookmark_title) self.assertTrue( self._bookmark_added, 'The bookmark %s was not found to be installed on the home screen.' % self.bookmark_title)
def test_play_youtube_video(self): """ https://moztrap.mozilla.org/manage/case/6073/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() # Tap the video container to load the <video> element and start playing self.wait_for_element_displayed(*self._video_container_locator) self.marionette.find_element(*self._video_container_locator).tap() # Wait HTML5 player to appear self.wait_for_element_displayed(*self._video_element_locator) video = self.marionette.find_element(*self._video_element_locator) player = HTML5Player(self.marionette, video) # Check that video is playing player.wait_for_video_loaded() self.assertTrue(player.is_video_playing()) # Pause playback player.pause() stopped_at = player.current_timestamp self.assertFalse(player.is_video_playing()) # Resume playback player.play() resumed_at = player.current_timestamp self.assertTrue(player.is_video_playing()) # Ensure that video resumes to play # from the place where it was paused delay = resumed_at - stopped_at self.assertLessEqual(delay, self.acceptable_delay, 'video resumed to play not from place where it was paused')
def test_browser_back_button(self): search = Search(self.marionette) search.launch() browser = search.go_to_url(self.test_url) browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') link = self.marionette.find_element(By.CSS_SELECTOR, '#community a') # TODO: remove the explicit scroll once bug 833370 is fixed self.marionette.execute_script( 'arguments[0].scrollIntoView(false);', [link]) link.tap() Wait(self.marionette).until(lambda m: m.title == 'Mozilla Community') browser.switch_to_chrome() browser.tap_back_button() browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') browser.switch_to_chrome() browser.tap_forward_button() browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla Community')
def browser_wifi(self): # Start browser and load page and verify, code taken from test_browser_cell_data.py search = Search(self.marionette) search.launch() browser = search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') browser.wait_for_page_to_load(120) browser.switch_to_content() self.wait_for_element_present(*self._page_title_locator, timeout=120) heading = self.marionette.find_element(*self._page_title_locator) self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.') # Wait a couple of seconds with page displayed time.sleep(2) # Close browser via cards view self.app_under_test = "search" self.close_app() self.app_under_test = "browser" # Sleep between iterations time.sleep(10)
class TestBrowserNavigation(GaiaMtbfTestCase): _community_link_locator = (By.CSS_SELECTOR, '#community a') _community_history_section_locator = (By.ID, 'history') def setUp(self): GaiaMtbfTestCase.setUp(self) self.data_layer.enable_wifi() self.connect_to_local_area_network() self.test_url = self.marionette.absolute_url('mozilla.html') self.search = Search(self.marionette) self.search.launch() def test_browser_back_button(self): self.browser = self.search.go_to_url(self.test_url) self.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') self.browser.switch_to_chrome() self.browser.tap_back_button() self.browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla') self.browser.switch_to_chrome() self.browser.tap_forward_button() self.browser.switch_to_content() Wait(self.marionette).until(lambda m: m.title == 'Mozilla Community') def tearDown(self): GaiaMtbfTestCase.tearDown(self)
def test_play_video(self): """Confirm video playback https://moztrap.mozilla.org/manage/case/6073/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() player = HTML5Player(self.marionette) # Check that video is playing player.wait_for_video_loaded() self.assertTrue(player.is_video_playing()) # Tap on the edge of the video to make the controls appear player.invoke_controls() # Pause playback player.tap_pause() stopped_at = player.current_timestamp self.assertFalse(player.is_video_playing()) resumed_at = player.current_timestamp # Resume playback player.tap_play() # Ensure that video resumes to play # from the place where it was paused delay = resumed_at - stopped_at self.assertLessEqual( delay, self.acceptable_delay, 'video resumed to play not from place where it was paused, paused at %.3f, resumed at %.3f' % (stopped_at, resumed_at)) # Make sure the video is ready to play again player.wait_for_video_loaded() # This is disabled for now, because of bug 1100333 # self.assertTrue(player.is_video_playing()) # After tapping the play button, the controls disappear, make them appear again player.invoke_controls() # Tap mute button player.tap_mute() player.tap_unmute() player.tap_full_screen() permission = PermissionDialog(self.marionette) self.marionette.switch_to_default_content() permission.wait_for_permission_dialog_displayed() permission.tap_to_confirm_permission() # The interaction with the permission dialog makes us # loose connection to the player frame, so we need to reconnect browser.switch_to_content() player = HTML5Player(self.marionette) Wait(self.marionette).until(lambda m: player.is_fullscreen) # After tapping full screen, the controls disappear, make them appear again # Normally, we would use invoke_controls(), but this seems to cause intermittent failures # Bug 1111734 is filed to replace invoke_controls() to show_controls(), once it is possible Wait(self.marionette).until(lambda m: player.controls_visible is False) player.show_controls() Wait(self.marionette).until(lambda m: player.controls_visible) player.tap_full_screen() Wait(self.marionette).until(lambda m: player.is_fullscreen is False) Wait(self.marionette).until(lambda m: player.controls_visible is False)
def go_to_url(self, homescreen, url): search = Search(self.marionette) search.launch() browser = search.go_to_url(url)
def test_play_video(self): """Confirm video playback https://moztrap.mozilla.org/manage/case/6073/ """ search = Search(self.marionette) search.launch() browser = search.go_to_url(self.video_URL) browser.wait_for_page_to_load(180) browser.switch_to_content() player = HTML5Player(self.marionette) # Check that video is playing player.wait_for_video_loaded() self.assertTrue(player.is_playing) # Tap on the edge of the video to make the controls appear player.invoke_controls() # Pause playback player.tap_pause() stopped_at = player.current_timestamp self.assertFalse(player.is_playing) resumed_at = player.current_timestamp # Resume playback player.tap_play() # Ensure that video resumes to play # from the place where it was paused delay = resumed_at - stopped_at self.assertLessEqual(delay, self.acceptable_delay, 'video resumed to play not from place where it was paused, paused at %.3f, resumed at %.3f' % (stopped_at, resumed_at)) # Make sure the video is ready to play again player.wait_for_video_loaded() self.assertTrue(player.is_playing) # After tapping the play button, the controls disappear, make them appear again player.invoke_controls() # Tap mute button player.tap_mute() player.tap_unmute() player.tap_full_screen() permission = PermissionDialog(self.marionette) self.marionette.switch_to_default_content() permission.wait_for_permission_dialog_displayed() permission.tap_to_confirm_permission() # The interaction with the permission dialog makes us # loose connection to the player frame, so we need to reconnect browser.switch_to_content() player = HTML5Player(self.marionette) Wait(self.marionette).until(lambda m: player.is_fullscreen) # After tapping full screen, the controls disappear, make them appear again # Normally, we would use invoke_controls(), but this seems to cause intermittent failures # Bug 1111734 is filed to replace invoke_controls() to show_controls(), once it is possible Wait(self.marionette).until(lambda m: player.controls_visible is False) player.show_controls() Wait(self.marionette).until(lambda m: player.controls_visible) player.tap_full_screen() Wait(self.marionette).until(lambda m: player.is_fullscreen is False) Wait(self.marionette).until(lambda m: player.controls_visible is False)