Hello Sirs and Madams
I was wondering how I would be able to grab the total amount of elements within a specific div in a dynamic environment. Specifically with regards to an eCommerce store that would change products on a daily basis.
How would I go about grabbing the total amount of products which are available?
I would like to store that value in a variable for later manipulation.
For example, there are 10 products available on that page (10 links), how would I manage to extract the total (10) and use that.
From what I've searched for, this might be easily accomplished via the EXTRACT, EVAL and/or TAG functions, however I am having some difficulty with the matter.
Would it be easier to do this with JavaScript instead?
EDIT:
VERSION BUILD=8970419 RECORDER=FX
OS: Ubuntu 14.04.4 LTS Release: 14.04
Browser: Firefox 47
With some searching I found this:
http://forum.imacros.net/viewtopic.php?f=11&t=26030
Shows that you can play .iim files in a .js file with the following command:
URL GOTO=imacros://run/?m=your-javascript.js
Would using something like this be advised:
$("#mylist li").length
Apologies, I am not knowledgeable on the topic, all suggestions are welcome.
Any assistance on the matter would be greatly appreciated. Many thanks for your time.
Extract Number of Elements
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
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
Re: Extract Number of Elements
CIM...! (Always mention your FCI when you open a Thread, read my Sig, many Commands are not available for all Browsers/Version...)Inflicted wrote:Hello Sirs and Madams
I was wondering how I would be able to grab the total amount of elements within a specific div in a dynamic environment. Specifically with regards to an eCommerce store that would change products on a daily basis.
How would I go about grabbing the total amount of products which are available?
I would like to store that value in a variable for later manipulation.
For example, there are 10 products available on that page (10 links), how would I manage to extract the total (10) and use that.
From what I've searched for, this might be easily accomplished via the EXTRACT, EVAL and/or TAG functions, however I am having some difficulty with the matter.
Would it be easier to do this with JavaScript instead?
EDIT:With some searching I found this:Code: Select all
VERSION BUILD=8970419 RECORDER=FX OS: Ubuntu 14.04.4 LTS Release: 14.04 Browser: Firefox 47
http://forum.imacros.net/viewtopic.php?f=11&t=26030
Shows that you can play .iim files in a .js file with the following command:
URL GOTO=imacros://run/?m=your-javascript.js
Would using something like this be advised:
$("#mylist li").length
Apologies, I am not knowledgeable on the topic, all suggestions are welcome.
Any assistance on the matter would be greatly appreciated. Many thanks for your time.
EDIT: Hum, OK, you keep editing your OP while I'm already responding, FCI mentioned... Good...!
=> The "URL GOTO=imacros://run/?m=your-javascript.js" Synatax for example only works on FF...
Your "$("#mylist li").length" is a good idea, I've posted already several Examples on the Forum where I use a similar Technique consisting of doing an 'EXTRACT=HTM' at your 'DIV' Level, which will contain all the Links, and then Length (-1) of the Array returned by 'split()' will give you the Number of Occurrences of the Keyword you used in the 'split()'.
Here is an Example (on the Nb of Select Options in a DDLB, but the Technique is the same for any other Element):
- Re: Number of Options in a Select tag
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Extract Number of Elements
Here is a possible solution if you're applying a pure iim macro
Code: Select all
' specify your selector here
SET selectScr "var num = document.querySelectorAll('div').length;"
SET !POPUP_ALLOWED {{!URLCURRENT}}
SET openScr "eval('window.open(\\"javascript:'+num+'\\")');"
URL GOTO=javascript:(function(){<SP>{{selectScr}}{{openScr}}<SP>})();
WAIT SECONDS=0.1
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=* ATTR=* EXTRACT=TXT
TAB CLOSE
SET number {{!EXTRACT}}
'PROMPT {{number}}