1

I want to wait for this xpath element until the xpath element I use below opens. How can I do it. Thank you in advance for your answers.

//div[@class="expander_content"]/ul/li[3]
3
  • Does this help. Commented Jan 29, 2022 at 18:53
  • Please let me know if I understand correctly what you asked for and my solution is working for you Commented Jan 29, 2022 at 19:57
  • Thanks, the solutions shared in the thread worked Commented Jan 30, 2022 at 14:16

2 Answers 2

2

The best approach to wait for elements with Selenium is to use Expected Conditions explicit waits.
With the following imports

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

And after initializing an instance of the wait object like the following

wait = WebDriverWait(driver, 20)

You will be able to wait until the element visibility with:

wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@class="expander_content"]/ul/li[3]')))
Sign up to request clarification or add additional context in comments.

Comments

0

We have multiple Waits in selenium but the best one is explicit.

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));

Now you will be able to apply wait according to your need, there is multiple expected conditions out there or you can customize it:

wait.until(ExpectedConditions.Condition(Locator));

Note: For details please visit Waits

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.