Diceman
8 years agoOccasional Contributor
Page not found leads to "Object Required" Error. How to execute alternative steps instead?
Given the following code, I am able to open Internet Explorer to "about:blank" and the script, when run, will log a 1. However, if I change the page to an alternative page, the function crashes. ...
- 8 years ago
The problem is TestComplete looks for the exist property of Page("about:blank") it's there so you get log 1
But when TC looks for exist property of Page("alternative page") , it is looking a property in non existant object. so it crash.
To avode that you can use "WaitAliasChild" Method this will waite for defined time and then
If the specified object does not exist, the method returns a stub object with "exist =False"
you can arrange your function like below
function Test(){ if(Sys.Browser("iexplore").WaitAliasChild("alternative page", 10000).Exists ) { Log.Message("1"); } else{ Log.Message("2"); } }
However you may have to map the "alternative page" in name mappings.
If calling URL you can use TestObj.WaitPage(URL, Timeout) method.