Forum Discussion

salley's avatar
Frequent Contributor
7 years ago

.exists method

i've a form that has about 100 items and they appear based on some Class, and items could sometimes 50/60 depends on the class code, i want to select if item exists , if not move to next and do the same, i just don't want my script to fail if object not found. is it possible to do it through if then else statement, i'm just not sure what to put in else statement, ex:

if value1.exists then

if value2.exits then

and so on


End if

End if 

if value 2 not found then my test is failing,,i'm new to this ,,, can somebody help me , i just don't want my test to fail. 


4 Replies

  • tristaanogre's avatar
    Esteemed Contributor

    You cannot check the "Exists" property of an object that does not exist...  If you think about it, this makes logical sense.


    The best way to check for object existence is to use some variation of a WaitNNN method to retrieve the object first and then check for existance.


    So, your code would be something on the lines of


    value1 = parentObject.WaitAliasChild('objectName', -1);

    if value1.exists then

    value2 = parentObject.WaitAliasChild('objectName', -1);

    if value2.exists then


    Or some such pattern.

    • salley's avatar
      Frequent Contributor

      Thanks, got it. 

      another query if i have the below code and i don't want my test to fail, i just want to click whatever option i've available on the screen and move on, how do i do that ,,,,,,,,,,

      sTable.Cell(1, 1).Table("conForm_ABCD01").Cell(0, 1).RadioButton("conForm_ABCD01_1").Click
      sTable.Cell(2, 1).Table("conForm_ABCD02").Cell(0, 1).RadioButton("conForm_ABCD02_1").Click
      sTable.Cell(3, 1).Table("conForm_ABCD03").Cell(0, 1).RadioButton("conForm_ABCD03_1").Click
      sTable.Cell(4, 1).Table("conForm_ABCD04").Cell(0, 1).RadioButton("conForm_ABCD04_1").Click
      sTable.Cell(5, 1).Table("conForm_ABCD05").Cell(0, 1).RadioButton("conForm_ABCD05_1").Click
      sTable.Cell(6, 1).Table("conForm_WORK06").Cell(0, 1).RadioButton("conForm_ABCD06_1").Click
      sTable.Cell(7, 1).Table("conForm_ABCD06").Cell(0, 1).RadioButton("conForm_ABCD00_1").Click


      lets say i've the above script, but i don't have all the items available on the screen, i just want to click whatever items are available,, Thanks in advance,,,