def _toggle(self, trigger="api"): is_open = self.is_open() target_popup_state = "closed" if is_open else "open" if callable(trigger): trigger() elif trigger == "button": self._toolbar_button.click() elif trigger == "shortcut": window = Windows(lambda: self.marionette).current window.send_shortcut("r", alt=True, shift=True) elif trigger == "api": self._ensure_popup_state(target_popup_state) else: raise ValueError("Unknown trigger method: \"{}\"".format(trigger)) if target_popup_state == "open": # Briefly enter the iframe to make sure the it's loaded. with self.in_iframe(): pass ( Wait(self.marionette, timeout=1) .until(lambda _: self.is_open() is not is_open) )
def _toggle(self, trigger="api"): is_open = self.is_open() if callable(trigger): trigger() elif trigger == "button": self._toolbar_button.click() elif trigger == "shortcut": window = Windows(lambda: self.marionette).current window.send_shortcut("r", alt=True, shift=True) elif trigger == "api": self._ensure_popup_state("closed" if is_open else "open") else: raise ValueError("Unknown trigger method: \"{}\"".format(trigger)) (Wait(self.marionette, timeout=1).until(lambda _: self.is_open() is not is_open))
def _toggle(self, trigger="api"): is_open = self.is_open() if callable(trigger): trigger() elif trigger == "button": self._toolbar_button.click() elif trigger == "shortcut": window = Windows(lambda: self.marionette).current window.send_shortcut("r", alt=True, shift=True) elif trigger == "api": self._ensure_popup_state("closed" if is_open else "open") else: raise ValueError("Unknown trigger method: \"{}\"".format(trigger)) ( Wait(self.marionette, timeout=1) .until(lambda _: self.is_open() is not is_open) )
def allow(self): """Allow the redirection.""" self._allow_button.click() # Wait for the tab to load. # TODO: Bug 1140470: use replacement for mozmill's waitForPageLoad Wait(self.marionette).until(lambda _: not self.is_shown()) win = Windows(lambda: self.marionette).current tab = win.tabbar.selected_tab Tabs(lambda: self.marionette).wait_until_loaded(tab)
def _toggle(self, trigger="api"): is_open = self.is_open() target_popup_state = "closed" if is_open else "open" if callable(trigger): trigger() elif trigger == "button": self._toolbar_button.click() elif trigger == "shortcut": window = Windows(lambda: self.marionette).current window.send_shortcut("r", alt=True, shift=True) elif trigger == "api": self._ensure_popup_state(target_popup_state) else: raise ValueError("Unknown trigger method: \"{}\"".format(trigger)) if target_popup_state == "open": # Briefly enter the iframe to make sure the it's loaded. with self.in_iframe(): pass (Wait(self.marionette, timeout=1).until(lambda _: self.is_open() is not is_open))
:param trigger: Optional, method in how to open the new browser window. This can be a string with one of `menu` or `shortcut`, or a callback which gets triggered with the current :class:`BrowserWindow` as parameter. Defaults to `menu`. :returns: :class:`PageInfoWindow` instance of the opened window. """ def callback(win): # Prepare action which triggers the opening of the browser window if callable(trigger): trigger(win) elif trigger == 'menu': self.menubar.select_by_id('tools-menu', 'menu_pageInfo') elif trigger == 'shortcut': if win.marionette.session_capabilities[ 'platformName'] == 'windows': raise ValueError( 'Page info shortcut not available on Windows.') win.send_shortcut( win.localize_entity('pageInfoCmd.commandkey'), accel=True) elif trigger == 'context_menu': # TODO: Add once we can do right clicks pass else: raise ValueError('Unknown opening method: "%s"' % trigger) return BaseWindow.open_window(self, callback, PageInfoWindow) Windows.register_window(BrowserWindow.window_type, BrowserWindow)
def open_page_info_window(self, trigger='menu'): """Opens the page info window by using the specified trigger. :param trigger: Optional, method in how to open the new browser window. This can be a string with one of `menu` or `shortcut`, or a callback which gets triggered with the current :class:`BrowserWindow` as parameter. Defaults to `menu`. :returns: :class:`PageInfoWindow` instance of the opened window. """ def callback(win): # Prepare action which triggers the opening of the browser window if callable(trigger): trigger(win) elif trigger == 'menu': self.menubar.select_by_id('tools-menu', 'menu_pageInfo') elif trigger == 'shortcut': if win.marionette.session_capabilities['platform'] == 'WINDOWS_NT': raise ValueError('Page info shortcut not available on Windows.') win.send_shortcut(win.get_entity('pageInfoCmd.commandkey'), accel=True) elif trigger == 'context_menu': # TODO: Add once we can do right clicks pass else: raise ValueError('Unknown opening method: "%s"' % trigger) return BaseWindow.open_window(self, callback, PageInfoWindow) Windows.register_window(BrowserWindow.window_type, BrowserWindow)
from __future__ import absolute_import from marionette_driver import By from firefox_puppeteer.ui.about_window.deck import Deck from firefox_puppeteer.ui.windows import BaseWindow, Windows class AboutWindow(BaseWindow): """Representation of the About window.""" window_type = 'Browser:About' dtds = [ 'chrome://branding/locale/brand.dtd', 'chrome://browser/locale/aboutDialog.dtd', ] @property def deck(self): """The :class:`Deck` instance which represents the deck. :returns: Reference to the deck. """ self.switch_to() deck = self.window_element.find_element(By.ID, 'updateDeck') return Deck(self.marionette, self, deck) Windows.register_window(AboutWindow.window_type, AboutWindow)
] properties = [ 'chrome://branding/locale/brand.properties', 'chrome://mozapps/locale/update/updates.properties', ] def __init__(self, *args, **kwargs): BaseWindow.__init__(self, *args, **kwargs) @property def wizard(self): """The :class:`Wizard` instance which represents the wizard. :returns: Reference to the wizard. """ # The deck is also the root element wizard = self.marionette.find_element(By.ID, 'updates') return Wizard(lambda: self.marionette, self, wizard) def select_next_page(self): """Clicks on "Next" button, and waits for the next page to show up.""" current_panel = self.wizard.selected_panel self.wizard.next_button.click() Wait(self.marionette).until( lambda _: self.wizard.selected_panel != current_panel) Windows.register_window(UpdateWizardDialog.window_type, UpdateWizardDialog)
def close(self, trigger='shortcut', force=False): """Closes the current page info window by using the specified trigger. :param trigger: Optional, method to close the current window. This can be a string with one of `menu` (OS X only) or `shortcut`, or a callback which gets triggered with the current :class:`PageInfoWindow` as parameter. Defaults to `shortcut`. :param force: Optional, forces the closing of the window by using the Gecko API. Defaults to `False`. """ def callback(win): # Prepare action which triggers the opening of the browser window if callable(trigger): trigger(win) elif trigger == 'menu': # TODO: Make use of menubar class once it supports ids menu = win.marionette.find_element(By.ID, 'menu_closeWindow') menu.click() elif trigger == 'shortcut': win.send_shortcut(win.get_entity('closeWindow.key'), accel=True) else: raise ValueError('Unknown closing method: "%s"' % trigger) BaseWindow.close(self, callback, force) Windows.register_window(PageInfoWindow.window_type, PageInfoWindow)
""" deck = self.window_element.find_element(By.ID, 'mainDeck') return Deck(lambda: self.marionette, self, deck) def close(self, trigger='shortcut', force=False): """Closes the current page info window by using the specified trigger. :param trigger: Optional, method to close the current window. This can be a string with one of `menu` (OS X only) or `shortcut`, or a callback which gets triggered with the current :class:`PageInfoWindow` as parameter. Defaults to `shortcut`. :param force: Optional, forces the closing of the window by using the Gecko API. Defaults to `False`. """ def callback(win): # Prepare action which triggers the opening of the browser window if callable(trigger): trigger(win) elif trigger == 'menu': self.menubar.select_by_id('file-menu', 'menu_close') elif trigger == 'shortcut': win.send_shortcut(win.get_entity('closeWindow.key'), accel=True) else: raise ValueError('Unknown closing method: "%s"' % trigger) BaseWindow.close(self, callback, force) Windows.register_window(PageInfoWindow.window_type, PageInfoWindow)
'chrome://branding/locale/brand.dtd', 'chrome://mozapps/locale/update/updates.dtd', ] properties = [ 'chrome://branding/locale/brand.properties', 'chrome://mozapps/locale/update/updates.properties', ] @property def wizard(self): """The :class:`Wizard` instance which represents the wizard. :returns: Reference to the wizard. """ # The deck is also the root element wizard = self.marionette.find_element(By.ID, 'updates') return Wizard(self.marionette, self, wizard) def select_next_page(self): """Clicks on "Next" button, and waits for the next page to show up.""" current_panel = self.wizard.selected_panel self.wizard.next_button.click() Wait(self.marionette).until( lambda _: self.wizard.selected_panel != current_panel, message='Next panel has not been selected.') Windows.register_window(UpdateWizardDialog.window_type, UpdateWizardDialog)