rapieragnay wrote: ↑Wed Mar 03, 2021 4:34 am
The code below describes the issue I'm facing in more detail
The first action gives me the user-agent what I need. (CR83)
The second action (click a button on the page) brings up my default user-agent. (FF52)
What action do I need to keep the new user-agent for all actions performed on that tab/window ?
Code: Select all
chrome = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36';
function goto(url) {
code = 'SET !USERAGENT "'+ chrome +'"'+'\n';
code+= "URL GOTO="+url+"\n";
iimPlayCode(code);
}
url = 'https://developers.whatismybrowser.com';
goto(url);
code = 'WAIT SECONDS=10'+'\n';
code += 'TAG POS=1 TYPE=INPUT:SUBMIT ATTR=CLASS:button<SP>button-filled-blue<SP>button-next-to-input'+'\n';
iimPlayCode(code);
Yep OK, but "again", this is "normal" (= By Design) Behaviour as you've split the Logic of your Script into 2 separate 'iimPlayCode()' Calls, where (By Design) all Vars and Built-in Vars get reset at the end of an 'iimPlayCode()' Call.
You would get the same Behaviour with any '!TIMEOUT_xxx' Vars, any '!VAR[n]' Vars or User-defined Vars (+ 'iimSet()' that you would need to call also each time), or even with '!ERRORIGNORE' for example...
The only Exception that I know of is with the 'FILTER' Command which doesn't get reset, and this is actually a "slightly" annoying Bug that I have reported many times already...
=> In order to get your UA "sticky" to "CR83", you then need to group all Actions together in one same on-the-fly Macro executed by one same 'iimPlayCode()' Call, ... or to repeat the "SET !USERAGENT xxx" Statement in all Sub-Macros like @techimac posted in his 2 Scripts...
>>>
Or make use/misuse
of the mini-Bug I noticed and described in my previous Post, by first running and aborting manually some mini-Macro, then your UA will remain "sticky" for any new Scripts you'll be running afterwards...
And/or maybe worth testing, it could be that you also get the same Behaviour/Func if you call that "mini-Macro" from your "main-Macro" and add some "fake" 'TAG' Statement (that won't be found) that will cause that Sub-Macro to abort "naturally", then it's possible that "maybe" the UA doesn't get reset, but I don't know, you would need to test/try... Same also with 'MacroError()' maybe...
I know of a "Bug" with the '!EXTRACT' Var which doesn't always get reset and where in some "Circumstances", it is possible to still retrieve the Content of '!EXTRACT' from some previously run Macro..., so maybe in some "edgy" Conditions with 'PAUSE'/'Abort'/'RuntimeError'/'MacroError()'/etc..., you'll be able to create some "unexpected" Behaviour that can always be used as a "Workaround" for some Scenario, ah-ah...!
- (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...