fixing macro when SELECTOR stops finding the right element?

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
totalimacrosnoobie
Posts: 2
Joined: Wed Oct 16, 2019 6:48 am

fixing macro when SELECTOR stops finding the right element?

Post by totalimacrosnoobie » Thu Oct 17, 2019 2:50 am

Hi, i am a complete brainlet at things like imacros, coding, anything like this. i have zero background in it, but I thought maybe some kind person here might be able to help me if i give enough information. After days of trying to solve it myself reading all about imacros, I am defeated. This post is a hail mary asking for help

iMacros: 9.0.3
Firefox: 52.6.0

In the past, a friend set up a looping macro for me on a website that would write text and send it using a loop that extracted names from a .txt file with a list. it worked fine for a few years but recently it just stopped working and simply cannot figure out how to fix it. Very sadly, my friend passed away and he was the only person I knew that could help me with this. here is the old macro that he had set up for me and I was using:

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !DATASOURCE /Users/DianaD/Downloads/listforimacros.txt
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
FRAME NAME="main"
EVENT TYPE=CLICK SELECTOR="HTML>BODY>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV:nth-of-type(2)>DIV>INPUT" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV:nth-of-type(2)>DIV>INPUT" CHARS="your text goes here {{!COL1}} or here"
EVENT TYPE=CLICK SELECTOR="HTML>BODY>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV:nth-of-type(3)>INPUT" BUTTON=0
WAIT SECONDS=60

(yes i know im a lowly mac user i use macOS 10.12.6)
i would just change the part of the macro that says "your text goes here" to what i wanted and itd just rapidly enter and send it with the modified loop extracting names from my .txt file in my downloads folder.
I have made sure to keep both firefox and imacros from updating so things dont break. I use firefox 52.6.0 as always, and imacros 9.0.3 . now
This leads me to believe the site itself changed. the macro gets stuck on line 8 and the error code says that it cannot find what the SELECTOR command is looking for. im pretty sure the long HTML>BODY>etc" element was the text box that when clicked allowed typing to be entered, but this no longer works. I've tried using the inspector thingy to find the text box but copy pasting what comes up doesnt seem to work. trying to find it by clicking it while using all the different imacros record modes never resulted in a working SELECTOR element either.

through reading lots of imacros wiki stuff i barely understand and banging my head against the wall, I have learned that the code seems to be a string navigating the inspector's sub menus. though none of the record mode attempts yielded a functioning macro, i think i was able to get some new element things that maybe could be helpful. my hope is that with some help from this forum i can learn to manually correct the new code things i pulled from my imacros record mode attempts, and eventually get it working again. ive been collecting anything i find useful which ill share below:

here is a screenshot of the textbox that it was previously able to select:
Image
download/file.php?mode=view&id=1565


