BrowserWindow

BrowserWindow

class firefox_puppeteer.ui.browser.window.BrowserWindow(*args, **kwargs)

Representation of a browser window.

close(trigger='menu', force=False)

Closes the current browser window by using the specified trigger.

Parameters:
  • trigger – Optional, method to close the current browser window. This can be a string with one of menu or shortcut, or a callback which gets triggered with the current BrowserWindow as parameter. Defaults to menu.
  • force – Optional, forces the closing of the window by using the Gecko API. Defaults to False.
closed

Returns closed state of the chrome window.

Returns:True if the window has been closed.
default_homepage

The default homepage as used by the current locale.

Returns:The default homepage for the current locale.
focus()

Sets the focus to the current chrome window.

focused

Returns True if the chrome window is focused.

Returns:True if the window is focused.
get_final_url(url)

Loads the page at url and returns the resulting url.

This function enables testing redirects.

Parameters:url – The url to test.
Returns:The resulting loaded url.
handle

Returns the window handle of the chrome window.

Returns:window handle.
is_private

Returns True if this is a Private Browsing window.

loaded

Checks if the window has been fully loaded.

Returns:True, if the window is loaded.
localize_entity(entity_id)

Returns the localized string for the specified DTD entity id.

Parameters:entity_id – The id to retrieve the value from.
Returns:The localized string for the requested entity.
Raises:MarionetteException – When entity id is not found.
localize_property(property_id)

Returns the localized string for the specified property id.

Parameters:property_id – The id to retrieve the value from.
Returns:The localized string for the requested property.
Raises:MarionetteException – When property id is not found.
menubar

Provides access to the menu bar, for example, the File menu.

See the MenuBar reference.

navbar

Provides access to the navigation bar. This is the toolbar containing the back, forward and home buttons. It also contains the location bar.

See the NavBar reference.

notification

Provides access to the currently displayed notification.

open_about_window(trigger='menu')

Opens the about window by using the specified trigger.

Parameters:trigger – Optional, method in how to open the new browser window. This can either the string menu or a callback which gets triggered with the current BrowserWindow as parameter. Defaults to menu.
Returns:AboutWindow instance of the opened window.
open_browser(trigger='menu', is_private=False)

Opens a new browser window by using the specified trigger.

Parameters:
  • 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 BrowserWindow as parameter. Defaults to menu.
  • is_private – Optional, if True the new window will be a private browsing one.
Returns:

BrowserWindow instance for the new browser window.

open_page_info_window(trigger='menu')

Opens the page info window by using the specified trigger.

Parameters: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 BrowserWindow as parameter. Defaults to menu.
Returns:PageInfoWindow instance of the opened window.
open_window(callback=None, expected_window_class=None, focus=True)

Opens a new top-level chrome window.

Parameters:
  • callback – Optional, function to trigger the window to open. It is triggered with the current BaseWindow as parameter. Defaults to window.open().
  • expected_class – Optional, check for the correct window class.
  • focus – Optional, if true, focus the new window. Defaults to True.
send_shortcut(command_key, **kwargs)

Sends a keyboard shortcut to the window.

Parameters:
  • command_key – The key (usually a letter) to be pressed.
  • accel – Optional, If True, the Accel modifier key is pressed. This key differs between OS X (Meta) and Linux/Windows (Ctrl). Defaults to False.
  • alt – Optional, If True, the Alt modifier key is pressed. Defaults to False.
  • ctrl – Optional, If True, the Ctrl modifier key is pressed. Defaults to False.
  • meta – Optional, If True, the Meta modifier key is pressed. Defaults to False.
  • shift – Optional, If True, the Shift modifier key is pressed. Defaults to False.
switch_to(focus=False)

Switches the context to this chrome window.

By default it will not focus the window. If that behavior is wanted, the focus parameter can be used.

Parameters:focus – If True, the chrome window will be focused.
Returns:Current window as BaseWindow instance.
tabbar

Provides access to the tab bar.

See the TabBar reference.

wait_for_notification(notification_class=<class 'firefox_puppeteer.ui.browser.notifications.BaseNotification'>, timeout=5)

Waits for the specified notification to be displayed.

Parameters:
  • notification_class – Optional, the notification class to wait for. If None is specified it will wait for any notification to be closed. Defaults to BaseNotification.
  • timeout – Optional, how long to wait for the expected notification. Defaults to 5 seconds.
window_element

Returns the inner DOM window element.

Returns:DOM window element.