Not getting the right element

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
KiEni
Posts: 14
Joined: Sat Sep 13, 2014 9:25 pm

Not getting the right element

Post by KiEni » Thu Oct 23, 2014 2:10 pm

iMarcro 8.8.5, Firefox 33, Windows 8.1 64-bit

I'm having a bit of trouble trying to tag the right element. When I run my script I tag the right thing buy when I try to find tag the forms that's related to my element its tags the forms related to the element next to my desire element.

My Script:
TAG POS=1 TYPE=H2 ATTR=TXT:*TROPICAL*GREEN* Extract=TXT
TAG POS=R1 TYPE=LABEL FORM=ID:product* ATTR=TXT:9.5
TAG POS=R1 TYPE=INPUT:RADIO FORM=ID:product* ATTR=ID:swatch-0-9-5
TAG POS=R1 TYPE=INPUT:SUBMIT FORM=ID:product* ATTR=NAME:button
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:View<SP>cart

HTML:
<div id="product-description">
<h2>Hanon x Asics Gel Epirus 'TROPICAL GREEN'</h2> <---Anchor
<p id="product-price">
<span class="product-price" itemprop="price">$130.00</span>
</p>
<form id="product-form-371757621" data-money-format="${{amount}}" method="post" action="/cart/add"> <----- Desire element to be selected
<script>
<script type="text/javascript">
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Not getting the right element

Post by chivracq » Thu Oct 23, 2014 2:51 pm

KiEni wrote:iMarcro 8.8.5, Firefox 33, Windows 8.1 64-bit

I'm having a bit of trouble trying to tag the right element. When I run my script I tag the right thing buy when I try to find tag the forms that's related to my element its tags the forms related to the element next to my desire element.

My Script:

Code: Select all

