enter image description hereI want to get the data from disabled field. Here is the HTML: This field is a drop down and i want to identify selected data from the that field. for e.g. field name is Exchange and selected data is "ABC". My question is how to identify the selected data from disabled field.

<"select class="form-control input-sm mandatory ng-untouched ng-pristine"name="Exchange" id="topupExchange0" disabled=""">  
Select <"/option">  
        <!--template bindings={}-->  
        <"option value="ABC"> ABC<"/option">  
        <"option value="CDE"> CDE<"/option">  

How can I identify the disabled field?

  • 1
    Please edit your question to tell us what you are trying to do with the field? Do you want to focus on it, read the option values or option text? Verify that it is disabled when it should be? Or are you just trying to select it (if so, you should be able to use myElem = findElement(By.Id, "topupExchange0");
    – Kate Paulk
    Commented Mar 8, 2017 at 15:41

1 Answer 1


As per new Edit of question please follow below steps:

  1. Check first there is any iframe or not. (I am believing there is an iframe).So switch to it and get element.

    WebElement iframeElement = driver.findElement(By.id("IF1"));
    //now use the switch command

Refer this link

  1. Your script requirements are based on the disabled element, So write below line to find it.

    List<WebElement> lstOpt =  driver.findElements(By.xpath("//option[@disabled="disabled"]"));

Extra notes

  • First get list of select which have disabled option in attribute.

    List<WebElement> lstEle =  driver.findElements(By.xpath("//select[@id='topupExchange0']"));
  • Then check the condition like follow :

     System.out.println("Disable list is found.");
  • Now you can use as per your requirements like Get options, Print options, ignore it, stop execution etc.

Example of get options :

List<WebElement> lstOpt =  driver.findElements(By.xpath("//select[@id='topupExchange0']/option"));

Note : Answer is in Java

Please let me know If any query.

  • It didn't works for me. Commented Mar 9, 2017 at 10:28
  • Can you please send the exception ?
    – Sagar007
    Commented Mar 9, 2017 at 10:30
  • Another requirement is for disabled text box . <"input class="form-control ng-untouched ng-pristine ng-valid mat-input-element" mdinput="" type="text" maxlength="15" id="schemeCode" placeholder="Code" aria-describedby="""> Commented Mar 9, 2017 at 10:35
  • i'm not stack trace developer. Enclosed screenshot for your reference. Can you give the code as per the HTML tag. Would be helpful for me. Thanks in Advance. Commented Mar 9, 2017 at 10:38
  • Answer is updated. Please check.
    – Sagar007
    Commented Mar 9, 2017 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.