Conditional Statements in iMacros sidebar for IE

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Conditional Statements in iMacros sidebar for IE

by sgibbs77 on Thu Sep 28, 2017 6:01 am

I don't know if the is the proper location to post this, but I have a macro that runs through a set of various links and downloads data to my computer from a website. However, there are times when some of the links are not there. Right now, to get around this, I have to visually check to see which links are there and comment out the code for the links that are not there. Is there any way, given that I'm using the iMacros sidebar version for IE, to do a check to see if the link is there and skip past it if it is not? Here is a sample of the code below:

TAG POS=1 TYPE=A ATTR=TXT:Commissions
FRAME F=1
TAG POS=1 TYPE=A ATTR=TXT:Postpaid<SP>Activation
TAG POS=1 TYPE=A ATTR=TXT:Smart<SP>Phone<SP>Activation this is the "link" that the macro "clicks" to get that set of data; it may or may not exist at any given time; I need to know how to get around it
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
TAG POS=1 TYPE=SPAN ATTR=TXT:Generate<SP>Export<SP>File
TAG POS=2 TYPE=SPAN ATTR=TXT:Yes
WAIT SECONDS=10
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
ONDOWNLOAD FOLDER=C:\Users\AWC\Dropbox\Commissions\New<sp>Activations FILE=Smartphone<sp>New<sp>Activation<sp>Commission.xlsx WAIT=YES
TAG POS=1 TYPE=SPAN ATTR=TXT:Download<SP>Export<SP>File
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:Postpaid<SP>Activation<SP>Summary if the first link does not exist; it would need to skip down to this line of code
FRAME F=1
TAG POS=1 TYPE=A ATTR=TXT:Feature<SP>Phone<SP>Activation
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
TAG POS=1 TYPE=SPAN ATTR=TXT:Generate<SP>Export<SP>File
TAG POS=2 TYPE=SPAN ATTR=TXT:Yes
WAIT SECONDS=8
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
ONDOWNLOAD FOLDER=C:\Users\AWC\Dropbox\Commissions\New<sp>Activations FILE=Feature<sp>New<sp>Activation<sp>Commission.xlsx WAIT=YES
TAG POS=1 TYPE=SPAN ATTR=TXT:Download<SP>Export<SP>File
sgibbs77
 
Posts: 3
Joined: Thu Sep 28, 2017 5:51 am

Re: Conditional Statements in iMacros sidebar for IE

by chivracq on Thu Sep 28, 2017 6:39 am

sgibbs77 wrote:I don't know if the is the proper location to post this, but I have a macro that runs through a set of various links and downloads data to my computer from a website. However, there are times when some of the links are not there. Right now, to get around this, I have to visually check to see which links are there and comment out the code for the links that are not there. Is there any way, given that I'm using the
Code: Select all
iMacros sidebar version for IE
, to do a check to see if the link is there and skip past it if it is not? Here is a sample of the code below:

Code: Select all
TAG POS=1 TYPE=A ATTR=TXT:Commissions
FRAME F=1
TAG POS=1 TYPE=A ATTR=TXT:Postpaid<SP>Activation
TAG POS=1 TYPE=A ATTR=TXT:Smart<SP>Phone<SP>Activation [b]this is the "link" that the macro "clicks" to get that set of data; it may or may not exist at any given time; I need to know how to get around it[/b]
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
TAG POS=1 TYPE=SPAN ATTR=TXT:Generate<SP>Export<SP>File
TAG POS=2 TYPE=SPAN ATTR=TXT:Yes
WAIT SECONDS=10
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
ONDOWNLOAD FOLDER=C:\Users\AWC\Dropbox\Commissions\New<sp>Activations FILE=Smartphone<sp>New<sp>Activation<sp>Commission.xlsx WAIT=YES
TAG POS=1 TYPE=SPAN ATTR=TXT:Download<SP>Export<SP>File
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:Postpaid<SP>Activation<SP>Summary [b]if the first link does not exist; it would need to skip down to this line of code[/b]
FRAME F=1
TAG POS=1 TYPE=A ATTR=TXT:Feature<SP>Phone<SP>Activation
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
TAG POS=1 TYPE=SPAN ATTR=TXT:Generate<SP>Export<SP>File
TAG POS=2 TYPE=SPAN ATTR=TXT:Yes
WAIT SECONDS=8
TAG POS=1 TYPE=SPAN ATTR=CLASS:icn<SP>rIcn<SP><SP>arrow-south-white-small
ONDOWNLOAD FOLDER=C:\Users\AWC\Dropbox\Commissions\New<sp>Activations FILE=Feature<sp>New<sp>Activation<sp>Commission.xlsx WAIT=YES
TAG POS=1 TYPE=SPAN ATTR=TXT:Download<SP>Export<SP>File

Yep, the 'General' Sub-Forum is the correct one for your Thread... (and always the one to choose if you are unsure...).

FCIM...! :mrgreen: (Read my Sig..., always mention your FCI when you open a Thread, many Commands are not implemented for all Browsers/Versions...)
=> iMacros for IE v...?, IE v...?, OS...?

