How to get value from a placeholder using xpath

Viewed 67907

All of the elements are dynamic. I can see only Placeholder which is unique from the following html:-

<input 
   id="ext-gen1617" 
   type="text" 
   size="20" 
   class="x-form-field x-form-text x-form-focus" 
   autocomplete="off" 
   aria-invalid="false" 
   placeholder="Gender" 
   data-errorqtip="" 
   role="textbox" 
   aria-describedby="combobox-1166-errorEl" 
   aria-required="true" 
   style="width: 78px;"
/>

I need to get the value displayed in

placeholder="Gender". 

I tried using

//input[@placeholder='Gender']

But my webdriver script failed to identify it.

Can anyone please help me out with possible solution to it?

4 Answers

The best way is to find the element with CSS selector in this case - input[placeholder='Gender'], which can easily find the element.

Related