Forum Discussion
3 Replies
- NisHeraValued Contributor
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.
- DicemanOccasional Contributor
Thanks! That worked!
- tristaanogreEsteemed Contributor
Minor correction, since the code doesn't use Aliases, WaitPage is the better method since you are SPECIFICALLY waiting for a page
But then, to totally turn that into a universal function to use for ANYTHING
function WaitForMyPage(pageUrl){ if(Sys.Browser("iexplore").WaitPage(pageUrl, 1, 10000).Exists ) { Log.Message("1"); } else{ Log.Message("2"); } } function foo(){ WaitForMyPage('http://www.google.com/'); //will log a 1 if the google page is open, 2 if anything else is open }