Forum Discussion

sth2226's avatar
12 years ago

Code to not accessiable or greyed out text/edit field

I have a problem where text field in the application is not accesable or it is greyed out. How to verify weather the field is greyed out or not using jscript code

1 Reply

  • marin's avatar
    marin
    Frequent Contributor
    Hello Sathya,



    you will need to locate the element and then inspect where to look for the attribute.



    In my test cases I often have disabled text boxes and I use either 

    a) its container (div) to look for its class name -> as it often has a special recognizable class applied to it

    or

    b) look for text box itself and evaluate its attribute readOnly (which is "true" in case box is grayed out)



    Example code would look something like this:





    //search text box container, use developer tools like Firebug to locate the div in the hierarchy if applicable

    var myDivWithTextBox = myPage.NativeWebObject.Find("ObjectIdentifier", "myDivWithTextBox");

    if(myDivWithTextBox.className == "myReadOnlyClass")

      doThis();

    else

      doThat();





    //search box itself

    var myTxtBox = myPage.NativeWebObject.Find("ObjectIdentifier", "myTxtBoxName");

    if(myTxtBox.readOnly)

      doThis();

    else

      doThat();







    Hope this helps,



    Marin