Basic Usage
If you want to use different types of browsers – for example, Firefox, Edge, Chrome, etc. – define this in the BrowserSettings
class:
Python |
---|
| from browserist import Browser, BrowserSettings, BrowserType
settings = BrowserSettings(type=BrowserType.FIREFOX)
with Browser(settings) as browser:
browser.open.url("https://example.com")
browser.wait.seconds(5)
|
Supported Browsers
Name | Type | Notes |
Chrome | BrowserType.CHROME | Default (except for Windows) |
Edge | BrowserType.EDGE | Default for Windows |
Firefox | BrowserType.FIREFOX | |
Internet Explorer | BrowserType.INTERNET_EXPLORER | |
Safari | BrowserType.SAFARI | |
More information about installation of browser drivers.
Custom Browser Executable
If the browser executable isn't in a default folder, choose which file to use by setting the path_to_executable
option in the BrowserSettings
class.
Python |
---|
| from browserist import Browser, BrowserSettings, BrowserType
settings = BrowserSettings(
type=BrowserType.FIREFOX,
path_to_executable="/path/to/executable/firefox.exe")
with Browser(settings) as browser:
browser.open.url("https://example.com")
browser.wait.seconds(5)
|
How to Run Multiple Browsers
When you have multiple browser drivers installed, you can run them in sequence like this:
Python |
---|
| from browserist import Browser, BrowserSettings, BrowserType
chrome = BrowserSettings(type=BrowserType.CHROME)
edge = BrowserSettings(type=BrowserType.EDGE)
firefox = BrowserSettings(type=BrowserType.FIREFOX)
for settings in [chrome, edge, firefox]:
with Browser(settings) as browser:
browser.open.url("https://example.com")
browser.wait.seconds(5)
|