Use config.yaml to define environment URLs and browser types. For example:
environment: "staging"
browser: "chrome"
implicit_wait_seconds: 10
In driver_factory.py, read these settings and set the implicit wait like this:
from selenium import webdriver
import yaml
with open('config/config.yaml') as f:
config = yaml.safe_load(f)
browser = config['browser']
implicit_wait = config['implicit_wait_seconds']
def create_driver():
if browser == 'chrome':
driver = webdriver.Chrome()
elif browser == 'firefox':
driver = webdriver.Firefox()
else:
raise ValueError('Unsupported browser')
driver.implicitly_wait(implicit_wait) # Set implicit wait here
return driver
This way, you can change wait times or browsers without changing code.