本文整理汇总了Python中gaiatest.apps.browser.app.Browser类的典型用法代码示例。如果您正苦于以下问题:Python Browser类的具体用法?Python Browser怎么用?Python Browser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Browser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_app
def prepare_app(self, app_name):
if app_name.lower() == 'browser':
from gaiatest.apps.browser.app import Browser
browser = Browser(self.marionette)
browser.go_to_url('http://taskjs.org/')
tab_frame = self.marionette.execute_script("return window.wrappedJSObject.Browser.currentTab.dom;")
self.marionette.switch_to_frame(tab_frame)
MarionetteWait(self.marionette, 30).until(lambda m: m.execute_script('return window.document.readyState;', new_sandbox=False) == 'complete')
示例2: before_scroll
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')
示例3: test_browser_keyboard
def test_browser_keyboard(self):
# This test runs on TBPL only because other tests cover it on device
browser = Browser(self.marionette)
browser.launch()
search_url = 'http://mozqa.com/data/firefox/layout/mozilla.html'
browser.go_to_url(search_url)
search_src = browser.url_src
# Assert that the typed url is the same as the src attribute of the browser iframe
self.assertEqual(search_url, search_src)
示例4: setUp
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()
示例5: launch
def launch(self, url=None):
# Unlock the screen
gaiatest.LockScreen(self.marionette).unlock()
# Ensure browser app is installed
if not gaiatest.GaiaApps(self.marionette).is_app_installed("Browser"):
raise Exception("Browser app is not installed, cannot continue.")
# Kill any running apps; after b2g restart it is possible the first time use app comes up
gaiatest.GaiaApps(self.marionette).kill_all()
time.sleep(2)
# Ensure are on homescreen (should be after kill all above anyway)
self.marionette.execute_script('window.wrappedJSObject.dispatchEvent(new Event("home"));')
# Start browser app
self.browser = Browser(self.marionette)
self.browser.launch()
# Verify browser app is now running
if not self.running():
raise Exception("Browser app failed to start. Cannot continue.")
# Wait time for browser app to 'settle'
time.sleep(30)
# Launch the test by navigating to the URL
url = url.replace('&', '\\&')
self.browser.switch_to_chrome()
#print url
self.launch_time = datetime.datetime.now()
self.marionette.execute_script("return window.wrappedJSObject.Browser.navigate('%s');" %url)
return self.running()
示例6: test_browser_cell_data
def test_browser_cell_data(self):
"""https://moztrap.mozilla.org/manage/case/1328/"""
browser = Browser(self.marionette)
browser.launch()
browser.go_to_url('http://mozqa.com/data/firefox/layout/mozilla.html', timeout=120)
browser.switch_to_content()
browser.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.')
示例7: test_cost_control_reset_wifi
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')
示例8: test_play_youtube_video
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: test_browser_lan
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')
示例10: setUp
def setUp(self):
GaiaMtbfTestCase.setUp(self)
self.connect_to_network()
self.test_url = 'http://mozqa.com/data/firefox/layout/mozilla.html'
curr_time = repr(time.time()).replace('.', '')
self.bookmark_title = 'gaia%s' % curr_time[10:]
self.homescreen = Homescreen(self.marionette)
self.browser = Browser(self.marionette)
self.browser.launch()
示例11: TestBrowserCellData
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)
示例12: TestBrowserSearch
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)
示例13: test_cost_control_data_alert_mobile
def test_cost_control_data_alert_mobile(self):
"""https://moztrap.mozilla.org/manage/case/8938/"""
self.data_layer.connect_to_cell_data()
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=120)
# 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')
示例14: TestBrowserBookmark
class TestBrowserBookmark(GaiaMtbfTestCase):
_bookmark_added = False
def setUp(self):
GaiaMtbfTestCase.setUp(self)
self.connect_to_network()
self.test_url = 'http://mozqa.com/data/firefox/layout/mozilla.html'
curr_time = repr(time.time()).replace('.', '')
self.bookmark_title = 'gaia%s' % curr_time[10:]
self.homescreen = Homescreen(self.marionette)
self.browser = Browser(self.marionette)
self.browser.launch()
def test_browser_bookmark(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(self.test_url)
self.browser.tap_bookmark_button()
bookmark = self.browser.tap_add_bookmark_to_home_screen_choice_button()
self.wait_for_element_displayed(*bookmark._bookmark_title_input_locator)
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()
self.wait_for_element_displayed('id', 'bookmark-title')
self.homescreen.wait_for_app_icon_present(self.bookmark_title)
self._bookmark_added = self.homescreen.is_app_installed(self.bookmark_title)
if self.find_element('id', 'edit-button').is_displayed():
self.find_element('id', 'edit-button').tap()
self.assertTrue(self._bookmark_added, 'The bookmark %s was not found to be installed on the home screen.' % self.bookmark_title)
def tearDown(self):
# make sure it goes back to the top for activating editing mode
self.device.touch_home_button()
self.device.touch_home_button()
# delete the bookmark
self.apps.switch_to_displayed_app()
self.homescreen.activate_edit_mode()
self.confirm_dialog = self.homescreen.installed_app(self.bookmark_title).tap_delete_app()
self.confirm_dialog.tap_confirm()
self.data_layer.disable_wifi()
GaiaMtbfTestCase.tearDown(self)
示例15: test_browser_search
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'))