Megha N
Megha N

Reputation: 1

I'm not able to get text value from a disabled text

I need to get value from a disabled text box

This is what I'm tried

WebElement text= driver.findElement(By.id("text"));
System.out.println("text= " +ssn.getAttribute("value"));
<input _ngcontent-c10="" class="form-control ng-untouched ng-pristine" id="text" name="TEXT" placeholder="12345" type="text" disabled="">

It is printing this

text = null

Upvotes: 0

Views: 111

Answers (1)

frianH
frianH

Reputation: 7563

Your input element has no value attribute, so .getAttribute("value")); is useless

Your element have the following attribute :

  • _ngcontent-c10
  • class
  • id
  • name
  • placeholder
  • type
  • disabled

May this is what you mean :

WebElement text = driver.findElement(By.xpath("//input[@id='text']"));
System.out.println("text= " +text.getAttribute("placeholder"));

It will get 12345

Upvotes: 1

Related Questions