But yep, simply use '!ERRORIGNORE' I would think, combined with a short '!TIMEOUT_STEP' (=1 or 0) to avoid waiting for the Default 6 sec for each 'TAG' Statement that won't do anything probably if the Link was not found in the Frame...

If those Statements might still click some "unwanted" Elements in the Frame, you would then need to first check with 'EXTRACT' if the Link is present before actually clicking on it if it's there, to then with 'EVAL()' spit out a "1"/"0" to reuse for the Statements you want to "mute" with "TAG POS={{!VAR1}}". ('TAG POS=0' won't do anything...)

And you can use the same Principle if you want on the 'WAIT=10 sec" Statement for a "Conditional 'WAIT'", if you don't want your Script to wait for 10 sec if the Link was not there...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Conditional Statements in iMacros sidebar for IE

by sgibbs77 on Fri Oct 06, 2017 8:48 am

Thank you for the response. I'm using the iMacros for IE version 11. It's the Freeware version on a Windows 8.1. If you wouldn't mind, could you provide an example of what you are talking about given the code I used? I'm a bit of a novice at using this, as all my macros were recorded using mouse clicks and some simple knowledge of how to code using the language. I greatly appreciate it!
sgibbs77
 
Posts: 3
Joined: Thu Sep 28, 2017 5:51 am

Re: Conditional Statements in iMacros sidebar for IE

by chivracq on Fri Oct 06, 2017 11:09 am

sgibbs77 wrote:Thank you for the response. I'm using the
Code: Select all
iMacros for IE version 11.  It's the Freeware version on a Windows 8.1.
If you wouldn't mind, could you provide an example of what you are talking about given the code I used? I'm a bit of a novice at using this, as all my macros were recorded using mouse clicks and some simple knowledge of how to code using the language. I greatly appreciate it!

Ah OK, some Follow-up 1 week later... :D

Hum, your FCI is still unclear..., "iMacros for IE version 11" does exist but it's a "strange" Version to use, more common would be v11.5, or even v12.0 which got released about 1 month ago, depending on when you started using iMacros... And your IE Version (the Version of the Browser itself) is still missing...

But no, I won't be writing your Script, I'll help you if you get "really" stuck but you need to do your "part of the job" and to try stg..., you already have maybe 100 Examples on the Forum if you search the Forum a bit (on my Posts for example with "Conditional" + "WAIT" or "spit out" or anything that can be "Conditional"...).
Have a look at this Thread for example where I explained the "Principle" and different "Techniques" you can use and where I maintain a List of relevant/interesting Threads...:
- Workarounds for Conditional Logic in Macro Code

But, this is a bit your "lucky day" though I guess, I actually just wrote a Script for a very similar Scenario like yours for some other Thread/User (who really did his best to find a Solution by himself, ah-ah...!):
- Re: How to use EVAL to Stop the Macro when there is no Next?

That should get you nicely started I reckon...!? 8)

Hum, and try to mention a bit clearly the 3 exact Versions for your Env., I normally don't react to Threads when your FCI is not mentioned clearly and completely...
And try to follow up a bit quicker than in one week again... I don't remember after 1 week what your Thread was about and I have to read it all over again.. :idea:
OK, good luck and post your Final Script... :wink:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Conditional Statements in iMacros sidebar for IE

by sgibbs77 on Fri Oct 06, 2017 11:20 am

I only replied today because I was not aware of the reply that you had provided earlier. My version of IE is version 11. I have not gotten the updated version of the iMacros sidebar, so I did not realize there were new versions of it. I will try looking at the links you provided to see if they help. I was not expecting you to do the work for me, just looking for an example. I have never created an iMacro macro from scratch by typing the code myself. As I stated, I've only built macros with mouse clicks.
sgibbs77
 
Posts: 3
Joined: Thu Sep 28, 2017 5:51 am

Re: Conditional Statements in iMacros sidebar for IE

by chivracq on Fri Oct 06, 2017 12:33 pm

sgibbs77 wrote:I only replied today because I was not aware of the reply that you had provided earlier. My version of IE is version 11. I have not gotten the updated version of the iMacros sidebar, so I did not realize there were new versions of it. I will try looking at the links you provided to see if they help. I was not expecting you to do the work for me, just looking for an example. I have never created an iMacro macro from scratch by typing the code myself. As I stated, I've only built macros with mouse clicks.

Oh well, you have some 'Notify me when a reply is posted' Option when you open a Thread or post any Msg in a Thread to get some automatic Notification (per E-mail I think), like on most Forums, especially built in PHPBB like this one...

Hum, well, if you have iMacros for IE v11.0 and it works fine for you, then there is no need to change then, even if I think that a few "cool" new Functionalities/Commands were introduced in v11.5, but they were maybe more "interesting" for a bit more "Advanced" Users...

But hum, about your Case, you probably don't even need any Conditional Logic in your Script, I already mentioned '!ERRORIGNORE' and a short '!TIMEOUT_STEP', you should try that first..., this is the most "plausible" and easiest Solution very probably...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

-->