Forum Discussion
tristaanogre
Esteemed Contributor
Right... because you're calling code in your IF clause for an object that might not exist yet. Your "Exists" check should happen first, before anything else, as anything else will fail if the object does not exist.
let navigate = Aliases.browser.page.nav let navbar = Aliases.browser.page.header if (navigate.WaitAliasChild('carrier', 5000).Exists){ if (navigate.WaitAliasChild('carrier', 5000).Width != 0) { Log.Message("carrier exists"); } else { Log.Message("carrier "); } }
AlexKaras
5 years agoChampion Level 3
Hi,
> if (!navigate.WaitAliasChild('carrier', 5000).Width == 0 || navigate.WaitAliasChild('carrier', 5000).Exists)
> because you're calling code in your IF clause for an object that might not exist yet.
If you don't like nested conditions, you may use the fact that JScript uses short circuit conditionals. The code in this case may look like this:
if ((navigate.WaitAliasChild('carrier', 5000).Exists) && (navigate.carrier.Width > 0))
// sucess
else
// failure
Related Content
- 7 months agoMehwishDaud
- 5 years agokate123
- 9 months agolodecesa
Recent Discussions
- 5 hours agojstaehlin
- 22 hours agoAivanitskiy