I have a website where I need to automate some actions.
Every time a customer does a purchase, a div with an input and a submit button appears. On that div I need to enter a value and click submit. The div then closes until the next purchase appears in the same div. I need to do the same actions, and so on.
It's indefinite.
I already found some solutions that point to the direction: Selenium - wait until element is present, visible and interactable
WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".reply-button"))).click()
But I can't provide a specific time to wait. I need a solution that keeps going in a loop indefinitely and progress all purchases throughout the day
Every solution that I find solves the problem that the website takes time to load. But I have a completely different problem underlying. I need to wait for a purchases to happen. So I can't set a specific time to wait. It could be indefinite.
What Selenium function could help me -in a best practice way- with my problem?
CodePudding user response:
while true:
try:
WebDriverWait(browser, 30).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".reply-button"))).click()
except:
continue
else:
break