Ask a Question

Identify current form for script use

SOLVED
ZXQA
Occasional Contributor

Identify current form for script use

Hello,

   I am trying to write a reusable script with a data loop in TestComplete 12, VB Script.

Is there a way for me to identify the current active form? I have searched extensively and found nothing.

 

My script interacts with a data grid and enters a file determined number of items and is quite simple but I would like to use this identification feature in other scripts as well. The grid is on the same location of every form but the form name changes example below: 

1.  Sys.Process("Signon").WinFormsObject("frmPSSales").WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")

2. Sys.Process("Signon").WinFormsObject("frmPSOrders").WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")

 

I would like to capture the current "Sys.Process("Signon").WinFormsObject("********")." of the current form so it does not have to passed in to the function.

 

An example of what im doing is below:

 

Sub HMMMM()
frm = ""
frm = "This would be the retrieved form fullname or mapped name"
Call Project.Variables.itemNum.Reset
While Not Project.Variables.itemNum.IsEOF
'Enters the text Project.Variables.itemNum("ItemNumber") in the 'txtBase' text editor.
Call frm.UcGetItemA1.panBase.txtBase.SetText(Project.Variables.itemNum.Value("ItemNumber"))
'Enters '[Enter]' in the 'txtBase' object.
Call frm.UcGetItemA1.panBase.txtBase.Keys("[Enter]")
'Enters '[Enter]' in the 'SPTextBox' object.
Call frm.SPTextBox.Keys("[Enter]")
Call Project.Variables.itemNum.Next
WEnd
End Sub

 

Any help is greatly appreciated.

5 REPLIES 5
Marsha_R
Community Hero

This may be of some help

https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitem/index.htm...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

Use find for the object which keeps changing
For example for your script try with the below line it should work or else just find correct the name property name correctly with Asterik on the changing field : 
Sys.Process("Signon").Find('Name','WinFormsObject("frm*")',1).WinFormsObject("RightFillPan").WinFormsObject("clientPanel").WinFormsObject("SpDataGrid1")

sonya_m
SmartBear Alumni (Retired)

Thank you for helping everyone!

 

@ZXQA does this help? Please let us know how you solved the issue.


Sonya Mihaljova
Community and Education Specialist

sonya_m
SmartBear Alumni (Retired)

@ZXQA Could you take a look at this help topic and let me know if this helps? 

 

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/desktop/activewindow-...

 


Sonya Mihaljova
Community and Education Specialist

ZXQA
Occasional Contributor

Thank you Sonya! I will review it and see if it is what i am after as soon as I am back at work. Thank you again.

cancel
Showing results for 
Search instead for 
Did you mean: