cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping error

Highlighted
Contributor

Mapping error

One of the screen I'm testing contains two edit fields. I cannot use the text in the field as property to identify the field. I did try to use other properties (Index or Top). When I use "Highlight on Screen" (from the name mapping tree) the right field is highlighted. However when I try to run a test script using this mapping the program uses the same field for both mappings.



Is this a known problem. Is a work-around available?
3 REPLIES 3
Contributor

RE: Mapping error

Herman,



Its weird that you are able to high lite the object through namemappping but the script dose not point to the right object.Could you post the code frag please?



Meanwhile for work around try "FindChild" method to dynamically find the object in the process tree.



PropertiesArray = Array(Prop1, Prop2)

ValuesArray = Array(Value1, Value2)

Obj = ParentObject.FindChild(PropertiesArray, ValuesArray, 999) 



Thank you

Syed
Syed Ahmed Safvan

Highlighted
Occasional Contributor

RE: Mapping error

I have had issues in the past in which the "highlight on screen" was working but then when the actual engine was running it either failed or got confused between similar objects (in fact one such issue is still investigated by support).



That said, from my experinece it is usually a mapping configuration error.



Is the object "open" to test complete? If so why not use it's name and/or class?
Highlighted
Staff

RE: Mapping error

Hi Herman,



I agree with Ory: it looks like the problem is caused by unreliable properties in your Name Mapping scheme. Try using more reliable properties to identify the problematic objects and avoid using indexes as the indexes can change during your script execution. If other recognition criteria are absolutely unreliable, I recommend that you use the Left and Top properties to identify the objects by their coordinates. 



If this approach does not help you either, the only thing which remains is to identify the needed object by other objects located near the object. However, note that identifying an object by another object located near this object is a task which will require some scripting. You can implement a script similar to the following script (the script finds an object of the specified class located to the right of a label with the specific text on a specific panel):



[JScript]



function getControl(pnlParent, lblText, classNameSubstr)

{

// Find the label

var lbl = pnlParent.FindChild("wText", lblText, 20000); // If the wText property does not work, try using the Text property or any other property which contains the label's text



// Find the control located to the right of the label



// Set the starting X-coordinate point in the coordinates of the parent panel

var x = lbl.Left + lbl.Width;

var control = null;



for (var i = 0; i < 100; i++)

{

// Move to the right for 5 pixels 

x += 5;



// Get the object located in the current position

var curObj = Sys.Desktop.ObjectFromPoint(x, lbl.Top + lbl.Height / 2)



// Check whether the current object is a text box

if (curObj.ClrClassName.indexOf(classNameSubstr) > -1)

{ // The current object is the needed text box

control = curObj;

break;

}

}



return control;

}



function test()

{

// TODO: Assign the container object to the pnlGeneral variable



// The text of the label located to the left of the needed control

var labelText = "My Value:";  

// A class name substring which identifies the control as the needed text edit control (modify the substring if this is necessary) 

var controlClass = "TextEdit" 



// Try to get the control located to the right of the label with the specified text

var txtMyValue = getControl(pnlGeneral, labelText, controlClass);



if (txtMyValue != null)

{

Log.Message("Object found successfully. See Remarks for more information.", "FullName: " + txtMyValue.FullName);

}

else

{

Log.Error("An object with the '" + controlClass + "' class name located near the '" + labelText + "' label was not found.");

}

}



------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors