Reputation: 13
I wanted my script to do something at certain hour, minute and second
i already have a code but i need it to do what it supposed to do at certain hour, minute and second
self.driver.get(link)
time.sleep(1)
add_to_cart_button = self.driver.find_element_by_class_name("product-variation")
add_to_cart_button.click()
time.sleep(2)
button = self.driver.find_element_by_class_name("btn btn-solid-primary btn--l YtgjXY")
button.click()
That is my code, can anyone help me, i need the button.click()
to click at for example 18:01:59
Upvotes: 1
Views: 146
Reputation: 15488
You can try like this:
from datetime import datetime, time
from time import sleep
def wait_start(runTime, action):
startTime = time(*(map(int, runTime.split(':'))))
while startTime > datetime.today().time():
sleep(1)
wait_start('18:01:59', lambda: button.click())
Upvotes: 1