Partially completed coding of loop script, need help finishing.

Joined
Oct 7, 2022
Messages
1
Reaction score
0
New to coding so I'm at a bit of a loss here. So I'm trying to build a script which loops until a button (add to basket) is clickable. This full step by step list on how I wish the script to go is

1. Start loop.
2. Check if button is clickable.
3. If it is not clickable then refresh the page and go back to step 2.
4. If button is clickable then click it
5. If the button has been clicked, wait 5 seconds and check if a specific element has been found. If this element has not been found then refresh the page and go back to step 2
I6. f element is present then sent telegram notification and break.
I have coded the first 4 steps which is below:

Python:
while True:

    try:

        WebDriverWait(driver, 1).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.areas-filter-panel__find-button"))).click()

    except TimeoutException:   

        driver.refresh()

        continue

I just need a helping hand in coding the last two steps. The specific element I'm looking for is on a different page to the button I want to be clicked (eg: the checkout page). This element is:
Code:
ctl00$body$CountDown_timerMessage

Essentially I need the script to detect the presence of this element as sometimes the button becomes clickable, the script clicks the button but someone has already beaten me to this item; the item then can't be put into my basket but the current script I have stopped when the button becomes clickable. I need the script to make sure the webpage is the checkout page.

I have then coded a telegram message to alert me that the item is in my basket

Code:
telegram_send.send(messages=["TICKET IN BASKET"])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top