0

Tried to find but without success (at least for my case). Namely, I have to confirm for a textbox field that is non-editable. Data is already written (actually, username) and must not be changed by user (so I have to confirm that is non-editable). Tried this:

WebElement readonly = driver.findElement(By.id("//*[@id=\"settings\"]/div[3]/div/div"));
    String fieldName = readonly.getAttribute("disabled");

Result is error. That element looks on page (when inspected):

<form action="settings_id" id="settings" method="post" enctype="multipart/form-data">   .
 <div class="row collapse"> (3rd div)
 <div class="medium-12 columns">
 <div class="settings-input-disabled">username of logged user</div>

On front of application is shown greyed username of logged user. Thank you in advance.

Zoran
  • 491
  • 7
  • 22
  • Can you tell me where is the textbox? `disabled` is an attribute of `input` element. You can't get that property from a `div` – Buaban Oct 19 '17 at 08:47
  • @Buaban - that is element which I want to check (textbox which has disabled input). – Zoran Oct 19 '17 at 08:59

1 Answers1

1

You could check for disabled word in class attribute .

WebElement readonly = driver.findElement(By.id("//*[@id=\"settings\"]/div[3]/div/div"));
    String fieldName = readonly.getAttribute("class");
if(fieldName.contains("disabled")){
//  Your code
}