Forum Discussion
Hi,
> var b = context.get("genAlertForm");
a) The recommended way in TestComplete is to use its functionality to search for the objects rather then use internal page methods. (Guessing that you have either some Selenium background or page development experience)
b) TestComplete provides a set of .FindXXX() methods that try to find an object but do not report a problem if the object was not found. Check TestComplete help for more details about .WaitXXX() methods.
Assuming that genAlertForm is an identifier of the form, the code may be like this (untested sample with guessed parameters):
var b = <testedPage>.WaitPanel("genAlertForm", 500); // check for 0.5 sec if alert panel was displayed
if (b.Exists)
b.Button("OK").Close(); // click OK button
...
Two other notes about your code:
1) eval() function evaluates the code presented as a string. But I think that context.get("genAlertForm") already returns some web element, but not the string. Correct usage must be like var b = eval('context.get("genAlertForm");');
2) b.Button(ActionName); will not click a button (assuming that Button() is not a native method of the b object). The code should be like: b.Button("OK").Click();