Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1059245 - Update tests and framework to use the new Browser app
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Chira authored and Robert Chira committed Aug 29, 2014
1 parent 0535f7a commit d4747df
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 93 deletions.
Expand Up @@ -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()
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion tests/python/gaia-ui-tests/gaiatest/apps/keyboard/app.py
Expand Up @@ -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:
Expand All @@ -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
Expand Down
Empty file.
28 changes: 28 additions & 0 deletions 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)
Empty file.
67 changes: 67 additions & 0 deletions 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)
Expand Up @@ -19,8 +19,6 @@ lan = true
smoketest = true
sanity = true

[test_browser_tabs.py]

[test_browser_search.py]

[test_browser_navigation.py]
Expand Down
Expand Up @@ -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):
Expand All @@ -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')
Expand All @@ -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()

Expand Down
Expand Up @@ -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):
Expand All @@ -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()

Expand Down
Expand Up @@ -5,14 +5,15 @@
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):

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')
Expand All @@ -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')
Expand Up @@ -6,24 +6,25 @@
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):

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')
else:
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')
Expand Down
Expand Up @@ -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


Expand All @@ -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 <video> element and start playing
Expand Down
Expand Up @@ -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 TestBrowserSearch(GaiaTestCase):
Expand All @@ -15,14 +15,15 @@ class TestBrowserSearch(GaiaTestCase):
def setUp(self):
GaiaTestCase.setUp(self)
self.connect_to_network()
self.apps.set_permission('Browser', 'geolocation', 'deny')

def test_browser_search(self):
browser = Browser(self.marionette)
browser.launch()
search = Search(self.marionette)
search.launch()

search_text = 'Mozilla Web QA'

browser.go_to_url(search_text)
browser = search.go_to_url(search_text)

browser.switch_to_content()
self.wait_for_element_displayed(*self._google_search_input_locator)
Expand Down

This file was deleted.

0 comments on commit d4747df

Please sign in to comment.