Micro Focus QTP (UFT) Forums
Creating Objects Dynamically - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Creating Objects Dynamically (/Thread-Creating-Objects-Dynamically)



Creating Objects Dynamically - Gentoolicious - 07-23-2008

One of my tests is designed to create a user and then check to make sure the user actually exists.

When a user wants to log in they are displayed a list of buttons that have the account name and account picture displayed (imagine logging into Windows XP) where the account name is the name of the button.

My script does something like this:

Code:
Dim accountName
Randomize
accountName = DataTable("accountName", dtGlobalSheet) & int((99999*rnd)+1)


'Process to Register Account
WpfWindow("WindowName").WpfEdit("UserName").Set accountName

<snip>

'Process to Login
if WpfWindow("Window Name").WpfButton(accountName).Exists Then
  MsgBox("Test Succeded.")
Else
  MsgBox("Test Failed.")
Endif

So as you can see, the accountName variable is generated somewhat randomly and, at the end of the script, the variable accountName is just substituted for the button name.

The code works. The problem is that QTP checks to see of WpfButton(accountName) exists in the object repository. As the button did not exist before the start of the test, it will not exist in the object repository and QTP throws an error message causing all my tests to report as failed (when they're not failing).

Can anyone tell me if their is some way to dynamically create an object and then add it to the repository while a script is running?


RE: Creating Objects Dynamically - stevol - 07-24-2008

Hi,
you must use descriptive programming, without using object repository.
With object spy you discover unique properties of WpfButton and you arrive to write something similar to:

Code:
If WpfWindow("Window Name").WpfButton("property_xyz:=xyz").Exist ...



RE: Creating Objects Dynamically - Johny Kluge - 08-18-2008

Hi,

I have got little bit another problem:
My script fills in the form on Terminal Emulator window. Before this window appears, unique ID is generated and displayed in the header of the form. I can capture this ID and store it into Output Value.
I need to check the Sybase DB if there is a new record added with such a new ID (after submitting the terminal form).
I was trying to insert a DB check, but it only works with static data.

I need to execute a select from table and check wheter new ID is present in the DB table.

Is it neccessary to configure the Object Repository? How?
Any help/link/comment would be very welcome!


Thank you
J.


RE: Creating Objects Dynamically - raghava82 - 08-18-2008

Hi Gentoolicious !

This is Raghava, I have not clearly understand ur problem, but i give the on suggetion to u, after recording you can change the name of that filed into Regular Experiession then while running the Test it will not take care about the particular Name, so i hope that i will not through any error.
Once Try this method.