Forum Discussion

MulgraveTester's avatar
MulgraveTester
Frequent Contributor
15 years ago

Detecting Read Only fields

My app has fields that cannot be edited but have the following properties

WndClass = Edit

Enabled = True

Visible = True

Exists = True

Focused = True

VisibleOnScreen = True



How do I detect that they cannot be edited?



If I try to do myField.setText("Some Text") then I get the error "Failed to enter text in the edit box, since it is read-only"

Somehow TC knows that the field is read-only but I cannot find a property of the field that I can use to identify this in code.



This field does not have a ReadOnly property. If I try

'VBScript

IF myField.ReadOnly then

    log.message("Field is Read Only")

END IF

then I get the error "Unable to find the object ReadOnly."



Please tell me how to identify that the field is read-only.

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Without knowing more about your application or the specific component you are using, I cannot say specifically how to tell if something is read-only.



    Have you queried your developers?  They should be able to tell you what property on your component determines whether it is read only.



    Using the Delphi open application plug-in and the delphi-compiled copy of the Orders sample program that gets installed with TestComplete, there is a ReadOnly property on TEdit components in that application.  I'm fairly certain that other applications, development environments/languages, etc, have similar properties.  It's a matter of knowing what type of application it is and what type of component.

  • Hi Michael,





    To check whether the Edit control is read-only, verify its ReadOnly property (the RTTI group in the Object Browser).


  • MulgraveTester's avatar
    MulgraveTester
    Frequent Contributor
    Thanks Robert. The developer was my first port of call with this issue.



    Thanks Allen, but the field does not have a ReadOnly property as I get the error that I originally posted.



    Is there any chance that the object spy does not show all of the properties associated with a control? It seems logical that an edit box should have a ReadOnly property.
  • MulgraveTester's avatar
    MulgraveTester
    Frequent Contributor
    A colleague solved this for me using WndStyles.



    if (myField.WndStyles AND ES_READONLY) = ES_READONLY then

        log.message("Field is read only")

    end if



    Thanks Matt