BLiTzKrIeGx1337 wrote: ↑Fri Aug 13, 2021 5:39 pm
iMacros 12.6.505.4525
Win10x64
IE11
Part of one of the macros I run in IE searches for an item and selects it by the item's name, lately though, it has occasionally been unable to find the element and errors out despite the item existing, it looks like sometimes, for some reason, the search box gets cleared before imacros tags the search button causing it to return no results, I've messed around a bit adding various waits and refreshes in different ways but I still keep getting the same issue, is there a way I can add in a script that would restart the macro at its current loop?
Code: Select all
URL GOTO=https://heraldpg.myprintdesk.net/DSF/Admin/ManageProducts.aspx?forcedToLoadOldClassic=true
SET !DATASOURCE C:\Users\forms\Desktop\AFDmacroCSVs\image&content.csv
SET !LOOP 48
SET !DATASOURCE_LINE {{!LOOP}}
SET !TIMEOUT_STEP 100
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:ctl00$ctl00$C$M$TextBoxSearch CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:IMAGE ATTR=NAME:ctl00$ctl00$C$M$ButtonSearch
WAIT SECONDS=3
TAG POS=1 TYPE=A ATTR=TXT:{{!COL1}}
^If the tag above isn't found, start the current loop over again
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:ctl00$ctl00$C$M$ctl00$W$ctl01$_BigIconByItself$EditProductImage
TAG POS=3 TYPE=INPUT:RADIO ATTR=NAME:ctl00$ctl00$C$M$ctl00$W$ctl01$_BigIconByItself$ProductIcon$CHOICE
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=NAME:ctl00$ctl00$C$M$ctl00$W$ctl01$_BigIconByItself$ProductIcon$ChkUseSameImageIcon CONTENT=YES
Thanks in advance!
"is there a way I can add in a script that would restart the macro at its current loop?"
=> Yep, your different 'WAIT' Statements won't help as you already have a long '!TIMEOUT_STEP' (= 100 Sec), so if some Element(s) do(es)n't get found, an extra [1-3] Sec won't change that...
Then..., yep-yep, that's possible... 2 different Techniques and 2 different Mechanisms...:
For both you will first need to extract that Link before "really" clicking on it to check if it exists...
Then using 'EVAL()', you will make "a lot of Things" conditional, ah-ah...!
But hum, first let me ask a Qt...: Do the 3 'TAG' Statements after the "TAG POS=1 TYPE=A ATTR=TXT:{{!COL1}}" need to be disabled/muted or won't they do anything if the Link was not found/not clicked...?
If that's the Case, then simply using '!ERRORIGNORE' + shortening '!TIMEOUT_STEP' will "do the Trick"...
Otherwise you'll need to compute the 'POS' Value (to enable/disable those Statements), or to conditionally switch to a 2nd Tab (already open, or that could conditionally be opened) where those 3 Statements won't do anything...
Then for the Loop Counter, you will need a Mechanism to "keep track" of the Nb of Faults to adjust the Counter for the '!DATASOURCE_LINE' Value, either using the OS Clipboard (with the '!CLIPBOARD' Var), or using some Temp mini-'.txt' or '.csv' File which are the 2 "main" Ways for iMacros to "communicate" with itself between 2 Loops.
>
Mini-Difficulty you might encounter, there is a Bug with the 'ADD' Command when using Negative Values when the Value = 0, then iMacros will append a "-0" as a String to the original Value... => "48-0" will remain "48-0" (as a String), instead of giving simply "48" as Result (as a Number).
=> Workaround is to use 'EVAL()' again also...
Oh yeah, another "mini-Difficulty" is the 'FILEDELETE' Command that you'll need, this Command has "a Life of its own", ah-ah...! The File needs to exist, or you need '!ERRORIGNORE'. Make sure to allow for about 0.5 Sec between Read/Delete/Recreate it. In "some" Versions, it is (by Design) disabled on the 'DataSources' Default Folder, but I think you should be "safe" with your "C:\Users\forms\Desktop\AFDmacroCSVs\" Folder, or it might even only work on the Default (iMacros) 'Downloads' Folder. (I don't know how it behaves in your v12.6 for IE Version.)
>
It's not very complicated to implement, I find the mini-Temp File more "reliable" than using the OS Clipboard, as if you are running your Script "in the Background" and go doing "other Things" on your Computer, if you "forget" about the Script and start using the OS Clipboard, you will screw the Script and the Looping... But that's your "Call"...
Then a '.txt' File is more "flexible" than a '.csv' File, and if you need to disable/mute the last 3 Statements in your Script, that '.txt' File could be used to be opened in the 'TAB_2' and serve as Report/Log about the "Progress" of the Script. And a '.txt' File can be opened in a Browser + in 'Notepad' for example, and iMacros can still delete/write/save it, the File is not "Locked" at the OS Level.
- (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...