generated from Templates/Utility-Image-Builder
Added selenium driver.
Some checks failed
Home Cluster Builds/Image-FastApi-Arm64/pipeline/head There was a failure building this commit
Some checks failed
Home Cluster Builds/Image-FastApi-Arm64/pipeline/head There was a failure building this commit
This commit is contained in:
21
examples/selenium.py
Normal file
21
examples/selenium.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium import webdriver
|
||||
|
||||
def set_chrome_options() -> None:
|
||||
"""Sets chrome options for Selenium.
|
||||
Chrome options for headless browser is enabled.
|
||||
"""
|
||||
chrome_options = Options()
|
||||
chrome_options.add_argument("--headless")
|
||||
chrome_options.add_argument("--no-sandbox")
|
||||
chrome_options.add_argument("--disable-dev-shm-usage")
|
||||
chrome_prefs = {}
|
||||
chrome_options.experimental_options["prefs"] = chrome_prefs
|
||||
chrome_prefs["profile.default_content_settings"] = {"images": 2}
|
||||
return chrome_options
|
||||
|
||||
if __name__ == "__main__":
|
||||
chrome_options = set_chrome_options()
|
||||
driver = webdriver.Chrome(options=chrome_options)
|
||||
# Do stuff with your driver
|
||||
driver.close()
|
||||
Reference in New Issue
Block a user