How can I make script continue when encountering a different frame number?

Discussions and Tech Support specific to the iMacros for Chrome extension.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
MirandaLarry
Posts: 3
Joined: Thu Sep 10, 2020 1:19 am

How can I make script continue when encountering a different frame number?

Post by MirandaLarry » Thu Sep 10, 2020 1:56 am

imacros version: imacros for chrome extension 10.1.0 Free
OS: WIndows 10
Browser: Google CHROME 85.0.4183.83


Hi, Long time forum lurker first time poster lol,

I am trying to run a very simple script to automate my computer workflow, however one frame keeps changing its number from '4' to '5' and then my script doesn't work.

I'm sure this is a really simple fix but I clearly lack the expertise to figure it out. I have also searched on the forums as much as I could, however, the solutions are either beyond my capabilities or I'm missing their application.

Here is the code I'm using. It literally is used to just click two radio buttons (in FRAME F=5) and one drop down button (in FRAME F=0):

Code: Select all

FRAME F=5
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button
WAIT SECONDS=3
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:*******
TAG POS=1 TYPE=A ATTR=TXT:*******
My problem is that "FRAME F=5" changes randomly to "FRAME F=4" in the webpage (on each subsequent page load it could be '4' or '5', one of the two, but impossible to predict), which causes the macro script to stop as it is unable to complete.

First I tried to make a script like this:

Code: Select all

SET !ERRORIGNORE YES

FRAME F=5
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button

FRAME F=4
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button
WAIT SECONDS=3
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:*******
TAG POS=1 TYPE=A ATTR=TXT:*******
I wrote it like this thinking maybe if it couldnt complete FRAME F=5 then it would just timeout and go to the next lines executing in FRAME F=4. (I did also try it with SET !TIMEOUT_STEP 1 in there too) This solution didnt work.


My main question is this: Is there a solution that will allow me to just run the script for both F=5 and F=4 without the macro hanging if one doesn't complete? Or is there another solution to this I'm completely missing. Many solutions in the forums seemed to talk about using javascript, I'm not really too sure how to do that and wasn't sure if that even applied to my free version. Also if this can be solved easily by simply buying the paid version of the program, I'm open to it, I certainly think its worth the money, I just only use it to help click these three buttons and haven't been able to save up just yet.

Hope my description outlines the problem somewhat coherently.
Thanks so much for any help!
Last edited by MirandaLarry on Thu Sep 10, 2020 9:19 am, edited 1 time in total.
chivracq
Posts: 9713
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to make script continue when different frame number

Post by chivracq » Thu Sep 10, 2020 9:11 am

MirandaLarry wrote:
Thu Sep 10, 2020 1:56 am

Code: Select all

imacros version: imacros for chrome extension 10.1.0
OS: WIndows 10
Browser: Google CHROME 85.0.4183.83

Hi, Long time forum lurker first time poster lol,

I am trying to run a very simple script to automate my computer workflow, however one frame keeps changing its number from '4' to '5' and then my script doesn't work.

I'm sure this is a really simple fix but I clearly lack the expertise to figure it out. I have also searched on the forums as much as I could, however, the solutions are either beyond my capabilities or I'm missing their application.

Here is the code I'm using. It literally is used to just click two radio buttons (in FRAME F=5) and one drop down button (in FRAME F=0):

Code: Select all

FRAME F=5
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button
WAIT SECONDS=3
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:*******
TAG POS=1 TYPE=A ATTR=TXT:*******
My problem is that "FRAME F=5" changes randomly to "FRAME F=4" in the webpage (on each subsequent page load it could be '4' or '5', one of the two, but impossible to predict), which causes the macro script to stop as it is unable to complete.

First I tried to make a script like this:

Code: Select all

SET !ERRORIGNORE YES

FRAME F=5
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button

FRAME F=4
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button
WAIT SECONDS=3
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:*******
TAG POS=1 TYPE=A ATTR=TXT:*******
I wrote it like this thinking maybe if it couldnt complete FRAME F=5 then it would just timeout and go to the next lines executing in FRAME F=4. (I did also try it with SET !TIMEOUT_STEP 1 in there too) This solution didnt work.


My main question is this: Is there a solution that will allow me to just run the script for both F=5 and F=4 without the macro hanging if one doesn't complete? Or is there another solution to this I'm completely missing. Many solutions in the forums seemed to talk about using javascript, I'm not really too sure how to do that and wasn't sure if that even applied to my free version. Also if this can be solved easily by simply buying the paid version of the program, I'm open to it, I certainly think its worth the money, I just only use it to help click these three buttons and haven't been able to save up just yet.

Hope my description outlines the problem somewhat coherently.
Thanks so much for any help!

Hum, Thread approved because the overall Quality is very correct and I didn't want to make you redo your Post/Thread, but pay attention to select the "correct" Sub-Forum when you open a Thread... (or I don't answer...), this one will probably get moved to the 'General' Sub-Forum as it probably has nothing specific to the 'iMacros for CR' Sub-Forum...
I say "probably" because you might be hitting a Bug that could be specific to iMacros for CR v10.x, but you don't know that, and you should have mentioned it if you've tested some Script in some other Version/Browser and it fails "only" in this specific v10.1 for CR Version...

