Choosing specific CLASS within span

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

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.

Choosing specific CLASS within span

by CaiAllin on Mon Feb 12, 2018 12:56 pm

The website im on is
https://www.amazon.co.uk/Fast-Diet-Healthy-Revised-Updated/dp/1780722370/ref=sr_1_1?m=A536GCHGR1FGB&s=merchant-items&ie=UTF8&qid=1518463114&sr=1-1

Hi, the problem I'm having is that I want to click the link that is "* used from *" but the issue I'm having is that when I use this code
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=A ATTR=CLASS:"a-size-mini a-link-normal"

it clicks on the first "* used from *" which is under hardcover but I need to click the one directly under paperback each time. I thought about changing the code to "POS=2" but the issue is the paperback "used from" will not always be in position 2.
So I wanted to know if it's possible to define imacros to click under a specific span? Or if it's possible to ensure it to click the option under paperback each time.

I hope I have followed all the rules, this is my first time posting and I'm very new to imacros. I am using JScript and so this is the full macro :)
Thanks for taking the time to read my queuery.

I have uploaded a picture for more clarity.
Attachments
class name.png
CaiAllin
 
Posts: 2
Joined: Thu Jan 18, 2018 7:27 am

Re: Choosing specific CLASS within span

by chivracq on Mon Feb 12, 2018 2:26 pm

CaiAllin wrote:The website im on is
https://www.amazon.co.uk/Fast-Diet-Healthy-Revised-Updated/dp/1780722370/ref=sr_1_1?m=A536GCHGR1FGB&s=merchant-items&ie=UTF8&qid=1518463114&sr=1-1

Hi, the problem I'm having is that I want to click the link that is "* used from *" but the issue I'm having is that when I use this code
Code: Select all
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=A ATTR=CLASS:"a-size-mini a-link-normal"

it clicks on the first "* used from *" which is under hardcover but I need to click the one directly under paperback each time. I thought about changing the code to "POS=2" but the issue is the paperback "used from" will not always be in position 2.
So I wanted to know if it's possible to define imacros to click under a specific span? Or if it's possible to ensure it to click the option under paperback each time.

I hope I have followed all the rules, this is my first time posting and I'm very new to imacros. I am using JScript and so this is the full macro :)
Thanks for taking the time to read my queuery.

I have uploaded a picture for more clarity.

FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for FF v9.0.3...?, FF55/56...?, OS...?

I had a look at your Site, and reusing your Script, the "easiest" Solution I think is to use "Double Relative Positioning" on the 'LI' Container containing your 'SPAN' "Paperback" rather than the 'SPAN' Element itself...:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
TAB T=1
'URL GOTO=https://www.amazon.co.uk/Fast-Diet-Healthy-Revised-Updated/dp/1780722370/ref=sr_1_1?m=A536GCHGR1FGB&s=merchant-items&ie=UTF8&qid=1518463114&sr=1-1

TAG POS=1 TYPE=LI ATTR=TXT:*Paperback* EXTRACT=TXT
TAG POS=R-1 TYPE=* ATTR=* EXTRACT=TXT
TAG POS=R1 TYPE=A ATTR=CLASS:"a-size-mini a-link-normal"&&TXT:*Used*from*
(Tested on iMacros for FF v8.8.2, Pale Moon v26.3.3 (=FF47), Win10_x64.)

The 2 'EXTRACT''s btw are "fake", only meant to prevent clicking on any clickable Element...
- (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: 6687
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Choosing specific CLASS within span

by CaiAllin on Mon Feb 12, 2018 2:45 pm

Wow that was a fast reply, and it's working instantly thanks so much!
So as I understand it, you are telling Imacros to find the text 'paperback', then using 'POS=R-1' you assign that location to R1, then using 'POS=R1' it looks for the first matching class after that point?

Ah I see, I will make sure to include all info next time. Just FYI I am using iMacros for FF v9.0.3 and OS is Win10x64
CaiAllin
 
Posts: 2
Joined: Thu Jan 18, 2018 7:27 am

Re: Choosing specific CLASS within span

by chivracq on Mon Feb 12, 2018 3:15 pm

CaiAllin wrote:Wow that was a fast reply, and it's working instantly thanks so much!
So as I understand it, you are telling Imacros to find the text 'paperback', then using 'POS=R-1' you assign that location to R1, then using 'POS=R1' it looks for the first matching class after that point?

Ah I see, I will make sure to include all info next time. Just FYI I am using
Code: Select all
iMacros for FF v9.0.3 and OS is Win10x64

Yep, exactly, that's the Principle of "Relative Positioning"...
In this Case, we have to use "Double Relative Positioning" because when using an 'LI' (same like 'DIV') Element, iMacros doesn't look inside it and starts looking after (or before) it, while your "... Used from..." Link is still inside the 'LI', so the first 'POS=R-1' is to get outside the 'LI' for iMacros to be able to look inside it again.

And yep, always mention your FCI when you open a Thread (or post for the first time in some existing Thread) (FF Version is still missing btw in this one, but OK, don't worry...), I usually don't react otherwise..., or only once for first time Posters, if the "Quality" of the Post is still a bit "correct"... :wink:
- (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: 6687
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: Mark S and 7 guests

-->