Legalien wrote: ↑Thu Jun 23, 2022 10:23 pm
Code: Select all
Windows 10
Firefox 55.0.2
iMacros 8.9.7
So I have a bit of a problem with using multiple datasources in 1 iMacro script (.iim script).
Code: Select all
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 20
SET !DATASOURCE C:\Users\user\Documents\iMacros\Datasources\Folder1\mam.txt
SET !DATASOURCE_COLUMNS 2
SET !VAR1 EVAL("var min = 9; var max = 10; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
SET !VAR2 EVAL("var min = 2; var max = 3; var randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; randomNumber;")
SET !DATASOURCE_LINE 1
WAIT SECONDS={{!VAR2}}
URL GOTO=https://www.site.com/login/
WAIT SECONDS=2
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:login ATTR=ID:username CONTENT={{!COL1}}
WAIT SECONDS=1
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:login ATTR=ID:password CONTENT={{!COL2}}
WAIT SECONDS=2
TAG POS=1 TYPE=SPAN ATTR=TXT:Submit
WAIT SECONDS=3
URL GOTO=https://www.site.org/page.php
WAIT SECONDS={{!VAR1}}
SET !DATASOURCE C:\Users\user\Desktop\1\tools\result.txt
WAIT SECONDS={{!VAR2}}
EVENTS TYPE=KEYPRESS SELECTOR="#some_code" CHARS="{{!COL1}}"
So the script runs and uses the first datasource (mam.txt) to insert a username and password on a website, and then it logins.
Then it gets to the second datasource (result.txt) and tries to insert some text on the site. The problem is that this second datasource file doesn't always exist.
When the second datasource file doesn't exist, then iMacros inserts the COL1 from the first datasource. But I don't want it to do that. I told it to switch to the second datasource, why is it even taking the first datasource under consideration? What should happen if the second datasource doesn't exist, is to behave like it would if I ran the script using only the second datasource with the file not existing - iMacros should insert nothing, because there is nothing there.
Things work fine when the second datasource actually exists. Then iMacros inserts the text from it in the field.
Is there a solution to this?
---
I do have a solution. Breaking my script into 6 scripts, and then jumping from one to the other using URL GOTO=
1) Script 1 logs me in
2) Script 2 does what it does, then logs me out
3) Script 3 logs me in
4) Script 4 does what it does, then logs me out
5) Script 5 logs me in
6) Script 6 does what it does, then logs me out
In the end script 6 jumps back to script 1 and the process repeats itself.
In this way, it seems that when iMacros jumps from one script to another, it forgets the previous datasource and starts with a clean slate.
But there has to be a better way. Such a long solution to such a simple problem
Doesn't iMacro have a command to, like, reset it? Like you would run a command to clear the cache and cookies of a browser. Can't you run a command to clear the cache/cookies/memory of the iMacro extension?
Any solution is welcome. Thanks
>>>
Legalien wrote: ↑Thu Jun 23, 2022 11:11 pm
Legalien wrote: ↑Thu Jun 23, 2022 10:23 pm
1) Script 1 logs me in
2) Script 2 does what it does, then logs me out
3) Script 3 logs me in
4) Script 4 does what it does, then logs me out
5) Script 5 logs me in
6) Script 6 does what it does, then logs me out
In the end script 6 jumps back to script 1 and the process repeats itself.
In this way, it seems that when iMacros jumps from one script to another, it forgets the previous datasource and starts with a clean slate.
This won't work either. Scripts 2, 4 and 6 would have a total of eight inputs from the datasource. But iMacro just remembers the first input and keeps repeating it over and over again, no matter what appears in the txt file after
>>>
Legalien wrote: ↑Fri Jun 24, 2022 2:42 am
After many hours of banging my head up against the wall, I think I found the perfect solution!
Opening my txt file in a new tab, then copying my text using EXTRACT, and then pasting it in on the website.
Here is a little script:
Code: Select all
SET !EXTRACT_TEST_POPUP NO
TAB OPEN NEW
TAB T=2
URL GOTO="file:///C:/Users/user/Desktop/result.txt"
WAIT SECONDS=2
SET !EXTRACT NULL
TAG POS=1 TYPE=BODY ATTR=TXT:* EXTRACT=TXT
TAB T=1
WAIT SECONDS=2
SET !TIMEOUT 1
EVENTS TYPE=KEYPRESS SELECTOR="#someid" CHARS="{{!EXTRACT}}"
This is all I have, but it's all I need. I tested it and it seems to work great
>>>
Quick Quote of your 3 Posts (in case you would decide to "mutilate" your Thread as you seem to have found a Sol in the 3rd one (happens very often)), I had seen your first 2 Posts a few hour ago, but had Friends over, ... and they noticed my "Look" about "oh-oh...!, some new Thread on "my" Forum", and I was "not allowed" to reply or do any "Thinking" about this "new Thread", ah-ah...! Now they've just left, but it's "pretty late" and you "sound" like you found a Sol, so I'll have a look "tomorrow" after some sleep, ah-ah...!
+ From the Thread Title and a mini-super-diagonal-scan Reading, the Thread doesn't "sound" like specific to the 'iMacros for FF' Sub-Forum, rather meant for the 'General' one I would think, from a very quick Scan... I'll check "tomorrow" and will move it to its "relevant" Sub-Forum if necessary...
... But I think I like the Title already: "Multiple datasources in one script problem", the "good news" is that I do use multiple DataSources myself in several of my own Scripts, in some "pretty advanced way" I suppose, as I've never seen anybody asking any Qt's on the Forum about that kind of Scenarios, and also in the same v8.9.7 for FF Version like you (+ FF v55.03 + Win10-Pro), (+ the same Scripts also cross-FCI used for v8.8.2 for FF + PM v26.3.3 + same OS), so I guess I'm probably "quite knowledgeable" about using multiple DataSources in one same Script, ah-ah...!
+ Also (Temp)-DataSources being used between different Scripts, => one Script creates/saves a (Temp)-DataSource that some "other" Script can "check" or use as DataSource for some "further" Processing... Cool...!
Hum, "cool", except that I sometimes don't have any "clue" anymore what some of my Scripts are doing, ah-ah...! Written 10-8 years ago, they still work perfectly, but sometimes, I want to add some extra Func, and even if I always put Comments in my Coding/Scripts, pffff..., I sometimes have "Difficulties" re-understanding the sometimes "hum, pretty clever" Implementation I had done 8 or 10 years ago from my own Scripts, ah-ah...! (or oops...!?
)
OK, till tomorrow then, I will have a Look, and Thanks already for "Sharing", as I understood you already found a Solution, good...!
- (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...