Forum Discussion

MarinaB's avatar
MarinaB
Occasional Contributor
7 years ago

check fields visiblility

Can I make automation test that will verify do all fields exist (or not exist) at the form? And if I can how can I do that? Like example at the Form 20 fields exist. With the new version a new filed is added at the Form or example with the new version one field is not visible. What automated test can do?

3 Replies

  • SanderK's avatar
    SanderK
    Occasional Contributor

    This should get you on your way:

    https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/checking-existence.html

     

    Using the methods described there you could check whether said 20 fields exist on your form. To see if there are additional fields you could search for all fields of a certain type and see how many are returned. Keep in mind that a field can exist while being invisible. Therefore, it is wise to check the "Visible" or "VisibleOnScreen" property of each existing field.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    TestComplete provides a set of .WaitXXX() methods (e.g. .WaitChild, .WaitAllChildren, WaitForm, etc.) that are recommended to be used to look for the objects when the sought for object may or may not exist.

    .Visible and .VisibleOnScreen properties can be used to check if the given object is visible on screen.

     

    Exact answer to your question significantly depends on the implementation of the tested application.

    For example, if you are lucky and all fields at the form are named with, say, 'fld_' prefix, then you may search for all objects that start with that prefix, iterate through the returned objects list, check if the object is visible, compare the returned objects list with the previously saved 'master' one and report differences if any.

    If you are not lucky and developers assigned random names to the fields, than you may search for the fields one by one. Obviously in this case it will be not possible to detect if the new field is added. You may use image comparison to detect new fields, but this is error prone way.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Keep in mind that "Exists" could return true even if the item is not visible on screen.  In several of the Web Applications we're testing, there are certain modals that are present on the page but are marked not visible.  So, "Exists" would return true but "Visible" would not.