Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Selenium - WebDriverWait until either titles are displayed

I am trying to implement a wait by checking if the page title contains 'Page 1' like this

try:
    WebDriverWait(driver, 10).until(EC.title_contains("Page 1"))
except TimeoutException as e:
    return

How can I modify this so it also checks for a page title of 'Page 2', so if either of those page titles show up then it passes?


1 Answers

You can try below code:

try:
    WebDriverWait(driver, 10).until(lambda x: 'Page 1' in driver.title or 'Page 2' in driver.title)
except TimeoutException as e:
    pass
like image 197
Andersson Avatar answered Sep 03 '26 18:09

Andersson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!