I have this function which I want it to be called in the main function in flask app, and want to pass it to another class. The catch here is I want to create the instance only once while starting the server and have to pass it globally to all the classes
def webdriver_instance():
from selenium import webdriver
from selenium.webdriver import FirefoxOptions
opts = FirefoxOptions()
opts.add_argument("--headless")
opts.add_argument("start-maximized")
opts.add_argument("disable-infobars")
opts.add_argument("--disable-extensions")
opts.add_argument('--no-sandbox')
opts.add_argument('--disable-application-cache')
opts.add_argument('--disable-gpu')
opts.add_argument("--disable-dev-shm-usage")
browser = webdriver.Firefox(firefox_options=opts)
return browser