how do i get imacros to adapt to nth-of-type change?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
PBNSurprise
Posts: 15
Joined: Sun Jun 19, 2016 12:10 am

how do i get imacros to adapt to nth-of-type change?

Post by PBNSurprise » Sun Jun 19, 2016 12:26 am

I have a script running that posts comments on the same picture over and over on Instagram. Here is the script:

EVENT TYPE=CLICK SELECTOR="#user-content-posts>DIV>DIV>UL>LI>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>TEXTAREA" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="#user-content-posts>DIV>DIV>UL>LI>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>TEXTAREA" CHARS=[comment]
EVENT TYPE=CLICK SELECTOR="#user-content-posts>DIV>DIV>UL>LI>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>BUTTON" BUTTON=0
WAIT SECONDS=60

The problem is whenever the profile uploads a new picture, >DIV:nth-of-type(3)> suddenly turns into >DIV:nth-of-type(2)> so my script is rendered useless and cannot find the correct comment box. In order to fix this I have to manually go in and change all the >DIV:nth-of-type(3)> to >DIV:nth-of-type(2)> so that iMacros is now selecting the proper comment box. When another picture is uploaded I then have to go back and change everything to how it was before.

How could I get around this and have it automatically adapt? Is there a way to tell iMacros to always select the first comment box on the page? If I don't use event mode I have found that the script does not run at all, this is in firefox
Rons
Posts: 1
Joined: Fri Oct 07, 2016 8:29 am

Re: how do i get imacros to adapt to nth-of-type change?

Post by Rons » Mon Oct 10, 2016 6:58 am

PBNSurprise wrote: How could I get around this and have it automatically adapt? Is there a way to tell iMacros to always select the first comment box on the page? If I don't use event mode I have found that the script does not run at all, this is in firefox
To be honest I don't think stuff like this is possible. I've tried extensively.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how do i get imacros to adapt to nth-of-type change?

Post by chivracq » Mon Oct 10, 2016 3:05 pm

PBNSurprise wrote:I have a script running that posts comments on the same picture over and over on Instagram. Here is the script:

Code: Select all

EVENT TYPE=CLICK SELECTOR="#user-content-posts>DIV>DIV>UL>LI>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>TEXTAREA" BUTTON=0
EVENTS TYPE=KEYPRESS SELECTOR="#user-content-posts>DIV>DIV>UL>LI>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>TEXTAREA" CHARS=[comment]
EVENT TYPE=CLICK SELECTOR="#user-content-posts>DIV>DIV>UL>LI>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV>BUTTON" BUTTON=0
WAIT SECONDS=60
The problem is whenever the profile uploads a new picture, >DIV:nth-of-type(3)> suddenly turns into >DIV:nth-of-type(2)> so my script is rendered useless and cannot find the correct comment box. In order to fix this I have to manually go in and change all the >DIV:nth-of-type(3)> to >DIV:nth-of-type(2)> so that iMacros is now selecting the proper comment box. When another picture is uploaded I then have to go back and change everything to how it was before.

How could I get around this and have it automatically adapt? Is there a way to tell iMacros to always select the first comment box on the page? If I don't use event mode I have found that the script does not run at all, this is in firefox
CIM...! :mrgreen:
Rons wrote:
PBNSurprise wrote: How could I get around this and have it automatically adapt? Is there a way to tell iMacros to always select the first comment box on the page? If I don't use event mode I have found that the script does not run at all, this is in firefox
To be honest I don't think stuff like this is possible. I've tried extensively.
CIM...! :mrgreen:

Yep, it is possible, I've already explained the Principle a few times...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
iimfun
Posts: 239
Joined: Tue Jul 19, 2016 1:06 pm

Re: how do i get imacros to adapt to nth-of-type change?

Post by iimfun » Tue Oct 11, 2016 8:03 am

PBNSurprise wrote:>DIV:nth-of-type(3)> suddenly turns into >DIV:nth-of-type(2)>
Maybe you need something like this

Code: Select all

>DIV:last-of-type>
PBNSurprise
Posts: 15
Joined: Sun Jun 19, 2016 12:10 am

Re: how do i get imacros to adapt to nth-of-type change?

Post by PBNSurprise » Wed May 23, 2018 12:28 am

i can't remember how i solved this.. i think the way i did it was setting two different numbers or variables to equal nth-of-type that i needed. then i would use both those variables at once. so when the imacros runs it will try both and pick whichever one that worked, if that makes sense
Post Reply