Reputation: 81
I need to verify whether placeholder/helper text is displayed for a field.
In this example it is Min. $50.00
I don't see any placeholder/helper text attribute defined inside the div tags.
My field looks like . Displayed amount (in this example $50.00) is dynamic.
Code for the above field looks like
<div class="unit" style="padding-left:32px;">
<input id="Amount" type="text" class="inputAlign optionalHintText" size="18" maxlength="30"/>
<div id="sharesValueForPercent" class="TextMd"></div>
</div>
I tried different ways to get the text (Min$50.00). Can someone help me on this. Appreciate your response.
Upvotes: 1
Views: 3162
Reputation: 193108
To extract the placeholder text i.e. $50.00 you can use either of the following Locator Strategies:
Using cssSelector:
System.out.println(driver.findElement(By.cssSelector("input.inputAlign.optionalHintText#Amount")).getAttribute("value"));
Using xpath:
System.out.println(driver.findElement(By.xpath("//input[@class='inputAlign optionalHintText' and @id='Amount']")).getAttribute("value"));
Upvotes: 1