TAG POS=1 TYPE=H2 ATTR=TXT:*TROPICAL*GREEN* Extract=TXT
TAG POS=R1 TYPE=LABEL FORM=ID:product* ATTR=TXT:9.5
TAG POS=R1 TYPE=INPUT:RADIO FORM=ID:product* ATTR=ID:swatch-0-9-5
TAG POS=R1 TYPE=INPUT:SUBMIT FORM=ID:product* ATTR=NAME:button
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:View<SP>cart
HTML:
<div id="product-description">
<h2>Hanon x Asics Gel Epirus 'TROPICAL GREEN'</h2> <---Anchor
<p id="product-price">
<span class="product-price" itemprop="price">$130.00</span>
</p>
<form id="product-form-371757621" data-money-format="${{amount}}" method="post" action="/cart/add"> <----- Desire element to be selected
<script>
<script type="text/javascript">
Can't you post the URL of the Page...?
But I think that both your Anchor and the Element you want to R-tag after are located within the same Div, so R-Tag will get you out of the Div. You need to use double R-Tag to get back into the Div...
- (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...
KiEni
Posts: 14
Joined: Sat Sep 13, 2014 9:25 pm

Re: Not getting the right element

Post by KiEni » Thu Oct 23, 2014 4:10 pm

chivracq wrote:
KiEni wrote:iMarcro 8.8.5, Firefox 33, Windows 8.1 64-bit

I'm having a bit of trouble trying to tag the right element. When I run my script I tag the right thing buy when I try to find tag the forms that's related to my element its tags the forms related to the element next to my desire element.

My Script:

Code: Select all

TAG POS=1 TYPE=H2 ATTR=TXT:*TROPICAL*GREEN* Extract=TXT
TAG POS=R1 TYPE=LABEL FORM=ID:product* ATTR=TXT:9.5
TAG POS=R1 TYPE=INPUT:RADIO FORM=ID:product* ATTR=ID:swatch-0-9-5
TAG POS=R1 TYPE=INPUT:SUBMIT FORM=ID:product* ATTR=NAME:button
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:View<SP>cart
HTML:
<div id="product-description">
<h2>Hanon x Asics Gel Epirus 'TROPICAL GREEN'</h2> <---Anchor
<p id="product-price">
<span class="product-price" itemprop="price">$130.00</span>
</p>
<form id="product-form-371757621" data-money-format="${{amount}}" method="post" action="/cart/add"> <----- Desire element to be selected
<script>
<script type="text/javascript">
Can't you post the URL of the Page...?
But I think that both your Anchor and the Element you want to R-tag after are located within the same Div, so R-Tag will get you out of the Div. You need to use double R-Tag to get back into the Div...
Here is the url: http://www.socialstatuspgh.com/collections/asics
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Not getting the right element

Post by chivracq » Fri Oct 24, 2014 12:32 pm

Instead of complaining in this other Thread without even referring to this current Thread that I didn't elaborate on Double R-Tag, you should have followed up in this current Thread... :idea:

But anyway..., thanks to the URL, I was able to play with your Page, and the Explanation to your Problem is that you use Relative Positioning (perfect!) but the 'Size' Field is actually a hidden RadioButton for which only the Labels are visible (and can be clicked/selected). When you record selecting a 'Size', you should have noticed that 2 Statements get recorded at once:

Code: Select all

TAG POS=1 TYPE=LABEL FORM=ID:product-form-371757621 ATTR=TXT:9.5
TAG POS=1 TYPE=INPUT:RADIO FORM=ID:product-form-371757081 ATTR=ID:swatch-0-9-5
They both belong together, and you only need 1 when using R-Positioning:

Code: Select all

TAG POS=1 TYPE=H2 ATTR=TXT:*TROPICAL*GREEN* Extract=TXT
'TAG POS=R1 TYPE=LABEL FORM=ID:product* ATTR=TXT:9.5 // (Commented out...)
TAG POS=R1 TYPE=INPUT:RADIO FORM=ID:product* ATTR=ID:swatch-0-9-5
TAG POS=R1 TYPE=INPUT:SUBMIT FORM=ID:product* ATTR=NAME:button
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:View<SP>cart
=> No need for the Label...

Other Solution if you want to keep the Label, but you need to know that the RadioButton comes first in the DOM Hierarchy, so you need to use Negative R-Positioning for the RadioButton after the Label:

Code: Select all

TAG POS=1 TYPE=H2 ATTR=TXT:*TROPICAL*GREEN* Extract=TXT
TAG POS=R1 TYPE=LABEL FORM=ID:product* ATTR=TXT:9.5
TAG POS=R-1 TYPE=INPUT:RADIO FORM=ID:product* ATTR=ID:swatch-0-9-5
TAG POS=R1 TYPE=INPUT:SUBMIT FORM=ID:product* ATTR=NAME:button
WAIT SECONDS=1
TAG POS=1 TYPE=A ATTR=TXT:View<SP>cart
Tested on iMacros v8.8.2 for FF, Pale Moon v24.6.2 (=FF31), Win7-64.

And BTW, Config Info in your Signature for the other Thread(s?) you opened is not a good idea, or only to indicate what is your current Config, as those Threads will become completely confusing in a few weeks/months when you'll have updated iMacros or your Browser as you only have 1 dynamic Signature for the whole Forum and for all your Posts...
(And it's not "iMarcro" but "iMacros"...!)
- (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...
KiEni
Posts: 14
Joined: Sat Sep 13, 2014 9:25 pm

Re: Not getting the right element

Post by KiEni » Fri Oct 24, 2014 11:21 pm

Sorry it was just bugging me. Why is that having one and the other would cause it to go to a different product? When I say one and the other I'm referring to the R-Tags. And also I notice that for the TROPICAL it would add a size 9 to the cart but with the NIGHTSHADE it added the correct size 9.5. Why is that so? It is not a big deal but I'm just and would like to learn.
anmol94
Posts: 1
Joined: Fri Feb 20, 2015 4:54 am

Re: Not getting the right element

Post by anmol94 » Fri Feb 20, 2015 5:56 am

I think that both your Anchor and the Element you want to R-tag after are located within the same Div, so R-Tag will get you out of the Div. You need to use double R-Tag to get back into the Div...
**SignaturE**
Post Reply