Update Macro incremental nth-of-type

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
marchello
Posts: 4
Joined: Mon Sep 09, 2019 9:05 pm

Update Macro incremental nth-of-type

Post by marchello » Mon Sep 09, 2019 9:21 pm

Hello,

I was running an imacro script for long time without issue and today I see it stop when reach specific point. I try to record new macro to see if there is an update on the code and found something different, well I try to adapt with the new code and it was working but only on first image next image stop the script. I notice something different on the new recorded macro but don't know how to implement it :oops:

my line of code was like this

Code: Select all

iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");
iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")};
and here code when I make a new record with adding tags

Code: Select all

EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT" CHARS="aze "
EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI:nth-of-type(2)>INPUT" CHARS="bve "
EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI:nth-of-type(3)>INPUT" CHARS="dss "
EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI:nth-of-type(4)>INPUT" CHARS="cvb " etc.....
Not sure but I think it's the nth-of-type(??) that need to adapt to next image tags hope it's clear :roll:
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Update Macro incremental nth-of-type

Post by chivracq » Mon Sep 09, 2019 11:29 pm

marchello wrote:
Mon Sep 09, 2019 9:21 pm
Hello,

I was running an imacro script for long time without issue and today I see it stop when reach specific point. I try to record new macro to see if there is an update on the code and found something different, well I try to adapt with the new code and it was working but only on first image next image stop the script. I notice something different on the new recorded macro but don't know how to implement it :oops:

my line of code was like this

Code: Select all

iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");
iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")};
and here code when I make a new record with adding tags

Code: Select all

EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT" CHARS="aze "
EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI:nth-of-type(2)>INPUT" CHARS="bve "
EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI:nth-of-type(3)>INPUT" CHARS="dss "
EVENTS TYPE=KEYPRESS SELECTOR="#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI:nth-of-type(4)>INPUT" CHARS="cvb " etc.....
Not sure but I think it's the nth-of-type(??) that need to adapt to next image tags hope it's clear :roll:

Your Thread will probably get moved to the 'General' Sub-Forum as it has nothing specific with 'FF', especially if you don't even mention your FCI, (but no need to duplicate now), and the 'EVENT' Mode is not even supported on FF anymore (in v10.02 for FF), even if for many years it was only implemented for FF...

CIM...! :mrgreen: (Read my Sig...)

=> Mention your FCI for me to answer your Qt...
- (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...
marchello
Posts: 4
Joined: Mon Sep 09, 2019 9:05 pm

Re: Update Macro incremental nth-of-type

Post by marchello » Tue Sep 10, 2019 10:18 am

Hello,

I use Imacro 8.9.7 for firefox 47 my macro is .js and I don't understand what is FCI ??? :oops:
marchello
Posts: 4
Joined: Mon Sep 09, 2019 9:05 pm

Re: Update Macro incremental nth-of-type

Post by marchello » Tue Sep 10, 2019 3:47 pm

I just fixed it on my code have other similar code I update those other line and script run again :mrgreen:
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Update Macro incremental nth-of-type

Post by chivracq » Wed Sep 11, 2019 12:03 am

marchello wrote:
Tue Sep 10, 2019 10:18 am
Hello,

I use Imacro 8.9.7 for firefox 47 my macro is .js and I don't understand what is FCI ??? :oops:

"FCI" is explained in my Sig... => "Full Config Info"...
And you forgot to mention your OS...

>>>
marchello wrote:
Tue Sep 10, 2019 3:47 pm
I just fixed it on my code have other similar code I update those other line and script run again :mrgreen:

Hum, OK, good to hear, but you could give some more "Explanation" and post the Solution, with your final Script... :idea:
"I just fixed it on my code" is not very helpful for other Users if you don't share the/your Solution... :roll:
(And I won't try to help you "another time" if you don't... :| )
- (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...
marchello
Posts: 4
Joined: Mon Sep 09, 2019 9:05 pm

Re: Update Macro incremental nth-of-type

Post by marchello » Wed Sep 11, 2019 10:27 am

Hello,

here the script: the red color is the update code and blue the older I just found that code have same code at different place so update them and all is working now :shock:


for(k= 0;k< tags["length"];
k++){iimSet("TAGS",tags[k]);
//iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");
//iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")};

iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");
iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")};

for(i= 2;i<= totalImages;i++){var macro;macro= "CODE:";
macro+= "SET !DATASOURCE displate.csv\x09"+ "\x0A";
macro+= "SET !DATASOURCE_LINE {{I}}"+ "\x0A";
macro+= "SET !TIMEOUT_PAGE 45"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:FILE FORM=ID:multiuploader-form ATTR=ID:fileInput CONTENT={{PATH}}{{!COL1}}"+ "\x0A";
macro+= "WAIT SECONDS={{SECONDS}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=SPAN ATTR=TXT:0%"+ "\x0A";
macro+= "WAIT SECONDS=1"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:title CONTENT={{!COL2}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=TEXTAREA ATTR=ID:description CONTENT={{!COL3}}"+ "\x0A";
macro+= "SET !TIMEOUT_STEP 0"+ "\x0A";
macro+= "TAG POS=1 TYPE=DIV ATTR=TXT:Choose<SP>a<SP>collection*"+ "\x0A";
macro+= "TAG POS=1 TYPE=DIV ATTR=TXT:{{!COL4}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=DIV ATTR=TXT:Create<SP>new<SP>collection"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:new-collection CONTENT={{!COL4}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:Create"+ "\x0A";
macro+= "TAG POS=1 TYPE=SPAN ATTR=TXT:{{!COL5}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:RANGE ATTR=* CONTENT={{!COL8}}"+ "\x0A";
iimSet("PATH",folderPath);iimSet("SECONDS",seconds);
iimSet("I",i);iimPlay(macro);
var macro;macro= "CODE:";
macro+= "SET !DATASOURCE magik.csv\x09"+ "\x0A";
macro+= "SET !DATASOURCE_LINE {{I}}"+ "\x0A";
macro+= "SET !EXTRACT {{!COL6}}"+ "\x0A";
macro+= "ADD !EXTRACT {{!COL7}}"+ "\x0A";
iimSet("I",i);
iimPlay(macro);
var categories=iimGetLastExtract(1)["split"](",");
var tags=iimGetLastExtract(2)["split"](",");
for(k= 0;k< categories["length"];
k++){iimSet("CATEGORY",categories[k]);
iimPlay("CODE:TAG POS=1 TYPE=SPAN ATTR=TXT:{{CATEGORY}}")};
for(k= 0;k< tags["length"];
k++){iimSet("TAGS",tags[k]);
iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")}};

//iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")}};
chivracq
Posts: 8720
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Update Macro incremental nth-of-type

Post by chivracq » Wed Sep 11, 2019 11:36 am

marchello wrote:
Wed Sep 11, 2019 10:27 am
Hello,

here the script: the red color is the update code and blue the older I just found that code have same code at different place so update them and all is working now :shock:

for(k= 0;k< tags["length"];
k++){iimSet("TAGS",tags[k]);
//iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");
//iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")};

iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");
iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")};

for(i= 2;i<= totalImages;i++){var macro;macro= "CODE:";
macro+= "SET !DATASOURCE displate.csv\x09"+ "\x0A";
macro+= "SET !DATASOURCE_LINE {{I}}"+ "\x0A";
macro+= "SET !TIMEOUT_PAGE 45"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:FILE FORM=ID:multiuploader-form ATTR=ID:fileInput CONTENT={{PATH}}{{!COL1}}"+ "\x0A";
macro+= "WAIT SECONDS={{SECONDS}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=SPAN ATTR=TXT:0%"+ "\x0A";
macro+= "WAIT SECONDS=1"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:title CONTENT={{!COL2}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=TEXTAREA ATTR=ID:description CONTENT={{!COL3}}"+ "\x0A";
macro+= "SET !TIMEOUT_STEP 0"+ "\x0A";
macro+= "TAG POS=1 TYPE=DIV ATTR=TXT:Choose<SP>a<SP>collection*"+ "\x0A";
macro+= "TAG POS=1 TYPE=DIV ATTR=TXT:{{!COL4}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=DIV ATTR=TXT:Create<SP>new<SP>collection"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:new-collection CONTENT={{!COL4}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=BUTTON FORM=NAME:NoFormName ATTR=TXT:Create"+ "\x0A";
macro+= "TAG POS=1 TYPE=SPAN ATTR=TXT:{{!COL5}}"+ "\x0A";
macro+= "TAG POS=1 TYPE=INPUT:RANGE ATTR=* CONTENT={{!COL8}}"+ "\x0A";
iimSet("PATH",folderPath);iimSet("SECONDS",seconds);
iimSet("I",i);iimPlay(macro);
var macro;macro= "CODE:";
macro+= "SET !DATASOURCE magik.csv\x09"+ "\x0A";
macro+= "SET !DATASOURCE_LINE {{I}}"+ "\x0A";
macro+= "SET !EXTRACT {{!COL6}}"+ "\x0A";
macro+= "ADD !EXTRACT {{!COL7}}"+ "\x0A";
iimSet("I",i);
iimPlay(macro);
var categories=iimGetLastExtract(1)["split"](",");
var tags=iimGetLastExtract(2)["split"](",");
for(k= 0;k< categories["length"];
k++){iimSet("CATEGORY",categories[k]);
iimPlay("CODE:TAG POS=1 TYPE=SPAN ATTR=TXT:{{CATEGORY}}")};
for(k= 0;k< tags["length"];
k++){iimSet("TAGS",tags[k]);
iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=#multiuploader>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")}};

//iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT CHARS={{TAGS}}");iimPlay("CODE:EVENTS TYPE=KEYPRESS SELECTOR=HTML>BODY>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>DIV:nth-of-type(6)>UL>LI>INPUT KEYS=[32,32]")}};

Alright, perfect...!, and Thanks...! :D

Well, if you want some "mini-Explanation", your "old" Code had been recorded using the 'EVENT' Mode without ID's, while you recorded the "new" Code with ID's in the Record Options for the ("experimental") 'EVENT' Mode.

If you recorded that part without ID's again, you would get the same or very similar Code like your old Code and/or you could have compared more easily if it was still the same or what part exactly had changed... :idea:

But the 'EVENT' Mode with ID's is usually a little bit more "reliable" than without ID's if the Content of the Page changes, in case some HTML Element(s) get(s) added or removed in the CSS Tree Structure of the Path, like an extra Paragraph in some Text Content, or an Ad on the Page, for example...
- (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...
Post Reply