I am currently working on a python (3.7) CLI program that uses Selenium and will be used by a diverse group of people.
The problem I ran into was the following:
For setting options like "headless" in Chrome I use
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(executable_path,options=chrome_options)
For Firefox, the code looks like this:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(executable_path,options=options)
So I wanted to know if there is a way to normalise these settings/ handle different browsers elegantly or do I have to write everything basically 2 or even 3 (might add Safari or Opera) times?