Full Quote:
Eza168 wrote: ↑Sun Dec 11, 2022 5:34 pm
chivracq wrote: ↑Sun May 28, 2017 11:22 am
If your Frame_Nb varies within [14,18] => 5 Values, "my" Solution would be to 5 times "try" to extract one (or more) of the Fields you want to extract to check if it is present in that Frame_Nb to therefore "deduct" which Frame_Nb to use using 'EVAL()' + 'CASE' or 'if else' for example, stg like:
Code: Select all
'Check FRAME_Nb for F[14,18]:
FRAME F=14
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_14 {{!EXTRACT}}
'>
FRAME F=15
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_15 {{!EXTRACT}}
'>
FRAME F=16
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_16 {{!EXTRACT}}
'>
FRAME F=17
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_17 {{!EXTRACT}}
'>
FRAME F=18
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_18 {{!EXTRACT}}
'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f14='{{F_14}}', f15='{{F_15}}', f16='{{F_16}}', f17='{F_17}}', f18='{{F_18}}'; var nf='#EANF#'; var z; if(f14!=nf){z=14;} else if(f15!=nf){z=15;} else if(f16!=nf){z=16;} else if(f17!=nf){z=17;} else if(f18!=nf){z=18;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
PAUSE
FRAME F={{FRAME_Nb}}
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:ctLP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:lowSP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:hiSP EXTRACT=TXT
TAG POS=1 TYPE=SPAN ATTR=ID:ctSP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:avgDom EXTRACT=TXT
Not tested as your Site is behind Login&Password but I guess you can understand the "Principle"...
The 5x 'if else' Construction is maybe not very "elegant", there are probably more elegant Solutions, ah-ah...!, but this one should work...
Excuse me to asking when i adapt your code to my need, since i face similar problem but seems not worked for my side. For your information, im using
Code: Select all
imacros version 8970419 with palemoon browser 28.10.0 (64bit) windows 10nt.
I only adapt a little since my frame number change from 6 - 10 in
https://openlearning.com for scripting about me page text area.
here is my small editing from your code, but all will result FRAME=6 , even when i deleted all things for f6
Code: Select all
'Check FRAME_Nb for F[6,10]:
FRAME F=6
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_6 {{!EXTRACT}}
'>
FRAME F=7
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_7 {{!EXTRACT}}
'>
FRAME F=8
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_8 {{!EXTRACT}}
'>
FRAME F=9
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_9 {{!EXTRACT}}
'>
FRAME F=10
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_10 {{!EXTRACT}}
'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f6='{{F_6}}', f7='{{F_7}}', f8='{{F_8}}', f9='{F_9}}', f10='{{F_10}}'; var nf='#EANF#'; var z; if(f6!=nf){z=6;} else if(f7!=nf){z=7;} else if(f8!=nf){z=8;} else if(f9!=nf){z=9;} else if(f10!=nf){z=10;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
PAUSE
FRAME F={{FRAME_Nb}}
SET !EXTRACT NULL
EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
WAIT SECONDS=1
EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY" CHARS="Sample text writing to test frame"
Did i copy your code any missed? or maybe something about anything else. Thanks very much for your time to take a look and give me your generousity.
Regards,
Albert
Euh...!?, a bit surprised you managed to post a 1st Post "freely" without me (Mod on this Forum) having to approve it. while you joined recently (=> 2022-10-18) and only have this current Post in your History, ... but OK, I see you deleted some previous Post of yours, and the whole Thread with it:
"Eza168 02/11/2022 - 13:17 Deleted topic “Imacros to Trick TAG POS which always change randomly.” written by “Eza168” for the following reason » "
And I had apparently not reacted to that Thread, the Quality was probably "too low", or I was "busy" at that time with "real Life", I don't really remember... (Oh yes!, I was indeed "busy" at that time (around 18 of Octb) and for nearly 1 week...) But hum, be "careful", I don't "like it too much" when Users delete or mutilate their Post(s)/Thread(s) instead of improving the Quality and sharing their Solution, and I usually then don't help them (anymore)..., just like you were probably "Happy" to find this current Thread, with a "useful" Script/Solution in it...
But OK, the Quality of your Post in this current Thread is very correct, and you did "your Research" very well, then hum..., OK...
>>>
Alright, your Post is "self-contained", all (needed) Info is in it, I don't need to completely re-dig into the Thread and re-read it from the beginning, which is very good, well for me and for other Users
, and..., yep-yep, I understand your Scenario and what you are trying to do, ... and what is "going wrong"...
The Script/Implementation visible in the Quote is based on the 'EXTRACT' Mechanism:
Code: Select all
FRAME F=18
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_18 {{!EXTRACT}}
=> Then if "F=18" was "correct", the 'F_18' Var would contain some "Extracted Text for the Page/Frame", and if the Fame Number was not correct, 'F_18' would contain the String "#EANF#" as the Element would have not been found and the 'EXTRACT' would return "#EANF#".
But the 'EXTRACT' Mechanism/Command is only supported by the `TAG` Mode, while you are using the `EVENT` Mode yourself in your Script, with:
Code: Select all
'Check FRAME_Nb for F[6,10]:
FRAME F=6
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_6 {{!EXTRACT}}
The "EVENT ..." Line doesn't really matter, commented out or not, as it not doing anything, what that Part is doing is actually:
Code: Select all
SET !EXTRACT NULL
SET !VAR1 {{!EXTRACT}}
PROMPT VAR1:<P>_{{!VAR1}}_
... And the PROMPT returns: "VAR1: __", => an empty String, between the 2 Underscores.
=> All your 'F_6', 'F_7', etc Vars all contain the same empty String, ... which is not what you want...!
Then later in the Script in the `EVAL` Statement to deduct the Frame Nb:
Code: Select all
'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f6='{{F_6}}', f7='{{F_7}}', f8='{{F_8}}', f9='{F_9}}', f10='{{F_10}}'; var nf='#EANF#'; var z; if(f6!=nf){z=6;} else if(f7!=nf){z=7;} else if(f8!=nf){z=8;} else if(f9!=nf){z=9;} else if(f10!=nf){z=10;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
... the 1st Condition (if(f6!=nf){z=6;}) (=> if(f6!='#EANF#'){z=6;}) will always be True as an empty String ("") is different from the "#EANF#" String, and the `EVAL()` will always return "6".
=> You need to first tag and extract some Element that will be on that Frame, but using the `TAG` Mode first, and not the `EVENT` Mode, because you cannot extract using the `EVENT` Mode... Only the `TAG` Mode will be able to populate your 'F_6'...'F_10' Vars, not the `EVENT` Mode...
- (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...