Ask a Question

Unable to find Object via winform custom controls

seafalcon
Contributor

Unable to find Object via winform custom controls


TestComplete Version 7.50

IE Version 8

OS Windows 7

Test language C# Script




This issues happened in my GridControl objects which will dynamically generate sub items such as LookUpEdit and DateEditCalendar.




/*******Test Scripts*********************************/












function Test1()

{

  var  powerTax_Main;

  var  gridControl;

  var  gridControl2;

  var  textEdit;

  var gridControl3;//

  powerTax_Main = Aliases["PowerTax_Main"];

  gridControl = powerTax_Main["MainForm"]["MdiClient"]["WindowForm"]["AirlineView"]["AirlineWorkspace"]["AirlineGridWorkPage"]["AirlineGridWorkSpace"]["MetaViewer"]["rootTable"]["Content"]["ListFields"]["List"];

  gridControl["ClickNewRowCellXY"]("Benefit Type", 49, 10);

  gridControl["ClickNewRowCellXY"]("Benefit Type", 55, 10);

  gridControl2 = powerTax_Main["PopupGridLookUpEditForm"]["GridControl"];

  gridControl2["ClickCellXY"](0, "Code", 47, 8);

  gridControl["ClickNewRowCellXY"]("Employee ID", 103, 13);

  gridControl["Keys"]("1");

  gridControl["ButtonEdit1"]["TextBoxMaskBox"]["Keys"]("[Tab]");

  gridControl["DblClickNewRowCellXY"]("Description", 21, 12);

  textEdit = gridControl["TextEdit4"];

  textEdit["wText"] = "dfdfdfds";

  gridControl["ClickNewRowCellXY"]("Date Provided", 43, 12);

  gridControl["ClickNewRowCellXY"]("Date Provided", 49, 10);

  powerTax_Main["MyPopupDateEditForm"]["DateEditCalendar"]["Click"](92, 51);

  

  gridControl["ClickNewRowCellXY"]("Gross up rate", 30, 12);

  gridControl["ClickNewRowCellXY"]("Gross up rate", 38, 11);

  

  gridControl2["ClickCellXY"](2, "Description", 24, 7);//this line failed because gridControl2 no longer exist 

  

  

  gridControl["ClickNewRowCellXY"]("Lowest Fare To Public", 42, 10);

  gridControl["ClickNewRowCellXY"]("Lowest Fare To Public", 42, 10);

  textEdit["wText"] = "3330";

  textEdit["TextBoxMaskBox"]["Keys"]("[Tab]");

  gridControl["Click"](966, 162);

}







How should I do to make TC recognize the correct object?




Thanks




Find the faith in life
5 REPLIES 5
syedsafvan
Contributor

RE: Unable to find Object via winform custom controls

Philip,



I believe in this kind of scenarios, the pop up grid is rendered dynamically as a result of  some action like editing a particular cell. In such cases I would suggest you to use name mappping to map the second grid with generic properties so that the grid id identification is not connected to a particular instance (Record time in your case). This way TC should be able to identify the second grid.




Thankyou

Syed Ahmed Safvan

seafalcon
Contributor

RE: Unable to find Object via winform custom controls

Ye, I read the manual there are 3 ways to work around this.
1 name mapping




2 using findChild() or findId()




3 Enumberate the object.




May I have some specific examples?




Thanks

Find the faith in life
seafalcon
Contributor

RE: Unable to find Object via winform custom controls

for the three methods, I need some clarification.

1 name mapping

What should testers do if they are testing a application which generates all objects dynamically?

I give you an example:



**************test scripts************************************

1  powerTax_Main = Aliases["PowerTax_Main"];

 2 gridControl = powerTax_Main["MainForm"]["MdiClient"]["WindowForm"]["AirlineView"]["AirlineWorkspace"]["AirlineGridWorkPage"]["AirlineGridWorkSpace"]["MetaViewer"]["rootTable"]["Content"]["ListFields"]["List"];

  3 gridControl["ClickNewRowCellXY"]("Benefit Type", 49, 10);

 4 gridControl["ClickNewRowCellXY"]("Benefit Type", 55, 10);

 5 gridControl2 = powerTax_Main["PopupGridLookUpEditForm"]["GridControl"];

  6 gridControl2["ClickCellXY"](0, "Code", 47, 8);



when I replay the testscript I recorded minutes ago, some of the objects in the test scripts are no longer exists. but some of them still remain in the memory, and my application will give the newly generated objects new name. Then how can I achieve the name mapping in test scripts?



2 Using find, findChild or findID.

findChild will be the last thing I want to do because I have to do many program to make it work, and I am not sure whether my program can really tame this method.. using findID,  what if there is no ID for my custom controls?







3 Enumeration... Gosh. that' the pain in the AXX.. I have to do enumeration everytime when TC can't identify an object?what if I have more than 50 objects TC can't identify.. Do I need to do enumeration everytime? If i do that, i prefer to use manual testing because probably I could save more time....







Find the faith in life
seafalcon
Contributor

RE: Unable to find Object via winform custom controls

Basically, we r using a GradControl contains many subitem objects such as lookupedit, calendaredit, textedit. unfortunately, there is no static windowscaption, or name defined by developers. all these properties are dynmaic changin during the runtime...



i had a lot of trouble in object recongition. i tried to use name mapping, or obj.refresh()..obj.refreshnamemappinginfo()..

all failed..



what should i do now?



another question is : can i add new name mapping definition into the exising name mapping list?



Thanks
Find the faith in life

RE: Unable to find Object via winform custom controls

Hi Philip,


As far as I understand, you are using Developer Express grid controls. We created a similar application which uses two lookup controls and reproduced the problem on our side. The problem is that there are two lookup grid controls on the same level of objects hierarchy, and therefore, TestComplete is using an index to identify them. However, the grid control which was activated last gets index 1 assigned due to the controls' implementation. Therefore, the new lookup grid is identified as the old one. Here is the script which demonstrates how you can avoid the problem:


function Test5()

{

  var  TestApp;

  var  gridControl;

  var  gridControl2;

  TestApp = Aliases.TestApp;

  gridControl = TestApp.MainForm.xtraTabControl.XtraTabPage.AddRemoveModifyMapContents.gridMapContents;

  gridControl.ClickCellXY(0, "ArticleType", 104, 13);

  TestApp.PopupGridLookUpEditForm.RefreshMappingInfo(); // IMPORTANT

  gridControl2 = TestApp.PopupGridLookUpEditForm.GridControl;

  gridControl2.ClickCellXY(1, "Type Name", 67, 6); 

  gridControl.ClickCellXY(0, "Product", 59, 11); 

  TestApp.PopupGridLookUpEditForm.RefreshMappingInfo(); // IMPORTANT

  gridControl2.ClickCellXY(0, "Product Name", 69, 10);

}


Note that you need to call the RefreshMappingInfo method before retrieving each of the lookup grid controls - this will make TestComplete refresh the reference.



Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: