generated from cisagov/ScubaGear
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encapsulate selenium driver setup into a class
- Loading branch information
1 parent
b3741d4
commit ec33d00
Showing
5 changed files
with
45 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
The Browser class encapsulates the setup, usage, and teardown of a | ||
Selenium WebDriver instance for automated browser interactions. | ||
""" | ||
|
||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
|
||
class Browser: | ||
def __init__(self): | ||
chrome_options = Options() | ||
chrome_options.add_argument("--headless") | ||
chrome_options.add_argument("--no-sandbox") | ||
chrome_options.add_argument("--disable-dev-shm-usage") | ||
|
||
self.driver = webdriver.Chrome(options=chrome_options) | ||
|
||
def get(self, url): | ||
self.driver.get(url) | ||
|
||
def quit(self): | ||
self.driver.quit() | ||
|
||
def find_element(self, by, value): | ||
return self.driver.find_element(by, value) | ||
|
||
def find_elements(self, by, value): | ||
return self.driver.find_elements(by, value) | ||
|
||
def current_url(self): | ||
return self.driver.current_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters