DIV:nth-of-type

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.

DIV:nth-of-type

by zirjeo on Tue Sep 19, 2017 8:01 pm

IE 11, Windows 10, VERSION BUILD=11.5.498.2403

I get this line of code below when selecting an arrow that expands a field for 2016 tax data for a property. But if I go into a different property and select the arrow for 2016 sometimes the numbers that are in parentheses are different for example the 2's below are 3's instead so then the code below will not work. Is there anyway to replace (2) with something so that any number that shows up it will still carry out the action? Would I have to use Eval possibly?

EVENT TYPE=CLICK SELECTOR="#ApplicationTabs-2>DIV:nth-of-type(2)>DIV:nth-of-type(9)>DIV>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(3)>TABLE>TBODY>TR>TD>A" BUTTON=0

P.S I could use TAG POS but it seems to take much longer.
WIndows 10, IE11, VERSION BUILD=11.5.498.2403
zirjeo
 
Posts: 59
Joined: Thu Oct 27, 2016 6:49 pm

Re: DIV:nth-of-type

by chivracq on Wed Sep 20, 2017 3:38 am

zirjeo wrote:
Code: Select all
IE 11, Windows 10, VERSION BUILD=11.5.498.2403


I get this line of code below when selecting an arrow that expands a field for 2016 tax data for a property. But if I go into a different property and select the arrow for 2016 sometimes the numbers that are in parentheses are different for example the 2's below are 3's instead so then the code below will not work. Is there anyway to replace (2) with something so that any number that shows up it will still carry out the action? Would I have to use Eval possibly?

Code: Select all
EVENT TYPE=CLICK SELECTOR="#ApplicationTabs-2>DIV:nth-of-type(2)>DIV:nth-of-type(9)>DIV>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(3)>TABLE>TBODY>TR>TD>A" BUTTON=0


P.S I could use TAG POS but it seems to take much longer.

1- That's where I think you could use 'XPATH' instead of 'SELECTOR'... :idea:

2- It's not possible to use Wildcards for the Numbers in 'nth-of-type(n)', you then get some Syntax Error about some "invalid expected String"...
You can use Wildcards for the whole 'nth-of-type(n)' part or for each "Level" between 2 '>' Separators, and even several Levels, up to "SELECTOR=*", and you won't get any Syntax Error but such Statements usually then do nothing unless you are firing some 'KEYPRESS' Event that can be caught from the whole HTML Page and is not "specific" to one specific HTML Element, like 'Space' (for Scrolling) / 'Ctrl^p' / 'Ctrl^a' / 'Ctrl^v' / 'Ctrl^f' / etc...

3a-You cannot use Relative Positioning either with the 'EVENT' Mode...
3b- Well, I have a way to replicate R-Positioning in the 'EVENT' Mode but it's a bit cumbersome as it involves a mix of the 'TAG' + 'EVENT' Modes and some somewhat complex Calculation on several 'EXTRACT=HTM''s with 'EVAL()' to re-calculate the "Position" of your HTML Element within the CSS to dynamically re-compute the 'n' in each 'nth-of-type(n)'... [Not for Cowards, ah-ah...!! :twisted: ]
3c- Hum, some Alternative Method for Relative Positioning with the 'EVENT' Mode is first tagging some HTLM Element that will not change with an 'EVENT' Statement with a Mouse 'CLICK' and then with one or several 'TAB' 'KEYPRESS' Statement(s) to navigate to your Link...

4- But a Method that usually works fine in such Cases, is simply to include several Statements for the different possible Positions, then one of the Statements will work...

5- It's possible to use Vars for the 'n', then if you can fairly easily "deduct" the correct 'n' Value from the Number of Paragraphs or specific Sections on the Page, then you can use a simplified Version of '3b-' to compute the correct 'n' Value using 'EVAL()' indeed...

6- I don't really understand why you say that the 'TAG POS' Mode seems to take much longer, it is normally the "Contrary", the 'EVENT' Mode is normally much slower that the 'TAG' Mode, especially with 'INPUT' Fields where some Content needs to be typed...? :?
- (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 General Support & Discussions

Who is online

Users browsing this forum: No registered users and 9 guests

-->