Skip to content

browser#

Main class of Browserist that sets the Selenium web driver and contains all helper functions.

How to initiate the browser driver:

Example

Basic usage:

Basic usage
1
2
3
4
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")

How to initiate the browser driver with custom settings and use Firefox:

1
2
3
4
5
6
from browserist import Browser, BrowserSettings

settings = BrowserSettings(browser_type=BrowserType.FIREFOX)

with Browser(settings) as browser:
    browser.open.url("https://example.com")

Functions#

back() #

Press the browser's back button.

Example
1
2
3
4
5
6
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.open.url("https://google.com")
    browser.back()  # Go back to previous page Example.com

forward() #

Press the browser's forward button.

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

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.open.url("https://google.com")
    browser.back()  # Go back to previous page Example.com
    browser.forward()  # Return to Google.com

quit() #

Quit the browser.

Example
1
2
3
4
5
from browserist import Browser

browser = Browser()
browser.open.url("https://example.com")
browser.quit()
Tip

Instead of manually quitting the browser with browser.quit(), it's recommend to use the context manager and with statements. The example above could then be refactored to:

Python
1
2
3
4
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")

refresh() #

Refresh the current page.

Example
1
2
3
4
5
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.refresh()