Tabbar

TabBar

class firefox_puppeteer.ui.browser.tabbar.TabBar(marionette, window, element)

Wraps the tabs toolbar DOM element inside a browser window.

close_all_tabs(exceptions=None)

Forces closing of all open tabs.

There is an optional exceptions list, which can be used to exclude specific tabs from being closed.

Parameters:exceptions – Optional, list of Tab instances not to close.
close_tab(tab=None, trigger='menu', force=False)

Closes the tab by using the specified trigger.

By default the currently selected tab will be closed. If another Tab is specified, that one will be closed instead. Also when the tab is closed, a switch_to() call is automatically performed, so that the new selected tab becomes active.

Parameters:
  • tab – Optional, the Tab instance to close. Defaults to the currently selected tab.
  • trigger – Optional, method to close the current tab. This can be a string with one of menu or shortcut, or a callback which gets triggered with the Tab as parameter. Defaults to menu.
  • force – Optional, forces the closing of the window by using the Gecko API. Defaults to False.
static get_handle_for_tab(marionette, tab_element)

Retrieves the marionette handle for the given Tab instance.

Parameters:
  • marionette – An instance of the Marionette client.
  • tab_element – The DOM element corresponding to a tab inside the tabs toolbar.
Returns:

handle of the tab.

menupanel

A MenuPanel instance which represents the menu panel at the far right side of the tabs toolbar.

Returns:MenuPanel instance.
newtab_button

The DOM element which represents the new tab button.

Returns:Reference to the new tab button.
open_tab(trigger='menu')

Opens a new tab in the current browser window.

If the tab opens in the foreground, a call to switch_to() will automatically be performed. But if it opens in the background, the current tab will keep its focus.

Parameters:trigger – Optional, method to open the new tab. This can be a string with one of menu, button or shortcut, or a callback which gets triggered with the current Tab as parameter. Defaults to menu.
Returns:Tab instance for the opened tab.
selected_index

The index of the currently selected tab.

Returns:Index of the selected tab.
selected_tab

A Tab instance of the currently selected tab.

Returns:Tab instance.
switch_to(target)

Switches the context to the specified tab.

Parameters:target – The tab to switch to. target can be an index, a Tab instance, or a callback that returns True in the context of the desired tab.
Returns:Instance of the selected Tab.
tabs

List of all the Tab instances of the current browser window.

Returns:List of Tab instances.
toolbar

The DOM element which represents the tab toolbar.

Returns:Reference to the tabs toolbar.

Tab

class firefox_puppeteer.ui.browser.tabbar.Tab(marionette, window, element)

Wraps a tab DOM element.

certificate

The SSL certificate assiciated with the loaded web page.

Returns:Certificate details as JSON blob.
close(trigger='menu', force=False)

Closes the tab by using the specified trigger.

When the tab is closed a switch_to() call is automatically performed, so that the new selected tab becomes active.

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

The DOM element which represents the tab close button.

Returns:Reference to the tab close button.
handle

The handle of the content window.

Returns:content window handle.
location

Returns the current URL

Returns:Current URL
select()

Selects the tab and sets the focus to it.

selected

Checks if the tab is selected.

Returns:True if the tab is selected.
switch_to()

Switches the context of Marionette to this tab.

Please keep in mind that calling this method will not select the tab. Use the select() method instead.

tab_element

The inner tab DOM element.

Returns:Tab DOM element.