Skip A TAG Having Same Class in Imacros

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

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.

Skip A TAG Having Same Class in Imacros

by babarali124 on Sat Jul 15, 2017 9:27 pm

I have created a script which works fine, but i am just stuck on one issue that i cannot figure-out how to tackle it. So I wanted your help guys.

I just want to click a button but the thing is there are several buttons having the exact same class on the page. So the script does is it just clicks on the first button that it finds on the page. I want to skip that first button and click the second button.

So in short button 1 <-- skip button 2 <-- click


below is the code

Code: Select all
    TAG POS=1 TYPE=SPAN ATTR=TXT:NEXT
    WAIT SECONDS=6
    TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:knowledge-preregistered-email-response CONTENT={{!COL4}}
    TAG POS=1 TYPE=SPAN ATTR=TXT:NEXT
    WAIT SECONDS=7
    TAG POS=1 TYPE=BUTTON ATTR=CLASS:yt-uix-button*yt-uix-button-size-default*yt-uix-button-default*yt-uix-button-empty*yt-uix-button-has-icon*no-icon-markup*comment-action-buttons-renderer-thumb*yt-uix-sessionlink*sprite-comment-actions*sprite-like*i-a-v-sprite-like*
    WAIT SECONDS=7


This is the button class

Code: Select all
> ATTR=CLASS:yt-uix-button*yt-uix-button-size-default*yt-uix-button-default*yt-uix-button-empty*yt-uix-button-has-icon*no-icon-markup*comment-action-buttons-renderer-thumb*yt-uix-sessionlink*sprite-comment-actions*sprite-like*i-a-v-sprite-like*


So i want to skip the first button having this class and move on to the next one and click that. My code does click the first button. if i add the ATTR class tag again so it will click the first button again but does not move to the second button below it.
babarali124
 
Posts: 17
Joined: Sat Jul 15, 2017 9:24 pm

Re: Skip A TAG Having Same Class in Imacros

by chivracq on Sun Jul 16, 2017 2:45 pm

babarali124 wrote:I have created a script which works fine, but i am just stuck on one issue that i cannot figure-out how to tackle it. So I wanted your help guys.

I just want to click a button but the thing is there are several buttons having the exact same class on the page. So the script does is it just clicks on the first button that it finds on the page. I want to skip that first button and click the second button.

So in short button 1 <-- skip button 2 <-- click


below is the code

Code: Select all
    TAG POS=1 TYPE=SPAN ATTR=TXT:NEXT
    WAIT SECONDS=6
    TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:knowledge-preregistered-email-response CONTENT={{!COL4}}
    TAG POS=1 TYPE=SPAN ATTR=TXT:NEXT
    WAIT SECONDS=7
    TAG POS=1 TYPE=BUTTON ATTR=CLASS:yt-uix-button*yt-uix-button-size-default*yt-uix-button-default*yt-uix-button-empty*yt-uix-button-has-icon*no-icon-markup*comment-action-buttons-renderer-thumb*yt-uix-sessionlink*sprite-comment-actions*sprite-like*i-a-v-sprite-like*
    WAIT SECONDS=7


This is the button class

Code: Select all
> ATTR=CLASS:yt-uix-button*yt-uix-button-size-default*yt-uix-button-default*yt-uix-button-empty*yt-uix-button-has-icon*no-icon-markup*comment-action-buttons-renderer-thumb*yt-uix-sessionlink*sprite-comment-actions*sprite-like*i-a-v-sprite-like*


So i want to skip the first button having this class and move on to the next one and click that. My code does click the first button. if i add the ATTR class tag again so it will click the first button again but does not move to the second button below it.

CIM...! :mrgreen:
Mention your FCI for me to read, read my Sig...
And I don't think your Thread has anything specific to only FF, meaning your Script works in other Browsers but fails in FF only (or if you were using a '.js' Script), especially if you don't mention your FCI, try to select the correct Sub-Forum next time... (But no need to duplicate now...)

But from your Thread Title, I would think that what you need is simply to increment the 'POS=1' on your Button to 'POS=2'...
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Skip A TAG Having Same Class in Imacros

by babarali124 on Sun Oct 22, 2017 6:33 am

Thank you, this was solved , I did figure it out later, in order to target the second field we have to use post tag2
babarali124
 
Posts: 17
Joined: Sat Jul 15, 2017 9:24 pm

Re: Skip A TAG Having Same Class in Imacros

by chivracq on Sun Oct 22, 2017 10:51 am

babarali124 wrote:Thank you, this was solved , I did figure it out later, in order to target the second field we have to use post tag2

Ah OK, finally some Follow-up 3 months later... Good... :D
And yep, you are "expected" to share your Solution even if you manage to get your Script to work by yourself..., to make the Thread a bit useful for other Users as well, if you had the Qt and opened a Thread about it, chances are some other User(s) one day will have the same Qt...

Hum, not sure what you mean by "we have to use post tag2", I guess probably the "TAG POS=2" I had mentioned, OK...
But hum, if you clicked already on the 2nd Button when you had recorded your Macro, iMacros should have recorded as well automatically "TAG POS=2"..., it's a bit "strange" that you ended up with "TAG POS=1"...
A Technique you can often use for "identical" Elements on a Page is to use "Relative Positioning" if you need to "differentiate" them and tag them a bit more "precisely" than by increasing the 'POS=n'... This is often more "reliable", especially if the Number of such identical Elements can be variable...

And hum, you didn't mention your FCI like I asked..., OK, fair enough for this one but I usually don't react to Threads anymore after asking in the first one to mention your FCI... :idea:
July 2017, => probable FCI was:
iMacros for FF v9.0.3/v8.9.7, FF54/55, OS...
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: No registered users and 10 guests

-->