is it possible to schedule my code by running it with schedule.every(10).seconds.do(example) or similar? I'm trying to schedule the Error Handling part in my code (XPath) which works with a While loop although because its in a While loop it refuses to run the other def functions, I want the XPath/error handling part to run in a loop with my Selenium window but detect and not interfere with the other def functions. it should just detect the XPath being there or not being there then run an exception if it doesn't detect.. Does anyone have a solution?
My code:
def example(): options = Options() options.add_experimental_option("detach", True) driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options) driver.get("example.com") driver.set_window_position(0, 0) driver.set_window_size(750, 512) while True: e = driver.find_elements(By.XPATH,"/html/body/div/div/div/div/div[2]/div/div/div[2]/div[2]/div[1]/span/button/span") if not e: print("Element not found") pyautogui.moveTo(89, 56) time.sleep(1) pyautogui.click() time.sleep(10)def example2(): options = Options() options.add_experimental_option("detach", True) driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install())) driver.get("example.com") driver.set_window_position(750, 0) driver.set_window_size(750, 512) while True: e = driver.find_elements(By.XPATH,"/html/body/div/div/div/div/div[2]/div/div/div[2]/div[2]/div[1]/span/button/span") if not e: print("Element not found") pyautogui.moveTo(850, 57) time.sleep(1) pyautogui.click()schedule.every().day.at("22:59").do(example)schedule.every().day.at("22:59").do(example2)while True: schedule.run_pending() time.sleep(1)