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 |
---|
| 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:
| 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
| 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
| 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
| 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 |
---|
| from browserist import Browser
with Browser() as browser:
browser.open.url("https://example.com")
|
refresh()
Refresh the current page.
Example
| from browserist import Browser
with Browser() as browser:
browser.open.url("https://example.com")
browser.refresh()
|