1

I have this html:

<input _wad-f341 type="text" autocomplete="off" kkwdnkwn class="classname" placeholder="Search  here" id="ppui-search-0-input">

Using developer tools I am getting the xpath and I am using below code to check if the search area is loaded or not.

WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, "//*[@id='ppui-search-0-input']")))

I am getting timeout as element was not found. Can anyone please help me? Is there any other way apart from id like using the placeholder desription?

1 Answer 1

1

Ideally to locate a clickable element instead of presence_of_element_located() you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.classname[placeholder='Search  here'][id^='ppui-search']")))
    
  • Using XPATH:

    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='classname' and @placeholder='Search  here'][starts-with(@id, 'ppui-search')]")))
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
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.