class TestBrowserSearch(GaiaMtbfTestCase):

    _google_search_input_locator = (By.NAME, 'q')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.connect_to_network()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_search(self):
        search_text = 'Mozilla Web QA'

        self.wait_for_element_displayed(*self.browser._awesome_bar_locator)

        self.marionette.find_element(*self.browser._awesome_bar_locator).clear()
        self.browser.go_to_url(search_text)

        self.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 tearDown(self):
        GaiaMtbfTestCase.tearDown(self)
    def browser_cell(self):
        # Start browser and load page and verify, code taken from test_browser_cell_data.py
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html',
                          timeout=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 the browser using home button
        self.app = browser
        self.close_app()

        # Sleep between iterations
        time.sleep(10)
示例#3
0
    def test_browser_tabs(self):
        """ Open a new tab.
        Open Browser.
        Open tab menu.
        Add a new tab.
        Assert that the new tab has opened.
        Load a website.
        Switch back to the first tab.
        """
        browser = Browser(self.marionette)
        browser.launch()

        # Open tab menu.
        browser.tap_tab_badge_button()

        # Add a new tab and load a website.
        browser.tap_add_new_tab_button()
        browser.go_to_url(self.test_url)
        browser.switch_to_content()
        Wait(self.marionette).until(lambda m: m.title == 'Mozilla')

        # Assert that the new tab has opened.
        browser.switch_to_chrome()
        self.assertEqual(browser.displayed_tabs_number, 2)
        # Assert that the displayed tabs number is equal with the actual number of opened tabs.
        self.assertEqual(browser.displayed_tabs_number, browser.tabs_count)

        # Switch back to the first tab.
        browser.tap_tab_badge_button()
        browser.tabs[0].tap_tab()
        self.assertTrue(browser.is_awesome_bar_visible)
示例#4
0
 def test_browser_lan(self):
     """https://moztrap.mozilla.org/manage/case/1327/"""
     browser = Browser(self.marionette)
     browser.launch()
     browser.go_to_url(self.test_url)
     browser.switch_to_content()
     Wait(self.marionette).until(lambda m: m.title == 'Mozilla')
    def test_cost_control_reset_wifi(self):

        self.data_layer.connect_to_wifi()
        cost_control = CostControl(self.marionette)
        cost_control.launch()
        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
        # please remove this once there is a better way than launching browser app/obj to do so
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_title_locator)

        # 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.')

        # disable wifi before reset data, wait for wifi to be closed, and switch back to the app
        self.data_layer.disable_wifi()
        time.sleep(1)
        cost_control.launch()

        # # go to settings section
        settings = cost_control.tap_settings()
        settings.reset_data_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')
示例#6
0
 def test_browser_lan(self):
     """https://moztrap.mozilla.org/manage/case/1327/"""
     browser = Browser(self.marionette)
     browser.launch()
     browser.go_to_url(self.test_url)
     browser.switch_to_content()
     Wait(self.marionette).until(lambda m: m.title == 'Mozilla')
class TestBrowserCellData(GaiaMtbfTestCase):

    _page_title_locator = (By.ID, 'page-title')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.data_layer = GaiaData(self.marionette)
        self.data_layer.connect_to_cell_data()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_cell_data(self):
        """https://moztrap.mozilla.org/manage/case/1328/"""
        self.wait_for_element_displayed(*self.browser._awesome_bar_locator)
        self.marionette.find_element(*self.browser._awesome_bar_locator).clear()

        self.browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html', timeout=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)
    def test_play_youtube_video(self):
        """ Confirm YouTube video playback

        https://moztrap.mozilla.org/manage/case/6073/

        """
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url(self.video_URL)
        browser.switch_to_content()

        # Tap the video
        self.wait_for_element_present(*self._video_container_locator)
        self.marionette.find_element(*self._video_container_locator).tap()
        # TODO: Remove sleep when Bug # 815115 is addressed, or if we can wait for a Javascript condition
        time.sleep(1)
        self.marionette.switch_to_frame()
        fullscreen_video = FullscreenVideo(self.marionette)

        # Switch to video player
        fullscreen_video.switch_to_video_frame()

        # Check for playback
        self.assertTrue(fullscreen_video.is_video_playing)
示例#9
0
class TestBrowserSearch(GaiaMtbfTestCase):

    _google_search_input_locator = (By.NAME, 'q')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.connect_to_network()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_search(self):
        search_text = 'Mozilla Web QA'

        self.wait_for_element_displayed(*self.browser._awesome_bar_locator)

        self.marionette.find_element(
            *self.browser._awesome_bar_locator).clear()
        self.browser.go_to_url(search_text)

        self.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 tearDown(self):
        GaiaMtbfTestCase.tearDown(self)
示例#10
0
    def test_browser_tabs(self):
        """ Open a new tab.
        Open Browser.
        Open tab menu.
        Add a new tab.
        Assert that the new tab has opened.
        Load a website.
        Switch back to the first tab.
        """
        browser = Browser(self.marionette)
        browser.launch()

        # Open tab menu.
        browser.tap_tab_badge_button()

        # Add a new tab and load a website.
        browser.tap_add_new_tab_button()
        browser.go_to_url(self.test_url)
        browser.switch_to_content()
        Wait(self.marionette).until(lambda m: m.title == 'Mozilla')

        # Assert that the new tab has opened.
        browser.switch_to_chrome()
        self.assertEqual(browser.displayed_tabs_number, 2)
        # Assert that the displayed tabs number is equal with the actual number of opened tabs.
        self.assertEqual(browser.displayed_tabs_number, browser.tabs_count)

        # Switch back to the first tab.
        browser.tap_tab_badge_button()
        browser.tabs[0].tap_tab()
        self.assertTrue(browser.is_awesome_bar_visible)
示例#11
0
    def test_browser_tabs(self):
        """ Open a new tab.
        Using Wifi/LAN

        Open Browser.
        Open tab menu.
        Add a new tab.
        Assert that the new tab has opened.
        Load a website ( http://mozqa.com/data/firefox/layout/mozilla.html)
        Switch back to the first tab.
        """
        browser = Browser(self.marionette)
        browser.launch()

        # Open tab menu.
        browser.tap_tab_badge_button()

        # Add a new tab and load a website.
        browser.tap_add_new_tab_button()
        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_title_locator)
        heading = self.marionette.find_element(*self._page_title_locator)
        self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')

        # Assert that the new tab has opened.
        browser.switch_to_chrome()
        self.assertEqual(browser.displayed_tabs_number, 2)
        # Assert that the displayed tabs number is equal with the actual number of opened tabs.
        self.assertEqual(browser.displayed_tabs_number, browser.tabs_count)

        # Switch back to the first tab.
        browser.tap_tab_badge_button()
        browser.tabs[0].tap_tab()
        self.assertTrue(browser.is_awesome_bar_visible)
示例#12
0
class TestBrowserCellData(GaiaMtbfTestCase):

    _page_title_locator = (By.ID, 'page-title')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.data_layer = GaiaData(self.marionette)
        self.data_layer.connect_to_cell_data()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_cell_data(self):
        """https://moztrap.mozilla.org/manage/case/1328/"""
        self.wait_for_element_displayed(*self.browser._awesome_bar_locator)
        self.marionette.find_element(
            *self.browser._awesome_bar_locator).clear()

        self.browser.go_to_url(
            'http://mozqa.com/data/firefox/layout/mozilla.html', timeout=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)
    def test_play_youtube_video(self):
        """ Confirm YouTube video playback

        https://moztrap.mozilla.org/manage/case/6073/

        """
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url(self.video_URL)
        browser.switch_to_content()

        # Tap the video
        self.wait_for_element_present(*self._video_container_locator)
        self.marionette.find_element(*self._video_container_locator).tap()
        # TODO: Remove sleep when Bug # 815115 is addressed, or if we can wait for a Javascript condition
        time.sleep(1)
        self.marionette.switch_to_frame()
        fullscreen_video = FullscreenVideo(self.marionette)

        # Switch to video player
        fullscreen_video.switch_to_video_frame()

        # Check for playback
        self.assertTrue(fullscreen_video.is_video_playing)
示例#14
0
文件: b2gperf.py 项目: changm/b2gperf
 def before_scroll(self):
     B2GPerfScrollTest.before_scroll(self)
     from gaiatest.apps.browser.app import Browser
     app = Browser(self.marionette)
     app.go_to_url('http://taskjs.org/')
     # TODO Move readyState wait into app object
     app.switch_to_content()
     MarionetteWait(self.marionette, 30).until(
         lambda m: m.execute_script(
             'return window.document.readyState;',
             new_sandbox=False) == 'complete')
示例#15
0
    def test_browser_lan(self):
        # https://moztrap.mozilla.org/manage/case/1327/
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')

        browser.switch_to_content()

        self.wait_for_element_present(*self._page_title_locator)
        heading = self.marionette.find_element(*self._page_title_locator)
        self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')
class TestYouTube(GaiaMtbfTestCase):

    video_URL = 'http://m.youtube.com/watch?v=5MzuGWFIfio'
    acceptable_delay = 2.0

    # YouTube video locators
    _video_container_locator = (By.CSS_SELECTOR, 'div[style^="background-image"]')
    _video_element_locator = (By.TAG_NAME, 'video')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.connect_to_network()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_play_youtube_video(self):
        """Confirm YouTube video playback
        https://moztrap.mozilla.org/manage/case/6073/
        """
        self.wait_for_element_displayed(*self.browser._awesome_bar_locator)
        self.marionette.find_element(*self.browser._awesome_bar_locator).clear()

        self.browser.go_to_url(self.video_URL, timeout=180)
        self.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())

    def tearDown(self):
        self.data_layer.disable_wifi()
        GaiaMtbfTestCase.tearDown(self)
示例#17
0
    def test_browser_search(self):
        browser = Browser(self.marionette)
        browser.launch()

        search_text = 'Mozilla Web QA'

        browser.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'))
示例#18
0
    def test_browser_search(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/451
        browser = Browser(self.marionette)
        browser.launch()

        search_text = 'Mozilla Web QA'

        browser.go_to_url(search_text)

        browser.switch_to_content()
        self.wait_for_element_displayed(*self._bing_search_input_locator)
        self.assertEqual('Bing : %s' % search_text, self.marionette.title)
        self.assertEqual(search_text,
                         self.marionette.find_element(*self._bing_search_input_locator).get_attribute('value'))
示例#19
0
    def test_browser_search(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/451
        browser = Browser(self.marionette)
        browser.launch()

        search_text = 'Mozilla Web QA'

        browser.go_to_url(search_text)

        browser.switch_to_content()
        self.wait_for_element_displayed(*self._bing_search_input_locator)
        self.assertEqual('Bing : %s' % search_text, self.marionette.title)
        self.assertEqual(search_text,
                         self.marionette.find_element(*self._bing_search_input_locator).get_attribute('value'))
示例#20
0
    def test_browser_search(self):
        browser = Browser(self.marionette)
        browser.launch()

        search_text = 'Mozilla Web QA'

        browser.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'))
class TestBrowserTabs(GaiaMtbfTestCase):

    _page_title_locator = (By.ID, 'page-title')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.connect_to_network()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_tabs(self):
        # Remember the tabs number
        self.ori_tab_num = self.browser.displayed_tabs_number

        # Open tab menu.
        self.browser.tap_tab_badge_button()

        # Add a new tab and load a website.
        self.browser.tap_add_new_tab_button()
        self.browser.go_to_url(
            'http://mozqa.com/data/firefox/layout/mozilla.html')
        self.browser.switch_to_content()
        self.wait_for_element_present(*self._page_title_locator)
        heading = self.marionette.find_element(*self._page_title_locator)
        self.assertEqual(
            heading.text,
            'We believe that the internet should be public, open and accessible.'
        )

        # Assert that the new tab has opened.
        self.browser.switch_to_chrome()
        self.assertEqual(self.browser.displayed_tabs_number,
                         self.ori_tab_num + 1)
        # Assert that the displayed tabs number is equal with the actual number of opened tabs.
        self.assertEqual(self.browser.displayed_tabs_number,
                         self.browser.tabs_count)

        # Switch back to the first tab.
        self.browser.tap_tab_badge_button()
        self.browser.tabs[0].tap_tab()
        self.assertTrue(self.browser.is_awesome_bar_visible)

    def tearDown(self):
        self.data_layer.disable_wifi()
        GaiaMtbfTestCase.tearDown(self)
    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
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://www.mozilla.org/', timeout=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
        self.wait_for_condition(
            lambda m: 'reached-limit' in self.marionette.find_element(
                *self._data_usage_view_locator).get_attribute('class'),
            message='Data usage bar did not breach limit')
    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
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://www.mozilla.org/', timeout=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
        self.wait_for_condition(
            lambda m: 'reached-limit' in self.marionette.find_element(
                *self._data_usage_view_locator).get_attribute('class'),
            message='Data usage bar did not breach limit')
    def test_browser_back_button(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/450
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')

        browser.switch_to_content()
        self.verify_home_page()

        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()
        browser.switch_to_chrome()
        browser.tap_back_button()

        browser.switch_to_content()
        self.verify_home_page()
        browser.switch_to_chrome()
        browser.tap_forward_button()

        browser.switch_to_content()
        self.verify_community_page()
    def test_browser_back_button(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/450
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')

        browser.switch_to_content()
        self.verify_home_page()

        community_link = self.marionette.find_element(*self._community_link_locator)
        community_link.tap()
        # # TODO: remove this execute_script when bug 833370 has been fixed
        # self.marionette.execute_script("arguments[0].scrollIntoView(false);", [community_link])
        # self.marionette.tap(community_link)

        self.verify_community_page()
        browser.switch_to_chrome()
        browser.tap_back_button()

        browser.switch_to_content()
        self.verify_home_page()
        browser.switch_to_chrome()
        browser.tap_forward_button()

        browser.switch_to_content()
        self.verify_community_page()
    def test_browser_back_button(self):
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url("http://mozqa.com/data/firefox/layout/mozilla.html")

        browser.switch_to_content()
        self.verify_home_page()

        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()
        browser.switch_to_chrome()
        browser.tap_back_button()

        browser.switch_to_content()
        self.verify_home_page()
        browser.switch_to_chrome()
        browser.tap_forward_button()

        browser.switch_to_content()
        self.verify_community_page()
class TestBrowserTabs(GaiaMtbfTestCase):

    _page_title_locator = (By.ID, 'page-title')

    def setUp(self):
        GaiaMtbfTestCase.setUp(self)
        self.connect_to_network()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_tabs(self):
        # Remember the tabs number
        self.ori_tab_num = self.browser.displayed_tabs_number

        # Open tab menu.
        self.browser.tap_tab_badge_button()

        # Add a new tab and load a website.
        self.browser.tap_add_new_tab_button()
        self.browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')
        self.browser.switch_to_content()
        self.wait_for_element_present(*self._page_title_locator)
        heading = self.marionette.find_element(*self._page_title_locator)
        self.assertEqual(heading.text, 'We believe that the internet should be public, open and accessible.')

        # Assert that the new tab has opened.
        self.browser.switch_to_chrome()
        self.assertEqual(self.browser.displayed_tabs_number, self.ori_tab_num + 1)
        # Assert that the displayed tabs number is equal with the actual number of opened tabs.
        self.assertEqual(self.browser.displayed_tabs_number, self.browser.tabs_count)

        # Switch back to the first tab.
        self.browser.tap_tab_badge_button()
        self.browser.tabs[0].tap_tab()
        self.assertTrue(self.browser.is_awesome_bar_visible)

    def tearDown(self):
        self.data_layer.disable_wifi()
        GaiaMtbfTestCase.tearDown(self)
示例#28
0
    def test_persona_cookie(self):
        """
        Smoketest of cookie handling/Persona integration
        Log in with Persona user
        After refreshing 123done should still be logged in (cookie retained)
        """
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://firefoxos.123done.org')

        browser.switch_to_content()

        self.wait_for_element_displayed(*self._logged_out_button_locator, timeout=120)

        login_button = self.marionette.find_element(*self._logged_out_button_locator)
        login_button.click()

        persona = Persona(self.marionette)
        persona.login(self.user.email, self.user.password)

        # wait to fall back to browser
        self.wait_for_condition(lambda m: self.apps.displayed_app.name == browser.name)
        self.apps.switch_to_displayed_app()

        browser.switch_to_content()
        self.wait_for_element_displayed(*self._logged_in_button_locator)

        browser.switch_to_chrome()
        # Refresh the page
        browser.tap_go_button()

        # Now we expect B2G to retain the Persona cookie and remain logged in
        browser.switch_to_content()
        self.wait_for_element_displayed(*self._logged_in_button_locator)
示例#29
0
    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
        # please remove this once there is a better way than launching browser app/obj to do so
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_title_locator)

        # 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.')

        # disable wifi before reset data, wait for wifi to be closed, and switch back to the app
        self.data_layer.disable_wifi()
        time.sleep(1)
        cost_control.launch()

        # # go to settings section
        settings = cost_control.tap_settings()
        settings.reset_data_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')
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.connect_to_network()

        self.browser = Browser(self.marionette)
        self.browser.launch()

    def test_browser_back_button(self):
        self.wait_for_element_displayed(*self.browser._awesome_bar_locator)
        self.marionette.find_element(
            *self.browser._awesome_bar_locator).clear()

        self.browser.go_to_url(
            'http://mozqa.com/data/firefox/layout/mozilla.html')

        self.browser.switch_to_content()
        self.verify_home_page()

        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.browser.switch_to_chrome()
        self.browser.tap_back_button()

        self.browser.switch_to_content()
        self.verify_home_page()
        self.browser.switch_to_chrome()
        self.browser.tap_forward_button()

        self.browser.switch_to_content()
        self.verify_community_page()

    def verify_home_page(self):
        self.wait_for_element_present(*self._community_link_locator)
        community_link = self.marionette.find_element(
            *self._community_link_locator)
        self.assertTrue(community_link.is_displayed(),
                        'The community link was not visible at mozilla.html.')

    def verify_community_page(self):
        self.wait_for_element_present(*self._community_history_section_locator)
        history_section = self.marionette.find_element(
            *self._community_history_section_locator)
        self.assertTrue(
            history_section.is_displayed(),
            'The history section was not visible at mozilla_community.html.')

    def tearDown(self):
        GaiaMtbfTestCase.tearDown(self)
    def test_play_youtube_video(self):
        """Confirm YouTube video playback

        https://moztrap.mozilla.org/manage/case/6073/
        """
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url(self.video_URL)
        browser.switch_to_content()

        # Tap the video container
        self.wait_for_element_present(*self._video_container_locator)
        self.marionette.find_element(*self._video_container_locator).tap()

        # Wait HTML5 player to appear
        self.wait_for_element_present(*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')
示例#32
0
    def browser_wifi(self):
        # Start browser and load page and verify, code taken from test_browser_cell_data.py
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')

        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 the browser using home button
        self.app = browser
        self.close_app()

        # Sleep between iterations
        time.sleep(10)
示例#33
0
    def test_cost_control_data_alert_mobile(self):

        self.data_layer.connect_to_cell_data()
        cost_control = CostControl(self.marionette)
        cost_control.launch()
        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('MB', '0.1')
        settings.reset_data_usage()
        settings.tap_done()
        self.assertTrue(cost_control.is_mobile_data_tracking_on)

        # open browser to get some data downloaded
        # please remove this once there is a better way than launching browser app/obj to do so
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://developer.mozilla.org/')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_body_locator, timeout=120)
        browser.switch_to_chrome()

        # get the notification bar
        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
        self.wait_for_condition(
            lambda m: 'reached-limit' in self.marionette.find_element(*self._data_usage_view_locator).get_attribute('class'),
            message='Data usage bar did not breach limit'
        )
    def test_play_youtube_video(self):
        """Confirm YouTube video playback

        https://moztrap.mozilla.org/manage/case/6073/
        """
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url(self.video_URL, timeout=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_play_youtube_video(self):
        """ Confirm YouTube video playback

        https://moztrap.mozilla.org/manage/case/6073/

        """
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url(self.video_URL)
        browser.switch_to_content()

        # Tap the video
        self.wait_for_element_present(*self._video_container_locator)
        self.marionette.find_element(*self._video_container_locator).tap()
        self.marionette.switch_to_frame()
        fullscreen_video = FullscreenVideo(self.marionette)

        # Switch to video player
        fullscreen_video.switch_to_video_frame()

        # Check for playback
        self.assertTrue(fullscreen_video.is_video_playing)
示例#36
0
    def test_play_youtube_video(self):
        """ Confirm YouTube video playback

        https://moztrap.mozilla.org/manage/case/6073/

        """
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url(self.video_URL)
        browser.switch_to_content()

        # Tap the video
        self.wait_for_element_present(*self._video_container_locator)
        self.marionette.find_element(*self._video_container_locator).tap()
        self.marionette.switch_to_frame()
        fullscreen_video = FullscreenVideo(self.marionette)

        # Switch to video player
        fullscreen_video.switch_to_video_frame()

        # Check for playback
        self.assertTrue(fullscreen_video.is_video_playing)
示例#37
0
    def test_browser_https_auth_login(self):
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/mozqa.com/http_auth/')

        browser.switch_to_content()

        self.wait_for_element_present(*self._login_link_locator)
        login_link = self.marionette.find_element(*self._login_link_locator)
        login_link.tap()

        browser.switch_to_chrome()

        auth_region = AuthenticationDialog(self.marionette)
        auth_region.authenticate('mozilla', 'mozilla')

        self.wait_for_condition(lambda m: browser.url == self._success_redirect_url)

        browser.switch_to_content()

        self.wait_for_element_displayed(*self._success_message_locator)
        success_message = self.marionette.find_element(*self._success_message_locator)
        self.assertEquals('Basic Authentication is successful!', success_message.text)
示例#38
0
    def test_browser_https_auth_login(self):
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/mozqa.com/http_auth/')

        browser.switch_to_content()

        self.wait_for_element_present(*self._login_link_locator)
        login_link = self.marionette.find_element(*self._login_link_locator)
        login_link.tap()

        browser.switch_to_chrome()

        auth_region = AuthenticationDialog(self.marionette)
        auth_region.authenticate('mozilla', 'mozilla')

        self.wait_for_condition(lambda m: browser.url == self._success_redirect_url)

        browser.switch_to_content()

        self.wait_for_element_displayed(*self._success_message_locator)
        success_message = self.marionette.find_element(*self._success_message_locator)
        self.assertEquals('Basic Authentication is successful!', success_message.text)
    def test_browser_back_button(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/450
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')

        browser.switch_to_content()
        self.verify_home_page()
        self.marionette.tap(self.marionette.find_element(*self._community_link_locator))

        self.verify_community_page()
        browser.switch_to_chrome()
        browser.tap_back_button()

        browser.switch_to_content()
        self.verify_home_page()
        browser.switch_to_chrome()
        browser.tap_forward_button()

        browser.switch_to_content()
        self.verify_community_page()
示例#40
0
    def test_browser_back_button(self):
        # https://github.com/mozilla/gaia-ui-tests/issues/450
        browser = Browser(self.marionette)
        browser.launch()

        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')

        browser.switch_to_content()
        self.verify_home_page()
        self.marionette.tap(
            self.marionette.find_element(*self._community_link_locator))

        self.verify_community_page()
        browser.switch_to_chrome()
        browser.tap_back_button()

        browser.switch_to_content()
        self.verify_home_page()
        browser.switch_to_chrome()
        browser.tap_forward_button()

        browser.switch_to_content()
        self.verify_community_page()
    def test_browser_back_button(self):
        browser = Browser(self.marionette)
        browser.launch()
        browser.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')
示例#42
0
    def test_browser_back_button(self):
        browser = Browser(self.marionette)
        browser.launch()
        browser.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')
示例#43
0
        marketplace_url = 'https://marketplace.firefox.com/'
    else:
        marketplace_app = 'Marketplace Dev'
        marketplace_url = 'https://marketplace-dev.allizom.org/'

    if args.app_url:
        args.browser = True
        marketplace_url = args.app_url

    # apps.kill_all()
    if args.browser:
        browser = Browser(mc)
        browser.launch()
        browser.go_to_url(marketplace_url)

        browser.switch_to_content()
        browser.wait_for_element_not_displayed(*_loading_fragment_locator)

    marketplace = Marketplace(mc, marketplace_app)

    if not args.browser:
        try:
            marketplace.launch()
        except AssertionError:
            e = ('Marketplace Dev app is not installed. Install it using '
                 'install_mkt --dev or use --browser to install apps '
                 'from the browser directly.')
            args.error(e)

        if args.prod:
            marketplace.switch_to_marketplace_frame()
    def test_cost_control_reset_wifi(self):
        # open fte from javascript (if this got fixed, switch to use fte:false and delete the temp solution down this section)
        # self.marionette.execute_script("return window.wrappedJSObject.ConfigManager.setOption({ fte: true });")
        # self.marionette.refresh()

        # temporary solution for current not working script (going through fte by UI)
        # please remove "fte locators" once this got fixed
        try:
            # go through 1st step in fte
            self.wait_for_element_displayed(*self._welcome_title_locator)
            next = self.marionette.find_element(*self._next_button_locator_1)
            self.marionette.tap(next)

            # go through 2nd step in fte
            self.wait_for_element_displayed(*self._data_report_title_locator)
            next = self.marionette.find_element(*self._next_button_locator_2)
            self.marionette.tap(next)

            # go through final step in fte
            self.wait_for_element_displayed(*self._data_alert_title_locator)
            next = self.marionette.find_element(*self._go_button_locator)
            self.marionette.tap(next)
        except:
            pass

        # wait for usage app main screen to come out
        self.wait_for_element_displayed(*self._usage_app_main_locator)

        # make sure wifi tracking is on and mobile data tracking is off
        self.wait_for_element_displayed(*self._mobile_data_item_locator)
        mobileswitch = self.marionette.find_element(*self._mobile_data_tracking_locator)
        wifiswitch = self.marionette.find_element(*self._wifi_data_tracking_locator)
        mobileswitch_click = self.marionette.find_element(*self._mobile_data_label_locator)
        wifiswitch_click = self.marionette.find_element(*self._wifi_data_label_locator)
        if mobileswitch.is_selected():
            self.marionette.tap(mobileswitch_click)
        if not wifiswitch.is_selected():
            self.marionette.tap(wifiswitch_click)

        # open browser to get some data downloaded
        # please remove this once there is a better way than launching browser app/obj to do so
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_title_locator)

        # go back to Usage app
        self.apps.launch('Usage')
        self.wait_for_element_displayed(*self._usage_app_title_locator)

        # if we can't trigger any data usage, there must be something wrong
        if self.marionette.find_element(*self._wifi_overview_data_locator).text == u'0.00 B':
            self.assertTrue(False, 'No data usage shown;')

        # disable wifi before reset data, wait for wifi to be closed, and switch back to self.app
        self.data_layer.forget_all_networks()
        self.data_layer.disable_wifi()
        time.sleep(1)
        self.marionette.switch_to_frame(self.app.frame)

        # go to settings section
        settings = self.marionette.find_element(*self._settings_button_locator)
        self.marionette.tap(settings)

        # go into iframe of usage app settings
        settings_iframe = self.marionette.find_element(*self._settings_iframe_locator)
        self.marionette.switch_to_frame(settings_iframe)

        # reset data
        self.wait_for_element_displayed(*self._settings_title_locator)
        reset = self.marionette.find_element(*self._reset_button_locator)
        self.marionette.tap(reset)
        self.wait_for_element_displayed(*self._reset_confirm_locator)
        confirm = self.marionette.find_element(*self._reset_confirm_locator)
        self.marionette.tap(confirm)
        self.wait_for_element_displayed(*self._done_button_locator)
        done = self.marionette.find_element(*self._done_button_locator)
        self.marionette.tap(done)

        # waiting for usage to be refreshed and checking for usage
        self.wait_for_condition(lambda m: m.find_element(*self._wifi_data_locator).text == u'0.00 B', message='Wifi usage did not re-set back to 0.00B')
示例#45
0
        return

    if args.prod:
        marketplace_app = 'Marketplace'
        marketplace_url = 'https://marketplace.firefox.com/'
    else:
        marketplace_app = 'Marketplace Dev'
        marketplace_url = 'https://marketplace-dev.allizom.org/'

    # apps.kill_all()
    if args.browser:
        browser = Browser(mc)
        browser.launch()
        browser.go_to_url(marketplace_url)

        browser.switch_to_content()
        browser.wait_for_element_not_displayed(*_loading_fragment_locator)

    marketplace = Marketplace(mc, marketplace_app)

    if not args.browser:
        try:
            marketplace.launch()
        except AssertionError:
            e = ('Marketplace Dev app is not installed. Install it using '
                 'install_mkt --dev or use --browser to install apps '
                 'from the browser directly.')
            args.error(e)

        if args.prod:
            marketplace.switch_to_marketplace_frame()
示例#46
0
    def test_cost_control_data_alert_mobile(self):
        # go through ftu if there is any, otherwise pass it
        try:
            # if there is fte coming up
            self.wait_for_element_displayed(*self._welcome_title_locator)

            # go through 1st step in fte
            self.wait_for_element_displayed(*self._welcome_title_locator)
            next = self.marionette.find_element(*self._next_button_locator_1)
            self.marionette.tap(next)

            # go through 2nd step in fte
            self.wait_for_element_displayed(*self._data_report_title_locator)
            next = self.marionette.find_element(*self._next_button_locator_2)
            self.marionette.tap(next)

            # go through final step in fte
            self.wait_for_element_displayed(*self._data_alert_title_locator)
            next = self.marionette.find_element(*self._go_button_locator)
            self.marionette.tap(next)
        except:
            # if there is no fte coming up
            pass

        # wait for usage app main screen to come out
        self.wait_for_element_displayed(*self._usage_app_main_locator)

        # make sure wifi tracking is on and mobile data tracking is off
        self.wait_for_element_displayed(*self._mobile_data_item_locator)
        mobileswitch = self.marionette.find_element(
            *self._mobile_data_tracking_locator)
        wifiswitch = self.marionette.find_element(
            *self._wifi_data_tracking_locator)
        mobileswitch_click = self.marionette.find_element(
            *self._mobile_data_label_locator)
        wifiswitch_click = self.marionette.find_element(
            *self._wifi_data_label_locator)
        if not mobileswitch.is_selected():
            self.marionette.tap(mobileswitch_click)
        if wifiswitch.is_selected():
            self.marionette.tap(wifiswitch_click)

        # go to settings section
        settings = self.marionette.find_element(*self._settings_button_locator)
        self.marionette.tap(settings)

        # go into iframe of usage app settings
        self.wait_for_element_displayed(*self._settings_iframe_locator)
        settings_iframe = self.marionette.find_element(
            *self._settings_iframe_locator)
        self.marionette.switch_to_frame(settings_iframe)

        # enable data use alert if not enabled
        # there is a bug that marionette 0.5.20 can't detect if some elements are displayed or not
        self.wait_for_element_displayed(*self._settings_title_locator)
        switch = self.marionette.find_element(*self._data_alert_switch_locator)

        if not switch.is_selected():
            switch_label = self.marionette.find_element(
                *self._data_alert_label_locator)
            self.marionette.tap(switch_label)

        # make sure the data alert is 0.1MB, or we would set it to 0.1MB
        when_use_is_above_button = self.marionette.find_element(
            *self._when_use_is_above_button_locator)
        self.wait_for_condition(lambda m: when_use_is_above_button.
                                get_attribute('disabled') == 'false')
        self.marionette.tap(when_use_is_above_button)
        capacity = self.marionette.find_element(*self._capacity_button_locator)
        # there are two choice in this switch u'GB' or u'MB'. if it is u'GB', try to switch to u'MB'
        if capacity.text == u'GB':
            self.marionette.tap(capacity)
        # clear the default value and set it to 0.1
        size = self.marionette.find_element(*self._size_input_locator)
        size.clear()
        size.send_keys('0.1')
        done = self.marionette.find_element(*self._usage_done_button_locator)
        self.marionette.tap(done)

        # reset data
        self.wait_for_element_displayed(*self._settings_title_locator)
        reset = self.marionette.find_element(*self._reset_button_locator)
        self.marionette.tap(reset)
        self.wait_for_element_displayed(*self._reset_confirm_locator)
        confirm = self.marionette.find_element(*self._reset_confirm_locator)
        self.marionette.tap(confirm)

        # done with settings section
        self.wait_for_element_displayed(*self._done_button_locator)
        done = self.marionette.find_element(*self._done_button_locator)
        self.marionette.tap(done)

        # open browser to get some data downloaded
        # please remove this once there is a better way than launching browser app/obj to do so
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://www.mozilla.org/')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_end_locator, timeout=120)
        browser.switch_to_chrome()

        # get the notification bar
        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
        bar = self.marionette.find_element(*self._data_usage_view_locator)
        self.wait_for_condition(
            lambda m: 'reached-limit' in bar.get_attribute('class'),
            message='Data usage bar did not breach limit')
    def test_cost_control_data_alert_mobile(self):
        # go through ftu if there is any, otherwise pass it
        try:
            # if there is fte coming up
            self.wait_for_element_displayed(*self._welcome_title_locator)

            # go through 1st step in fte
            self.wait_for_element_displayed(*self._welcome_title_locator)
            next = self.marionette.find_element(*self._next_button_locator_1)
            self.marionette.tap(next)

            # go through 2nd step in fte
            self.wait_for_element_displayed(*self._data_report_title_locator)
            next = self.marionette.find_element(*self._next_button_locator_2)
            self.marionette.tap(next)

            # go through final step in fte
            self.wait_for_element_displayed(*self._data_alert_title_locator)
            next = self.marionette.find_element(*self._go_button_locator)
            self.marionette.tap(next)
        except:
            # if there is no fte coming up
            pass

        # wait for usage app main screen to come out
        self.wait_for_element_displayed(*self._usage_app_main_locator)

        # make sure wifi tracking is on and mobile data tracking is off
        self.wait_for_element_displayed(*self._mobile_data_item_locator)
        mobileswitch = self.marionette.find_element(*self._mobile_data_tracking_locator)
        wifiswitch = self.marionette.find_element(*self._wifi_data_tracking_locator)
        mobileswitch_click = self.marionette.find_element(*self._mobile_data_label_locator)
        wifiswitch_click = self.marionette.find_element(*self._wifi_data_label_locator)
        if not mobileswitch.is_selected():
            self.marionette.tap(mobileswitch_click)
        if wifiswitch.is_selected():
            self.marionette.tap(wifiswitch_click)

        # go to settings section
        settings = self.marionette.find_element(*self._settings_button_locator)
        self.marionette.tap(settings)

        # go into iframe of usage app settings
        self.wait_for_element_displayed(*self._settings_iframe_locator)
        settings_iframe = self.marionette.find_element(*self._settings_iframe_locator)
        self.marionette.switch_to_frame(settings_iframe)

        # enable data use alert if not enabled
        # there is a bug that marionette 0.5.20 can't detect if some elements are displayed or not
        self.wait_for_element_displayed(*self._settings_title_locator)
        switch = self.marionette.find_element(*self._data_alert_switch_locator)

        if not switch.is_selected():
            self.marionette.tap(switch)

        # make sure the data alert is 0.1MB, or we would set it to 0.1MB
        detail_section = self.marionette.find_element('css selector', 'ul.settings button span')
        self.marionette.tap(detail_section)
        capacity = self.marionette.find_element(*self._capacity_button_locator)
        # there are two choice in this switch u'GB' or u'MB'. if it is u'GB', try to switch to u'MB'
        if capacity.text == u'GB':
            self.marionette.tap(capacity)
        # clear the default value and set it to 0.1
        size = self.marionette.find_element(*self._size_input_locator)
        size.clear()
        size.send_keys('0.1')
        done = self.marionette.find_element(*self._usage_done_button_locator)
        self.marionette.tap(done)

        # reset data
        self.wait_for_element_displayed(*self._settings_title_locator)
        reset = self.marionette.find_element(*self._reset_button_locator)
        self.marionette.tap(reset)
        self.wait_for_element_displayed(*self._reset_confirm_locator)
        confirm = self.marionette.find_element(*self._reset_confirm_locator)
        self.marionette.tap(confirm)

        # done with settings section
        self.wait_for_element_displayed(*self._done_button_locator)
        done = self.marionette.find_element(*self._done_button_locator)
        self.marionette.tap(done)

        # open browser to get some data downloaded
        # please remove this once there is a better way than launching browser app/obj to do so
        browser = Browser(self.marionette)
        browser.launch()
        browser.go_to_url('http://www.mozilla.org/')
        browser.switch_to_content()
        self.wait_for_element_present(*self._page_end_locator)
        browser.switch_to_chrome()

        # get the notification bar
        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
        bar = self.marionette.find_element(*self._data_usage_view_locator)
        self.wait_for_condition(lambda m: 'reached-limit' in bar.get_attribute('class'),
            message='Data usage bar did not breach limit')