to contrast with the old SELECTOR element found in the macro above, here is a new one i was able to get through one of the imacros recording modes ( but just copy pasting that in place of the old ones doesnt make the macro work for some reason:

Code: Select all

EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(5)>TABLE>TBODY>TR:nth-of-type(4)>TD>TABLE>TBODY>TR:nth-of-type(2)>TD>TABLE>TBODY>TR>TD>DIV>DIV>DIV>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR:nth-of-type(2)>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV>DIV>INPUT" BUTTON=0

here is the element itself when using the web dev inspector thing and clicking the text box enabling typing:

Code: Select all

<input id="message_input" name="message_input" class="player_message_input" style="" maxlength="160" onkeydown=" KeyDown(event); " onkeyup=" KeyUp(event); " onmouseover=" iPhone_InputNoZoom.MouseOver(); " onmouseup=" iPhone_InputNoZoom.MouseUp(); if(g_UA.iOS ) { GetEl('video_td').style.verticalAlign='bottom'; } " ondrop=" event.preventDefault(); if(t.nDragUserId &amp;&amp; t.g_hUsers[t.nDragUserId] ) this.value = this.value + ' ' + t.g_hUsers[t.nDragUserId].username + ' '; t.nDragUserId=0; this.classList.remove('highlight_bg'); this.style.backgroundColor='transparent'; this.focus(); this.value=this.value; " ondragover=" event.preventDefault(); this.style.backgroundColor=''; this.classList.add('highlight_bg'); " ondragleave=" this.style.backgroundColor='transparent'; this.classList.remove('highlight_bg'); " autocomplete="off" type="text">


here is a line of code one of the imacros record modes created when i clicked the "send" button seen in the screenshot above"

Code: Select all

TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:send_button

im at my wits end. I've begun to understand a TEENY bit of how imacros works, and maybe i can fix it if i can figure out how to do maybe a coordinate click command (but i cant even figure how to get the coordinates). im thinking maybe a coordinate click to click in the box to enable typing, and another to hit the send button???? maybe there is a way to keep the text box typing enabled when i start my keypress loop so i can just click the right area manually and then have it start instead of it just disabling when i click the imacros sidebar??? maybe use KEY=13 to have it hit enter to send instead of needing to click send? bypass the clicking thing all together somehow?? this is over my head. i think maybe if i learn how to manually edit the new SELECTOR="HTML>BODY>etc" thing i can get it working, but i get lost when it says like "nth-of-type(5)" and all that, so i dont know what to do.

please help me if youre so kind! im willing to paypal somebody if thats what they need to help me out. im fine switching to chrome or a diff version or firefox/imacros if needed.

thank you so much in advance!

I
Attachments
Screenshot 2019-10-16 18.19.21.png
chivracq
Posts: 8722
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: fixing macro when SELECTOR stops finding the right element?

Post by chivracq » Thu Oct 17, 2019 4:04 am

totalimacrosnoobie wrote:
Thu Oct 17, 2019 2:50 am
Hi, i am a complete brainlet at things like imacros, coding, anything like this. i have zero background in it, but I thought maybe some kind person here might be able to help me if i give enough information. After days of trying to solve it myself reading all about imacros, I am defeated. This post is a hail mary asking for help

iMacros: 9.0.3
Firefox: 52.6.0

In the past, a friend set up a looping macro for me on a website that would write text and send it using a loop that extracted names from a .txt file with a list. it worked fine for a few years but recently it just stopped working and simply cannot figure out how to fix it. Very sadly, my friend passed away and he was the only person I knew that could help me with this. here is the old macro that he had set up for me and I was using:

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !DATASOURCE /Users/DianaD/Downloads/listforimacros.txt
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
FRAME NAME="main"
EVENT TYPE=CLICK SELECTOR="HTML>BODY>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV:nth-of-type(2)>DIV>INPUT" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV:nth-of-type(2)>DIV>INPUT" CHARS="your text goes here {{!COL1}} or here"
EVENT TYPE=CLICK SELECTOR="HTML>BODY>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV:nth-of-type(3)>INPUT" BUTTON=0
WAIT SECONDS=60

(yes i know im a lowly mac user i use macOS 10.12.6)
i would just change the part of the macro that says "your text goes here" to what i wanted and itd just rapidly enter and send it with the modified loop extracting names from my .txt file in my downloads folder.
I have made sure to keep both firefox and imacros from updating so things dont break. I use firefox 52.6.0 as always, and imacros 9.0.3 . now
This leads me to believe the site itself changed. the macro gets stuck on line 8 and the error code says that it cannot find what the SELECTOR command is looking for. im pretty sure the long HTML>BODY>etc" element was the text box that when clicked allowed typing to be entered, but this no longer works. I've tried using the inspector thingy to find the text box but copy pasting what comes up doesnt seem to work. trying to find it by clicking it while using all the different imacros record modes never resulted in a working SELECTOR element either.

through reading lots of imacros wiki stuff i barely understand and banging my head against the wall, I have learned that the code seems to be a string navigating the inspector's sub menus. though none of the record mode attempts yielded a functioning macro, i think i was able to get some new element things that maybe could be helpful. my hope is that with some help from this forum i can learn to manually correct the new code things i pulled from my imacros record mode attempts, and eventually get it working again. ive been collecting anything i find useful which ill share below:

here is a screenshot of the textbox that it was previously able to select:
Image
download/file.php?mode=view&id=1565


to contrast with the old SELECTOR element found in the macro above, here is a new one i was able to get through one of the imacros recording modes ( but just copy pasting that in place of the old ones doesnt make the macro work for some reason:

Code: Select all

EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(5)>TABLE>TBODY>TR:nth-of-type(4)>TD>TABLE>TBODY>TR:nth-of-type(2)>TD>TABLE>TBODY>TR>TD>DIV>DIV>DIV>TABLE>TBODY>TR>TD>DIV>TABLE>TBODY>TR:nth-of-type(2)>TD>TABLE>TBODY>TR>TD:nth-of-type(4)>DIV:nth-of-type(2)>TABLE>TBODY>TR:nth-of-type(2)>TD>DIV>DIV>DIV>INPUT" BUTTON=0

here is the element itself when using the web dev inspector thing and clicking the text box enabling typing:

Code: Select all

<input id="message_input" name="message_input" class="player_message_input" style="" maxlength="160" onkeydown=" KeyDown(event); " onkeyup=" KeyUp(event); " onmouseover=" iPhone_InputNoZoom.MouseOver(); " onmouseup=" iPhone_InputNoZoom.MouseUp(); if(g_UA.iOS ) { GetEl('video_td').style.verticalAlign='bottom'; } " ondrop=" event.preventDefault(); if(t.nDragUserId &amp;&amp; t.g_hUsers[t.nDragUserId] ) this.value = this.value + ' ' + t.g_hUsers[t.nDragUserId].username + ' '; t.nDragUserId=0; this.classList.remove('highlight_bg'); this.style.backgroundColor='transparent'; this.focus(); this.value=this.value; " ondragover=" event.preventDefault(); this.style.backgroundColor=''; this.classList.add('highlight_bg'); " ondragleave=" this.style.backgroundColor='transparent'; this.classList.remove('highlight_bg'); " autocomplete="off" type="text">


here is a line of code one of the imacros record modes created when i clicked the "send" button seen in the screenshot above"

Code: Select all

TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:send_button

im at my wits end. I've begun to understand a TEENY bit of how imacros works, and maybe i can fix it if i can figure out how to do maybe a coordinate click command (but i cant even figure how to get the coordinates). im thinking maybe a coordinate click to click in the box to enable typing, and another to hit the send button???? maybe there is a way to keep the text box typing enabled when i start my keypress loop so i can just click the right area manually and then have it start instead of it just disabling when i click the imacros sidebar??? maybe use KEY=13 to have it hit enter to send instead of needing to click send? bypass the clicking thing all together somehow?? this is over my head. i think maybe if i learn how to manually edit the new SELECTOR="HTML>BODY>etc" thing i can get it working, but i get lost when it says like "nth-of-type(5)" and all that, so i dont know what to do.

please help me if youre so kind! im willing to paypal somebody if thats what they need to help me out. im fine switching to chrome or a diff version or firefox/imacros if needed.

thank you so much in advance!

I

OS belongs also to your FCI:
FCI:

Code: Select all

iMacros: 9.0.3
Firefox: 52.6.0
macOS 10.12.6
Yep, looks like the HTML Structure of this Site has changed a bit, the "original" Site was probably 10-15 years old, I would think, from the Use of Frames and 4 Levels of nested Tables for the Layout of the Site, and I would think the Site Designer has "started" to modernize it a bit, and I guess they are probably not "ready" yet, ah-ah...!

I would think they've started by removing the Frames and replacing them with 'DIV' Elements "directly" on the "main" Page...
When you recorded your Actions again to get the "new" 'SELECTOR', did iMacros also record some Line about the 'FRAME' Statement...?
=> I suspect not, and that would mean that your "FRAME NAME="main"" Statement is causing the problem and needs to be commented out, or some "FRAME F=0" needs to be placed just before the relevant Statement(s) where you tried to replace the "old" Selector with the "new" one... :idea:

Try also to re-record your Actions (still using the 'EVENT' Mode if the 'TAG' Mode is not working), but with the "Favor ID's" Setting in the Record Options. That will already shorten the Path quite a bit and make the Script a little bit more "reliable" in case of new Changes to the Page...
- (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...
chivracq
Posts: 8722
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: fixing macro when SELECTOR stops finding the right element?

Post by chivracq » Sat Oct 19, 2019 10:33 pm

Oh, good...!, I see some "Life" out there, 3 days later... :D

=> Any Follow-up/Update/Progress...?
- (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...
totalimacrosnoobie
Posts: 2
Joined: Wed Oct 16, 2019 6:48 am

Re: fixing macro when SELECTOR stops finding the right element?

Post by totalimacrosnoobie » Sat Oct 19, 2019 10:38 pm

chivracq wrote:
Thu Oct 17, 2019 4:04 am

I would think they've started by removing the Frames and replacing them with 'DIV' Elements "directly" on the "main" Page...
When you recorded your Actions again to get the "new" 'SELECTOR', did iMacros also record some Line about the 'FRAME' Statement...?
=> I suspect not, and that would mean that your "FRAME NAME="main"" Statement is causing the problem and needs to be commented out, or some "FRAME F=0" needs to be placed just before the relevant Statement(s) where you tried to replace the "old" Selector with the "new" one... :idea:

Try also to re-record your Actions (still using the 'EVENT' Mode if the 'TAG' Mode is not working), but with the "Favor ID's" Setting in the Record Options. That will already shorten the Path quite a bit and make the Script a little bit more "reliable" in case of new Changes to the Page...

you are right that the "main" part was a relic of the old script. i will have to try and edit that to see if that fixes it. since im so new to this i need to make time to study the wikis and stuff to figure out what each little part means, and if its even relevant the version i use

do you think updating to a newer imacros version will give me better results with recording? i think the favor IDs thing was already checked when i was attempting to record, so i am not sure if that will work with my current version
chivracq
Posts: 8722
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: fixing macro when SELECTOR stops finding the right element?

Post by chivracq » Sat Oct 19, 2019 11:04 pm

totalimacrosnoobie wrote:
Sat Oct 19, 2019 10:38 pm
you are right that the "main" part was a relic of the old script. i will have to try and edit that to see if that fixes it. since im so new to this i need to make time to study the wikis and stuff to figure out what each little part means, and if its even relevant the version i use

do you think updating to a newer imacros version will give me better results with recording? i think the favor IDs thing was already checked when i was attempting to record, so i am not sure if that will work with my current version

Yeah, well, then simply re-record your Actions, and pay attention if any 'FRAME' Statement(s) get(s) also recorded, they only get recorded (and are only needed) when you click in a "different" Frame...

>>>

About updating to a "newer" iMacros Version, hum, let me check your FCI then...:

Code: Select all

iMacros: 9.0.3
Firefox: 52.6.0
macOS 10.12.6
Oops, NO...!, definitely NO...! :shock:

v9.0.3 for FF is the last Version anyway to work on FF52.
The "later" v10.0.2 for FF Version only works on FF from FF56/57 (current is FF68 I think...), so unless you are "forced" to update FF to pass beyond FF56, then you would be obliged indeed to use v10.0.2 for FF, but that Version is very limited in Functionality compared to v9.0.3. :(
Hum, and I think that's not even "an Option" for you, as you use the 'EVENT' Mode, but the 'EVENT' Mode is not even supported/implemented anymore/yet in v10.0.2 for FF, so your Script wouldn't work at all in that Version...

v9.0.3 for FF is also not even "the best Version" to use on FF52, but v8.9.7 for FF (can be downloaded from the 'FF Legacy' Wiki-Page), v9.0.3 is also "limited" compared to v8.9.7... :idea:
(And both Versions work on FF until FF56, but recommended is FF v55.0.3, FF56 broke "a few things" compared to FF55.)

And if you need "a modern and up-to-date Browser", v8.9.7 still works on 'Pale Moon' v28, + 'Basilisk' v2019-09-x, + 'WaterFox' v56, and those 3 Browsers get updated regularly with Security Updates etc...

But there is "nothing really wrong" with your FF52 + v9.0.3, if the HTML Structure of the Site itself changed, all other Versions of iMacros would also encounter the same Pb's like you did..., using a different Browser and/or a different Version of iMacros with the same "old" Script based on the "old" Site wouldn't help...
- (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