import time import schedule from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.common.exceptions import NoSuchElementException, WebDriverException class WebDriverIgnition: def setup_method(self, method): chrome_options = Options() chrome_options.add_argument("--headless") # Run in headless mode chrome_options.add_argument("--disable-gpu") chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--window-size=1920,1080") self.driver = webdriver.Chrome(options=chrome_options) self.vars = {} def teardown_method(self, method): try: self.driver.quit() except WebDriverException: pass def reset_trial(self, url, user, password): try: self.driver.get(url) self.driver.implicitly_wait(10) reset_anchor = self.driver.find_element(By.ID, "reset-trial-anchor") if reset_anchor.is_displayed(): reset_anchor.click() self.driver.find_element(By.NAME, "username").send_keys(user) self.driver.find_element(By.CLASS_NAME, "button-message").click() self.driver.find_element(By.NAME, "password").send_keys(password) self.driver.find_element(By.CLASS_NAME, "button-message").click() self.driver.find_element(By.ID, "reset-trial-anchor").click() else: print("Reset anchor not visible.") except (NoSuchElementException, WebDriverException) as e: print(f"Error occurred: {e}") finally: self.teardown_method(None) # Configuration sUrlIgniton = "http://localhost:8088/web/home?0" sUser = "admin" sPassword = "password" def run_ignition_reset(): ignition = WebDriverIgnition() ignition.setup_method(None) ignition.reset_trial(sUrlIgniton, sUser, sPassword) # Run immediately once run_ignition_reset() # Schedule to run every 1 minute schedule.every(1).minutes.do(run_ignition_reset) while True: schedule.run_pending() time.sleep(1)