0

I have inspected the element and got the following code.
This button "Activate" appears only once in 4 hours. To run the process I need to find this element.

I tried using:

  1. find_element_by_class_name
  2. find_element_by_link_text
<div class="wrapper">
<button class="w-full h-14 pt-2 pb-1 px-3 bg-accent text-dark-1 rounded-full md:rounded select-none cursor-pointer md:hover:shadow-big focus:outline-none md:focus:bg-accent-2 md:focus:shadow-small ">
<div class="font-medium">
<div class="text-17 md:text-18 md:font-bold leading-18">Activate</div> 
<div class="text-13 md:text-12 font-normal md:font-medium leading-normal">to run process</div></div>
</button>
</div>

2 Answers 2

1

This should search and refresh a page until an element popsup.

wait = WebDriverWait(driver, 30)
while True:
    try:
        wait.until(EC.presence_of_element_located((By.XPATH,"//div[@class='wrapper']/div[.='Activate']")))
        break
    except:
        driver.refresh()

Import

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC
Sign up to request clarification or add additional context in comments.

Comments

0

I've had the same issue for that particular website and I have finally been able to solve it. What I did is find the 'iframe' of the website through Chromes inspect element tool.

This is where you will find the iframe source:

enter image description here

Once you discover this, code the following:

    while True:
    try: 
        self.driver.get("Enter Iframe src here")
        time.sleep(4)
        self.driver.find_element(By.CSS_SELECTOR, ".wrapper > .w-full").click()
        break
    except NoSuchElementException:
        self.driver.refresh()
        time.sleep(10)

Do note that there may be a better way to do this by dynamically getting the iframe src. But this should work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.