Forum Discussion
AndersW
15 years agoOccasional Contributor
Here is an example of how I would get to a certain page on our website:
// ----------------------------------------
// Test for SmartBear
// ----------------------------------------
procedure StartIExplorer;
begin
gLastTab := '';
gLastMenu := '';
MainBrowserProcess := Sys.WaitProcess('iexplore',500);
browserProcess := Sys.WaitProcess('iexplore',500,2);
if browserProcess.exists then begin
if browserProcess.WaitWindow('#32770','*',-1,500).exists then
browserProcess.Window('#32770').Window('Button','Cancel').Click;
MainBrowserProcess.Close;
sleep(1500);
TestedApps.iexplore.Run;
MainBrowserProcess := Sys.WaitProcess('iexplore',500);
browserProcess := Sys.WaitProcess('iexplore',500,2);
end
else
TestedApps.iexplore.Run;
end;
function FindMFObject(ObjectName: OleVariant);
begin
iexplore := Aliases.iexplore;
result := iexplore.pageNetcom.NetcomFrame.FindChild('Name','item(' + ObjectName + ')',60);
end;
procedure ActWebObj(ObjName: string);
var
WebObj: OleVariant;
begin
WebObj := FindMFObject(ObjName);
WebObj.Keys('[Enter]');
end;
procedure NavPage(TabName, MenuName: string);
begin
browserProcess := Sys.Process('iexplore');
MainFrame := Aliases.iexplore.pageNetcom.NetcomFrame;
if not (gLastTab = TabName) then begin
ActWebObj(TabName);
gLastTab := TabName;
end;
MainPageFrame := MainFrame.page.Frame;
if not (gLastMenu = MenuName) then begin
if not (MenuName = '') then begin
ActWebObj(MenuName);
gLastMenu := MenuName;
end;
end;
end;
procedure OpenWebPageTest;
begin
StartIExplorer;
NavPage(pgConfigDev,pgAppControl);
end;
// ----------------------------------------------------------
Basically what I do, is open my Browser to the web page we want, then I activate first the Menu item (in the banner). Then the left panel is loaded (this can take a second or two sometimes), and while that is loading TC7 would wait with the next part of the NavPage procedure until it was loaded. Then it would find and activate the Tab item from the Left Panel. Then the Main frame would load, and again it would wait with further execution (now past the NavPage procedure).
v8.00 doesn't wait. It just continues the script, and as it can't find my objects, then the test fails, and I am not sure why it doesn't wait like v7 does.
// ----------------------------------------
// Test for SmartBear
// ----------------------------------------
procedure StartIExplorer;
begin
gLastTab := '';
gLastMenu := '';
MainBrowserProcess := Sys.WaitProcess('iexplore',500);
browserProcess := Sys.WaitProcess('iexplore',500,2);
if browserProcess.exists then begin
if browserProcess.WaitWindow('#32770','*',-1,500).exists then
browserProcess.Window('#32770').Window('Button','Cancel').Click;
MainBrowserProcess.Close;
sleep(1500);
TestedApps.iexplore.Run;
MainBrowserProcess := Sys.WaitProcess('iexplore',500);
browserProcess := Sys.WaitProcess('iexplore',500,2);
end
else
TestedApps.iexplore.Run;
end;
function FindMFObject(ObjectName: OleVariant);
begin
iexplore := Aliases.iexplore;
result := iexplore.pageNetcom.NetcomFrame.FindChild('Name','item(' + ObjectName + ')',60);
end;
procedure ActWebObj(ObjName: string);
var
WebObj: OleVariant;
begin
WebObj := FindMFObject(ObjName);
WebObj.Keys('[Enter]');
end;
procedure NavPage(TabName, MenuName: string);
begin
browserProcess := Sys.Process('iexplore');
MainFrame := Aliases.iexplore.pageNetcom.NetcomFrame;
if not (gLastTab = TabName) then begin
ActWebObj(TabName);
gLastTab := TabName;
end;
MainPageFrame := MainFrame.page.Frame;
if not (gLastMenu = MenuName) then begin
if not (MenuName = '') then begin
ActWebObj(MenuName);
gLastMenu := MenuName;
end;
end;
end;
procedure OpenWebPageTest;
begin
StartIExplorer;
NavPage(pgConfigDev,pgAppControl);
end;
// ----------------------------------------------------------
Basically what I do, is open my Browser to the web page we want, then I activate first the Menu item (in the banner). Then the left panel is loaded (this can take a second or two sometimes), and while that is loading TC7 would wait with the next part of the NavPage procedure until it was loaded. Then it would find and activate the Tab item from the Left Panel. Then the Main frame would load, and again it would wait with further execution (now past the NavPage procedure).
v8.00 doesn't wait. It just continues the script, and as it can't find my objects, then the test fails, and I am not sure why it doesn't wait like v7 does.