3

I'm looking for data on a website with different webpages. When I move from one webpage to the other, I want to wait for the presence of a value called "location" using an implicit wait function. My code looks like this:

wait = WebDriverWait(driver, 
10).until(EC.presence_of_element_located((By.CLASS_NAME, 
"locationTitle")))

The HTML looks like this:

<div class="locationTitle">This Location</div>

Right now my code works for the first jump between page 1 and page 2. However, after the second page, the pages all have the same class 'locationTitle'. So I need to look for the page specific text that is "This Location". Do you know how?

Help would really be appreciated!

1 Answer 1

2

Try to use search By.XPATH instead of By.CLASS_NAME:

wait = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"//div[text()='This Location']")))
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.