Forum Discussion

kavansays's avatar
kavansays
Contributor
9 years ago

Using " Set Object" throws Error

Hi All,

 

I am trying to automate Windows based application, already developed 200+ test cases..

 

We are tring to declare variable as object in top of the script as automation practice (just like we use to do it in UFT) ..

 

For eg: 

 

'Declare Public objects
Set objTradeTicket = Aliases.wndTradeDetails
Set objTradeTable = Aliases.javaw.starterMystageIndmsQaApplication.scene.primaryTabPane.tradesTable
Set Yes_Btn = Aliases.javaw.heavyweightdialog1ConfirmClose.scene.buttonbar.buttonYes
Set objProductTab = Aliases.javaw.starterMystageIndmsQaApplication.scene.primaryTabPane.filterByProductTabs

 

 

Here the problem is i am just declaring the variable object on top of the script and these objects will be used in the script later on after few operations, once i execute the code Test complete immidiately throws ERROR(Obj does not exist)..

 

Can anyone please suggest solution on this please?

 

Thanks,

Kavan Shah

 

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Kavan,

     

    Not sure if I correctly understood the problem, but:

    > 'Declare Public objects
    > Set objTradeTicket = Aliases.wndTradeDetails

    This is not declaration, but initialization (assigning a reference to the object that must exist at the moment of assignment).

     

    To declare the variable, use just

    Dim objTradeTicket

     

    When you are assigning a reference to some object, e.g.

    Set Yes_Btn = Aliases.javaw.heavyweightdialog1ConfirmClose.scene​.buttonbar.buttonYes

    all objects mentioned in the assignment (i.e. javaw and heavyweightdialog1ConfirmClose and scene and buttonbar and buttonYes) must exist. Otherwise TestComplete will post the error to the test log that this or that object was not found. This is expected and correct behaviour.

    Use the .Exists property to check if the given object exists at the given moment of time.