1

I am using python selenium with firefox to check if a pages title

WebDriverWait(driver, 60).until(lambda x: 'Page 1' in driver.title or 'Page 2' in driver.title)

I am now wanting to also check if a HTML element is present, can I do this within this WebDriverWait statement or should I further process the result?

1 Answer 1

2

One option would be to reuse the same WebDriverWait() instance and issue a follow-up wait:

wait = WebDriverWait(driver, 60)
wait.until(lambda x: 'Page 1' in driver.title or 'Page 2' in driver.title)
wait.until(EC.presence_of_element_located((By.ID, "myid")))

Or, you can also combine them in a single function:

def mywait(driver):
    if 'Page 1' in driver.title or 'Page 2' in driver.title:
        return EC.presence_of_element_located((By.ID, "myid"))(driver)

wait = WebDriverWait(driver, 60)
wait.until(mywait)
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.