DriverClass : In this class we will create a browser driver method which is used to return the required driver object.
DeviceConfig : In this class we will assign the device details to the variables to use then in DriverClass as reusable.
DriverClass.py
from selenium import webdriver import SeleniumFrameWork.utilities.CustomLogger as cl class WebDriverClass: log = cl.customLogger() def getWebDriver(self, browserName): driver = None if browserName == "chrome": driver = webdriver.Chrome("/Users/admin/Documents/Skill2Lead/Others/drivers/chromedriver.exe") self.log.info("Chrome Driver is initializing") elif browserName == "safari": driver = webdriver.Safari() self.log.info("Safari Driver is initializing") elif browserName == "firefox": driver = webdriver.Firefox(executable_path="/Users/admin/Documents/Skill2Lead/Others/drivers/geckodriver") self.log.info("FireFox Driver is initializing") return driver
DeviceConfig.py
platformName = "Windows 10" bName = "chrome" bVersion = "latest" url = "http://www.dummypoint.com/seleniumtemplate.html" webPageTitle = "Selenium Template --DummyPoint"