I have a situation where I need an element to be clicked, however, if that element is not shown on the page, I want the script to continue without an error. (Usually getting an error because the script cannot find the IE element).
What type of If statement do I need to use, can someone assist me with this? Please show me with the below example.
Example:
// Change "O" to H to extract inner html, T for just text. O is outer html - i.e. everything. Matches returned in valueArray
IEGetTagsByAttrib>{"https://www.google.ca/#spf=157237097133 ... valueArray
Best way to avoid an error if an Internet Explorer Element is not found
Moderators: JRL, Dorian (MJT support)
-
- Junior Coder
- Posts: 20
- Joined: Wed Jul 31, 2019 9:38 am
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Best way to avoid an error if an Internet Explorer Element is not found
I just responded to this question via your support ticket, as your question there contained more specifics.
Re: Best way to avoid an error if an Internet Explorer Element is not found
@Dorian,
Oh, sure, Dorian, just keep it a secret, why don't you.
PepsiHog
Oh, sure, Dorian, just keep it a secret, why don't you.

PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
-
- Newbie
- Posts: 19
- Joined: Mon Oct 14, 2019 6:23 am
Re: Best way to avoid an error if an Internet Explorer Element is not found
I use the following in some of my scripts:
That one is fairly simple, it looks for a certain tag on the initial login page.
For that particular example there's no recovery (apart from the loop to retry every second or so) but depending on the situation you could tell it to refresh the page and try again, or look for other tags.
I guess the most important thing is Let>IGNOREERRORS=1 to prevent the popup error message for end users.
Code: Select all
//Login loop
Let>PageReadyCounter=0
Label>CheckPageReady
Let>IGNOREERRORS=1
IEGetTagsByAttrib>{"https://URL"},A,innertext=Log in,T,PageReadyRes
Let>IGNOREERRORS=0
IfNot>PageReadyRes_1={"Log in"}
Wait>0.5
Let>PageReadyCounter=PageReadyCounter+1
If>PageReadyCounter>120
MDL>Login page was not loaded - shutting down.
Goto>ShutDown
EndIf>
Goto>CheckPageReady
EndIf>
For that particular example there's no recovery (apart from the loop to retry every second or so) but depending on the situation you could tell it to refresh the page and try again, or look for other tags.
I guess the most important thing is Let>IGNOREERRORS=1 to prevent the popup error message for end users.