0

How to locate the element:

<input type="text" placeholder="Enter Area / Locality" class="" value="">

I tried:

//input[@placeholder='Enter Area / Locality']

but it is not working.

I want to send keys at this placeholder from selenium code.

Guy
  • 46,488
  • 10
  • 44
  • 88

1 Answers1

0

I don't see any issue with your code trial. As an alternative you can use the following based Locator Strategy:

//input[@placeholder=\"Enter Area / Locality\"]"

However, ideally as it is an <input> element and you want to invoke click() on it, you need to use elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input[placeholder='Enter Area / Locality']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@placeholder='Enter Area / Locality']"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352