Ask a Question

TestComplete cannot find objects during execution of recorded web tests

szein
Occasional Contributor

TestComplete cannot find objects during execution of recorded web tests

hello,

Currently we are using testcomplete to do functional testing for our ASP.NET, database dirven application. i record the test using "record script" option, and it works fine with me. However, sometimes when i run the test, i get the error that testcomplete cannot find certain object (element)!! and when i re-run the same test, it finds it (sometimes). i don't know why this happens, when i make recording , it goes very well, but later on, when i run the test, it does not find objects(object does not exist), even though it is there.



i tried looking in the help, but i got lost with the so many options. i donno from where to start!



Thanks

Sam
2 REPLIES 2

Hi Sam,


The most probable reason for the behavior is that your Name Mapping scheme uses unreliable properties for object identification. So, check whether the mapping criteria are sufficient to recognize the problematic objects and modify the mapping criteria if they are not. If this suggestion does not help, follow the steps below:


1. Insert the following routine call in your test before retrieving the problematic object (change the process name):




LogAppStructure(Sys.Process("MyProcessName"))


Here is the LogAppStructure routine code:




' VBScript


Sub LogAppStructure(obj)

  Err.Clear

  On Error Resume Next


  Dim count, i, Str

 

  ReDim params(7)

  params(0) = "WndClass"

  params(1) = "WndCaption"

  params(2) = "Index"

  params(3) = "Visible"

  params(4) = "Exists"

  params(5) = "ClrFullClassName"

  params(6) = "ProductName"

  params(7) = "ProductVersion" 

 

  Str = ""

  For i = 0 To UBound(params)

    If IsSupported(obj, params(i)) Then

      Str = Str & params(i) & " = " & VarToStr(Eval("obj." & params(i))) & VbCrLf

    End If

  Next

 

  Call Log.AppendFolder(obj.Name, Str)

  For i = 0 To obj.ChildCount - 1

    Call LogAppStructure(obj.Child(i))

  Next

  Log.PopLogFolder


  On Error GoTo 0

End Sub




// JScript, C#Script


function LogAppStructure(obj)

{

  var count, i, Str;

 

  var params = new Array();

  params.push("WndClass");

  params.push("WndCaption");

  params.push("Index");

  params.push("VisibleOnScreen");

  params.push("Exists");

  params.push("Visible");

  params.push("FullName");

  params.push("ClrFullClassName");

 

  Str = "";

  for (var i = 0; i < params.length; i++) {

    if (IsSupported(obj, params))

      Str += params + " = " + VarToStr(eval("obj." + params)) + "\r\n";

  }

 

  Log.AppendFolder(obj.Name, Str);

  for (var i = 0; i < obj.ChildCount; i++) {

    LogAppStructure(obj.Child(i));

  }

  Log.PopLogFolder();

}


2. Execute your test and reproduce the "Object not found" problem. The LogAppStructure function will post the entire structure of the tested application to the test log, and you will be able to see how objects are recognized right before the problem occurs.

3. If you fail to find the cause of the problem by using the test log, zip your entire TestComplete project suite folder along with the log of the test execution and send me the archive via our Contact Support form (http://www.automatedqa.com/support/message). Make sure that messages in your log correspond to correct actions in the latest version of your test.


Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
brudnick
Occasional Contributor

Hey,

If you are starting the test application via application defined in "TestedApps", be sure to add "TestedApps.CloseAll()" at the bottom of each script.  This solved a lot of my problems with not finding objects.



Barb
cancel
Showing results for 
Search instead for 
Did you mean: