diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/bookmark_menu.py b/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/bookmark_menu.py index 2005d1aee338..f6febacc9ce5 100644 --- a/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/bookmark_menu.py +++ b/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/bookmark_menu.py @@ -30,6 +30,10 @@ def tap_add_bookmark_to_home_screen_dialog_button(self): def type_bookmark_title(self, value): element = self.marionette.find_element(*self._bookmark_title_input_locator) + + # Wait for the default value to load into the input field + self.wait_for_condition(lambda m: element.get_attribute('value') != "") element.clear() + self.keyboard.send(value) self.keyboard.dismiss() diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/search_panel.py b/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/search_panel.py index cd5f4979da44..76ab73ffe7d3 100644 --- a/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/search_panel.py +++ b/tests/python/gaia-ui-tests/gaiatest/apps/homescreen/regions/search_panel.py @@ -26,6 +26,9 @@ def type_into_search_box(self, search_term): # The search results frame is not findable with AppWindowManager self._switch_to_search_results_frame() + def go_to_url(self, url): + self.keyboard.send(url, self.keyboard._enter_key) + def wait_for_everything_me_results_to_load(self, minimum_expected_results=1): self.wait_for_condition(lambda m: len(m.find_elements(*self._search_results_locator)) > minimum_expected_results) diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/keyboard/app.py b/tests/python/gaia-ui-tests/gaiatest/apps/keyboard/app.py index d3e00d9b48b1..8c1a8ea3cd00 100644 --- a/tests/python/gaia-ui-tests/gaiatest/apps/keyboard/app.py +++ b/tests/python/gaia-ui-tests/gaiatest/apps/keyboard/app.py @@ -215,7 +215,7 @@ def enable_caps_lock(self): self.apps.switch_to_displayed_app() # this would go through fastest way to tap/click through a string - def send(self, string): + def send(self, string, tap_key_at_end=None): self.switch_to_keyboard() for val in string: if ord(val) > 127: @@ -237,6 +237,9 @@ def send(self, string): self._switch_to_correct_layout(val) self._tap(val) + if tap_key_at_end: + self._tap(tap_key_at_end) + self.apps.switch_to_displayed_app() # Switch keyboard language diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/search/__init__.py b/tests/python/gaia-ui-tests/gaiatest/apps/search/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/search/app.py b/tests/python/gaia-ui-tests/gaiatest/apps/search/app.py new file mode 100644 index 000000000000..75e5d2bff9a1 --- /dev/null +++ b/tests/python/gaia-ui-tests/gaiatest/apps/search/app.py @@ -0,0 +1,28 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from gaiatest.apps.base import Base +from marionette.by import By + + +class Search(Base): + + name = 'Browser' + + _url_bar_locator = (By.CSS_SELECTOR, 'div.search-app .urlbar .title') + + def launch(self): + Base.launch(self) + self.wait_for_condition(lambda m: self.apps.displayed_app.name == self.name) + self.wait_for_element_displayed(*self._url_bar_locator) + + def go_to_url(self, url): + self.marionette.find_element(*self._url_bar_locator).tap() + + from gaiatest.apps.homescreen.regions.search_panel import SearchPanel + search_panel = SearchPanel(self.marionette) + search_panel.go_to_url(url) + + from regions.browser import Browser2 + return Browser2(self.marionette) diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/search/regions/__init__.py b/tests/python/gaia-ui-tests/gaiatest/apps/search/regions/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/search/regions/browser.py b/tests/python/gaia-ui-tests/gaiatest/apps/search/regions/browser.py new file mode 100644 index 000000000000..49071cf1ca88 --- /dev/null +++ b/tests/python/gaia-ui-tests/gaiatest/apps/search/regions/browser.py @@ -0,0 +1,67 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from gaiatest.apps.base import Base +from marionette.by import By + + +class Browser2(Base): + + _browser_app_locator = (By.CSS_SELECTOR, 'div.browser[transition-state="opened"]') + _browser_frame_locator = (By.CSS_SELECTOR, 'iframe.browser') + + _menu_button_locator = (By.CSS_SELECTOR, '.menu-button') + _add_to_home_button_locator = (By.ID, 'add-to-home') + _browser_menu_locator = (By.CSS_SELECTOR, '.overflow-menu') + + _back_button_locator = (By.CSS_SELECTOR, '.back-button') + _forward_button_locator = (By.CSS_SELECTOR, '.forward-button') + + def __init__(self, marionette): + Base.__init__(self, marionette) + self.marionette.switch_to_frame() + self._root_element = self.marionette.find_element(*self._browser_app_locator) + + def switch_to_content(self): + web_frame = self._root_element.find_element(*self._browser_frame_locator) + self.marionette.switch_to_frame(web_frame) + + def switch_to_chrome(self): + self.marionette.switch_to_frame() + + @property + def is_page_loading(self): + return "loading" in self._root_element.value_of_css_property('class') + + def wait_for_page_to_load(self, timeout=30): + self.wait_for_condition(lambda m: not self.is_page_loading, timeout=timeout) + + def tap_menu_button(self): + self._root_element.find_element(*self._menu_button_locator).tap() + self.wait_for_element_displayed(*self._browser_menu_locator) + + def tap_add_to_home(self): + self.wait_for_element_displayed(*self._add_to_home_button_locator) + self._root_element.find_element(*self._add_to_home_button_locator).tap() + from gaiatest.apps.homescreen.regions.bookmark_menu import BookmarkMenu + + return BookmarkMenu(self.marionette) + + @property + def url(self): + return self._root_element.find_element(*self._browser_frame_locator).get_attribute('data-url') + + @property + def data_origin(self): + return self._root_element.find_element(*self._browser_frame_locator).get_attribute('data-frame-origin') + + def tap_back_button(self): + current_url = self.url + self._root_element.find_element(*self._back_button_locator).tap() + self.wait_for_condition(lambda m: self.url != current_url) + + def tap_forward_button(self): + current_url = self.url + self._root_element.find_element(*self._forward_button_locator).tap() + self.wait_for_condition(lambda m: self.url != current_url) diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/manifest.ini b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/manifest.ini index 1079f6134bfe..d8986b3d0a04 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/manifest.ini +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/manifest.ini @@ -19,8 +19,6 @@ lan = true smoketest = true sanity = true -[test_browser_tabs.py] - [test_browser_search.py] [test_browser_navigation.py] diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_bookmark.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_bookmark.py index b993510d0df2..33bb3d471279 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_bookmark.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_bookmark.py @@ -5,8 +5,8 @@ import time from gaiatest import GaiaTestCase -from gaiatest.apps.browser.app import Browser from gaiatest.apps.homescreen.app import Homescreen +from gaiatest.apps.search.app import Search class TestBrowserBookmark(GaiaTestCase): @@ -16,6 +16,7 @@ class TestBrowserBookmark(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.connect_to_network() + self.apps.set_permission('Browser', 'geolocation', 'deny') if self.device.is_desktop_b2g or self.data_layer.is_wifi_connected(): self.test_url = self.marionette.absolute_url('mozilla.html') @@ -26,13 +27,13 @@ def setUp(self): self.bookmark_title = 'gaia%s' % curr_time[10:] def test_browser_bookmark(self): - browser = Browser(self.marionette) - browser.launch() + search = Search(self.marionette) + search.launch() - browser.go_to_url(self.test_url) - browser.tap_bookmark_button() + browser = search.go_to_url(self.test_url) + browser.tap_menu_button() + bookmark = browser.tap_add_to_home() - bookmark = browser.tap_add_bookmark_to_home_screen_choice_button() bookmark.type_bookmark_title(self.bookmark_title) bookmark.tap_add_bookmark_to_home_screen_dialog_button() diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_cell_data.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_cell_data.py index 7f68e00d36ff..3c5cac5ff96f 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_cell_data.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_cell_data.py @@ -5,7 +5,7 @@ from marionette.by import By from gaiatest import GaiaTestCase -from gaiatest.apps.browser.app import Browser +from gaiatest.apps.search.app import Search class TestBrowserCellData(GaiaTestCase): @@ -14,15 +14,18 @@ class TestBrowserCellData(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) + self.apps.set_permission('Browser', 'geolocation', 'deny') + self.data_layer.connect_to_cell_data() def test_browser_cell_data(self): """https://moztrap.mozilla.org/manage/case/1328/""" - browser = Browser(self.marionette) - browser.launch() + search = Search(self.marionette) + search.launch() - browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html', timeout=120) + browser = search.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html') + browser.wait_for_page_to_load(180) browser.switch_to_content() diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_lan.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_lan.py index 24c478be1e12..636b1b70c036 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_lan.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_lan.py @@ -5,7 +5,7 @@ from marionette import Wait from gaiatest import GaiaTestCase -from gaiatest.apps.browser.app import Browser +from gaiatest.apps.search.app import Search class TestBrowserLAN(GaiaTestCase): @@ -13,6 +13,7 @@ class TestBrowserLAN(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.connect_to_local_area_network() + self.apps.set_permission('Browser', 'geolocation', 'deny') if self.device.is_desktop_b2g or self.data_layer.is_wifi_connected(): self.test_url = self.marionette.absolute_url('mozilla.html') @@ -21,8 +22,8 @@ def setUp(self): 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) + 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') diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_navigation.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_navigation.py index c5b12511c4f1..0f74b36c653c 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_navigation.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_navigation.py @@ -6,7 +6,7 @@ from marionette import Wait from gaiatest import GaiaTestCase -from gaiatest.apps.browser.app import Browser +from gaiatest.apps.search.app import Search class TestBrowserNavigation(GaiaTestCase): @@ -14,6 +14,7 @@ class TestBrowserNavigation(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.connect_to_network() + self.apps.set_permission('Browser', 'geolocation', 'deny') if self.device.is_desktop_b2g or self.data_layer.is_wifi_connected(): self.test_url = self.marionette.absolute_url('mozilla.html') @@ -21,9 +22,9 @@ def setUp(self): self.test_url = 'http://mozqa.com/data/firefox/layout/mozilla.html' def test_browser_back_button(self): - browser = Browser(self.marionette) - browser.launch() - browser.go_to_url(self.test_url) + 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') diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_play_youtube_video.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_play_youtube_video.py index a09ec0639a02..1bab0d1d6faa 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_play_youtube_video.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/browser/test_browser_play_youtube_video.py @@ -4,7 +4,7 @@ from marionette.by import By from gaiatest import GaiaTestCase -from gaiatest.apps.browser.app import Browser +from gaiatest.apps.search.app import Search from gaiatest.apps.browser.regions.html5_player import HTML5Player @@ -20,15 +20,17 @@ class TestYouTube(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.connect_to_network() + self.apps.set_permission('Browser', 'geolocation', 'deny') 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) + 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