def Init(): global driver, config, userName, password, likeClassName, unLikeClassName, logger, numberOfLikes logger = LogHandler.Start() logger.getLogger('AutoLike') try: driver = SeleniumConfig.InitSelenium() config = ConfigParser.ConfigParser() config.read('config.ini') userName = config.get('DEFAULT', 'userName') password = config.get('DEFAULT', 'password') likeClassName = config.get('DEFAULT', 'likeClassName') unLikeClassName = config.get('DEFAULT', 'unLikeClassName') numberOfLikes = config.get('DEFAULT', 'numberOfLikes') except Exception as e: logger.error( "Unable to init chrome driver or config file. Exception: %s", e) raise Exception('Unable to init')
import selenium from selenium import webdriver from selenium.webdriver.chrome.options import Options import ConfigParser import LogHandler global logger logger = LogHandler.Start() def InitSelenium(): try: config = ConfigParser.ConfigParser() config.read('config.ini') try: optionsString = config.get('DEFAULT', 'chromeOptions') optionsList = optionsString.split(",") chrome_options = Options() for option in optionsList: chrome_options.add_argument(option) driver = webdriver.Chrome(chrome_options=chrome_options) except: logger.info("Chrome options don't exist") driver = webdriver.Chrome() return driver except Exception as e: