Skip to content

browser.window#

Functions#

close() #

Close close the current tab or, if it's the last tab in a window, the current browser window.

Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.window.open.new_tab("https://google.com")
    browser.window.close()

fullscreen() #

Fills the entire screen. Similar to pressing F11 in most browsers.

Example
browser.window.fullscreen()

maximize() #

Enlarge the browser window to the maximum allowed size.

Note

For most operating systems, the window will fill the screen, without blocking the operating system's own menus and toolbars. Obviously, the size of the browser window also depends on the device and its screen resolution.

Example
browser.window.maximize()

minimize() #

Minimizes the window of the current browsing context.

Note

The exact behavior of this command is specific to operating systems. Minimizing the window typically hides the window in the system tray.

Example
browser.window.minimize()

switch_to(window_handle) #

Switch to window/tab by handle ID or name.

Parameters:

Name Type Description Default
window_handle str

Handle ID or name of window/tab to switch to.

required
Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.window.open.new_tab("https://example.com", "tab_1")
    browser.window.open.new_tab("https://google.com", "tab_2")
    browser.window.switch_to("tab_1")

switch_to_original_window() #

Switch to initial window/tab.

Note

Browserist automatically remembers the handle ID of the initial window/tab when the browser is first opened.

Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.window.open.new_window("https://google.com")
    browser.window.switch_to_original_window()