Skip to content

How to Automate Basic Browser Navigation#

Standard Buttons#

Similar to Selenium, use these simple commands to automate the browser:

Action Code Description
Forward browser.forward() Press the browser's back button
Back browser.back() Press the browser's forward button
Refresh browser.refresh() Reload the current page
Quit browser.quit() Close the browser

Examples#

Python
1
2
3
4
5
6
7
8
from browserist import Browser

browser = 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
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
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