A few "Things" to improve before I will answer your Post/Thread...:

1- 'Free'/'PE' is missing from your FCI...?
... Even if you mention "somewhere in your Post" stg about buying the Paid Version, so that means you are using the 'Free' Version, but that bit of Info belongs clearly mentioned in your FCI and not lost in the middle of some Text...

2- Can you add a Question Mark to your Thread Title...?, you are not sharing a 'HowTo'...

3- Can you be more precise than just "This solution didnt work." when using 2 Blocks with both "F=4" + "F=5"...?
=> What "didn't work"...?, and what was the Behaviour you then observed...?

Oh yeah, and one more...:
4- v10.1 for CR just got released 2 days ago..., you mention "Long time forum lurker...", so that means you didn't just install v10.1 for CR for "the first time" just today or yesterday, I would think..., had you already started to write this Script and do some Testing in v10.0.5 for CR 'Free'...?, and were you getting the same Results...?, or did you start this Script from scratch only after installing/updating to v10.1 for CR...?

1+2 directly edited/added to your OP, 3+4 in a separate Reply..., and make sure to use the "new" Title in your Reply... (And if you quote (me), no need to requote your OP again...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
MirandaLarry
Posts: 3
Joined: Thu Sep 10, 2020 1:19 am

Re: How can I make script continue when encountering a different frame number?

Post by MirandaLarry » Thu Sep 10, 2020 9:51 am

Hi,

Thank you so much for your time and feedback. Hopefully I corrected the necessary errors in the OP and I will attempt to address points 3 and 4 below as well.

In response to point 3
3- Can you be more precise than just "This solution didnt work." when using 2 Blocks with both "F=4" + "F=5"...?
=> What "didn't work"...?, and what was the Behaviour you then observed...?
The behavior I observed was that upon playing the macro, if frame number 5 was loaded in the webpage it would execute the macro script in the page and then hang at the first 'TAG' entry under 'FRAME F=4. If, however, if frame number 4 was loaded in the webpage the macro would just hang at the first 'TAG' entry under FRAME F=5. This happens vice versa as well.

My expectation with including the duplicate script for both FRAME F=5 and FRAME F=4 in the macro, had been that upon being unable to complete the macro script for either FRAME F=5 or FRAME F=4, that the macro script would simply move to and execute the following command.

My very uninformed concern is that the other frame is still present in the loaded page however the buttons I need to press using the script are loading randomly into one or the other and perhaps the script is hanging looking endlessly in a frame (the frame the webpage and buttons didnt load into) for buttons that aren't there.


In response to point 4
4 - v10.1 for CR just got released 2 days ago..., you mention "Long time forum lurker...", so that means you didn't just install v10.1 for CR for "the first time" just today or yesterday, I would think..., had you already started to write this Script and do some Testing in v10.0.5 for CR 'Free'...?, and were you getting the same Results...?, or did you start this Script from scratch only after installing/updating to v10.1 for CR...?
I have been using macros for several years actually and using it for a similar task and application. My technique has always been to record my button presses and then edit the script to remove the unique url and basically use it to save me the repetitive mouse clicks on a form I use quite frequently. What has recently changed is the form is now loading into a larger webpage and unfortunately, the frame where the first two buttons are located keeps changing its number from 4 to 5 and back again every few page refreshes. So my recorded macro specifying FRAME F=5 just hangs and never completes if the form loads in on frame number 4 and vice versa. Unfortunately I dont have full control on the coding of the form so I cant delve unti it from that end, hence trying to find a workaround with the macro.

To be clear, the macro script works excellently and as it always has except for, like I said, the frame number which loads in is different than the one in my macro script, then the macro just hangs, (the green bar is on the top of the macro script window) and the macro doesn't continue.

I know it's really simple and I hope I'm not making it confusing, but at the same time, I understand that the solution to this no matter how simple, is currently beyond my capability of understanding.

I look forward to providing any additional info that may be helpful and greatly appreciate the attention and help this far.
chivracq
Posts: 9713
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How can I make script continue when encountering a different frame number?

Post by chivracq » Thu Sep 10, 2020 10:37 am

Alright, good-good, mini-Compliment for the overall Quality again..., and yep indeed, no need to post twice the same Reply, ah-ah...!, but you discovered the 'Delete' Button, "on time"...! :wink:
But I was waiting a bit before replying, as you cannot delete a Post anymore once anybody, including yourself, has posted afterwards...

>>>
My expectation with including the duplicate script for both FRAME F=5 and FRAME F=4 in the macro, had been that upon being unable to complete the macro script for either FRAME F=5 or FRAME F=4, that the macro script would simply move to and execute the following command.

Yep indeed, this would also be my "Expectation" and some easy Solution I would also first think of..., and the same Technique can also be used with the 'EVENT' Mode, when an Element is changing between "nth:4" and "nth:5" for example, => by simply repeating both Statements, and one of the 2 "should work"...

But it doesn't seem to work that way apparently, with a 'FRAME' Element and the 'FRAME' Command... :o

I'm a bit "worried", because 2 years ago, at the time of the Beta-Testing Phase for v10.0.2 for FF, v10.0.2 for FF was based on the same Core-Code of v10.0.1 for CR, I had reported that very same (Blocking) Bug and Behaviour you observe, ... and it got fixed in the Final v10.0.2 for FF Version that then got officially released...
But nobody had ever reported that Behaviour/Bug in v10.0.1 for CR, nor in the later v10.0.[3+4+5] for CR Versions, until you today, so I never knew if that Bug had only been introduced in v10.0.2 for FF and CR was never affected, or if it has also always existed in all v10.0.x for CR Versions + also the "new" v10.1 for CR Version, but no User ever reported it... :?

>>>

The "Good News" is that I think :P , I would have several possible Workarounds, ah-ah...!
But before going this Way..., there is maybe an easier Solution...! :P

If that Frame has an ID, then you could use the 'NAME=' Param for the 'FRAME' Command instead of using the 'F=' Param. :idea:
That would be the best and easiest Case... => Can you check that, in the Source of the "Main" '.html' Page...?

+ Also for "later" if it doesn't work, are those Frames declared as "frame" or "iframe" Elements...?
Last edited by chivracq on Fri Sep 11, 2020 1:02 am, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
MirandaLarry
Posts: 3
Joined: Thu Sep 10, 2020 1:19 am

Re: How can I make script continue when encountering a different frame number?

Post by MirandaLarry » Thu Sep 10, 2020 9:47 pm

Hi,
Yes, I was replying on my phone and wasn't sure the reply posted lol hence the duplicate. But no worries on waiting to reply, I'm extremely grateful to be getting any help at all, I understand Im a free user and it costs a lot to maintain support and development so I appreciate any time and help.

I do have some interesting news however. Due to the nature the web pages Im working with, Im usually pretty tied to using Google chrome and cant always test it on Firefox, however I was able to find a way to test it out today with a Firefox setup and I noticed something interesting:

For the following information I am using:
imacros: Firefox plugin Version 9030808 Free
Browser: Firefox 60.9.0esr
OS: Windows 10

In regard to your suggestion
If that Frame has an ID, then you could use the 'NAME=' Param for the 'FRAME' Command instead of using the 'F=' Param. :idea:
That would be the best and easiest Case... => Can you check that, in the Source of the "Main" '.html' Page...?
I had tried using the 'FRAME NAME=' instead of the 'FRAME F=' parameter with the Chrome imacros plugin and the macro script would just hang right at the first line, like it couldnt find the frame with that name, and not complete. This was one of the first things I checked when I discovered it in the wiki. However, today, I tried using the exact same macro script in the FIrefox imacros plugin and it worked! Same script, same Frame name. So to reiterate, all things in the macro script were identical between the chrome plugin and the firefox plugin used today and instead of designating FRAME F=4 or FRAME F=5, I designated 'FRAME NAME=*****" This of course seems to solve the problem because the frame name id would not be variable. Is this a limitation with the Chrome plugin not being able to execute the frame name parameter or is it simply an inconsistency in the webpage I am working in? Here is what the macros script used in this test looked like:

Code: Select all

TAB T=1
FRAME NAME="***********"
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button

FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:*******
TAG POS=1 TYPE=A ATTR=TXT:*******
I also tried using the macro script in the firefox plugin with both FRAME F=5 and FRAME F=4 designated (one right after another) with 'SET !ERRORIGNORE YES' and 'SET !TIMEOUT_STEP 1' in the head of the macro script and, unlike the chrome plugin, it operated as we originally expected, with the script moving along to the next command when it couldnt execute the previous one. It did not hang like it did with the Chrome plugin. Here is what the macros script used in this test looked like

Code: Select all

SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1

TAB T=1
FRAME F=5
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button

FRAME F=4
TAG POS=1 TYPE=LABEL FORM=NAME:mainform ATTR=TXT:****
TAG POS=1 TYPE=DIV ATTR=ID:next_button
WAIT SECONDS=3
FRAME F=0
TAG POS=1 TYPE=SPAN ATTR=TXT:*******
TAG POS=1 TYPE=A ATTR=TXT:*******
Here ends the information pertaining to using the imacros Firefox plugin for my tests.
+ Also for "later" if it doesn't work, are those Frames declared as "frame" or "iframe" Elements...?
It says "iframe id" in the webpage coding when I inspect it.
The "Good News" is that I think :P , I would have several possible Workarounds, ah-ah...!
But before going this Way..., there is maybe an easier Solution...!
Unfortunately many times it's difficult for me to use another browser other than Chrome, so certainly, if its not too much trouble of course, I would be most appreciative of any workarounds that you might know of.


So hopefully this thread is helpful, I hope I didn't just make a noob mistake and miss something obvious. Normally I would do more thorough testing with multiple versions and different browsers to identify inconsistencies, sadly I dont have the ability to do that in my current situation.
Post Reply