Added selenium driver.
Some checks failed
Home Cluster Builds/Image-FastApi-Arm64/pipeline/head There was a failure building this commit

This commit is contained in:
2023-01-13 10:15:30 +02:00
parent c6b462bb7f
commit 2def52546b
2 changed files with 54 additions and 3 deletions

21
examples/selenium.py Normal file
View 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()