简体   繁体   中英

SilkTest workbench Invalid Object Handle Exception?

I'm trying silktest for the first time with an in house application. In one of the windows, I have a button that has two menu lists :

New (pushbutton) ---> Option1 (list menu ) + Option2
if option1 clicked ---> subOption1, subOption2?

All these options are specific to the current scenario and user.

When recording, silktest detects the "New" pushbutton but when playing back, it throws an error : the handle of the object is invalidated.

One of the possible solutions is to instantiate Object something like this:

dim button as New Pushbutton  

but it throws an error: SilkTest.ntf.Pushbutton.Friend sub New (handle as silk test.ntf.ObjectHandle) is not accessible in this context because it is 'Friend'

Can someone help? Any suggestions??

Try to ensure the focus is on the button you want to push. If using silk4j, try to setFocus() on this element or even on its parent element firstly.

The "Invalid Object Handle Exception" is thrown when you try to work with an object that is no longer valid, consider for example a dialog that is closed, and afterwards you try to do something with it, it will no longer work. Sometimes the scenario is not so obvious, but the underlying principle is the same.

Also, don't construct PushButtons, get them using the find method, this will make sure that they contain a valid object handle.

Dim myButton As PushButton = myDialog.Find("//PushButton[@caption='New']")
myButton.Select()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM