Python Forum
Looping/Scheduling webelement select - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Looping/Scheduling webelement select (/thread-33734.html)



Looping/Scheduling webelement select - Dredd - May-22-2021

Hi guys,

I am wanting help with either turning this below code into either a For statement so I can ultimately create a loop for hourly or scheduling the below code to schedule it every hour:

from selenium import webdriver
from selenium import webdriver
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
import schedule
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By


driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://www.google.com/search?q=bing&source=lnms&tbm=nws&sa=X&ved=2ahUKEwjfy6yg0dnwAhWFvZ4KHV07BuQQ_AUoA3oECAEQBQ&biw=1036&bih=812&dpr=1.5")
button = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, "/html/body/div[7]/div/div[3]/div/div[1]/div/div[1]/div/div[4]")))
button.click()    



RE: Looping/Scheduling webelement select - Larz60+ - May-22-2021

remove 2 of the 3 imports lines 1-3
you can use 'sched' ( https://docs.python.org/3/library/sched.html ) for scheduling,

or do it from OS command with cron (Linux), not sure what windows equivalent is.