0

So I have a section of code that checks a part of a webpage to see if the status has been changed to get to the next step in the script. It refreshes the page if it hasn't, and ideally, I would like the script to wait at this webpage for about 5-10 seconds before it refreshes the page again. Here is my current loop for this:

orderElem = driver.find_element(By.CSS_SELECTOR, "dd.Production.Status")

while(orderElem.text != "Output Complete"):
        WebDriverWait(driver, 10)
        driver.refresh()
        WebDriverWait(driver, 5).until(
            EC.visibility_of_element_located((By.CSS_SELECTOR, "dd.Production.Status"))
        )
        orderElem = driver.find_element(By.CSS_SELECTOR, "dd.Production.Status")
1
  • are you looking for something like time.sleep()? Commented Feb 24, 2016 at 20:07

1 Answer 1

2

You can explicitly just wait with time.sleep(10) instead of WebDriverWait.

It seems like you are trying to refresh-poll the page every 10 second until orderElem.text == 'Output Complete', in which case:

def until_func(driver):
    driver.refresh()
    elem = driver.find_element_by_css_selector("dd.Production.Status")
    if elem.is_displayed() and elem.text == 'Output Complete':
        return elem
orderElem = WebDriverWait(driver, timeout=60, poll_frequency=10).until(until_func)

This will refresh the page every 10s, check if element desired is visible and has the correct text, and return the element when those conditions are met.

Sign up to request clarification or add additional context in comments.

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.