Forum Discussion

Petewilson's avatar
Petewilson
Contributor
6 years ago
Solved

Test Complete: Undeclared identifier: Name error in ddt loop but never in first loop

I am fairly new to Test Complete so please bear with me in my explaination and let me know if i need to provide any more detail to help resolve.

 

I have a scipt that enters a web page controls input fields from a data table. Currently there are 6 rows, so i have 6 interations or counts in the 'Project Run' and it successfully is looping through the rows to populate.

 

The odd thing is that i have a function in my code that searches to make sure the input field is relevant for that screen and that appears to fail on one of the rows of data in the table wuith the error, Undeclared identifier: Name.

 

It is odd as it gets through the entirety of the first loop at least, and it calls that function around 60 times, with no issues. It might not be until the 4th loop it happens but if i reorder the data table so that the 4th row is now at the beginning, it runs fine and the 3rd loop will fail.

 

It is always the first run of that function in whichever loop it fails in.

 

Just confused why it would suddenly think that is an undeclared indentifer after being run successfully 60+ times and if i tell it to carry on, it runs it for the remainder of the script no issues.

 

 

function FindControlByName(ParentWindow: OleVariant; ControlName: String): OleVariant;
var
  I: Integer;
  ControlNameChild : OleVariant;
begin
  Result:=nil;
  for I:=0 to ParentWindow.ChildCount-1 do
  begin
    ControlNameChild := 'VCLObject(''' + ControlName + ''')';
    if ParentWindow.Child[I].Name = ControlNameChild then
    begin
      if ParentWindow.Child[I].VisibleOnScreen = True then
      Result := ParentWindow.Child[I];
    end;
  end;
end;

I think i have proven that the data in the table isn't at fault as if i restructure the rows it is another row that the loop fails on, not the same data or row.

 

I have also changed the order of the scripts in the Project Run screen and it is still the first script that uses that function that has the issue

 

I have tried a Delay in the prior unit script that loads the page to make sure it isn't due to the page not having completed loading.

 

The .Name identifier works for 99% of the time it is called, just that one time it tells me it is undeclared??

 

Should also point out this is written in Delphi

 

Any help, advice and guidance is appreciated

 

Pete

 

 

2 Replies