iopus / imacro - Log errors to file - macros

I'm writing an imacro script to automate tasks on firefox. The script works fine but sometimes it doesn't find the correct html.
How can I log to a txt file every time the script encounters an error?
Sample script:
VERSION BUILD=8601111 RECORDER=FX
TAB T=1
SET !TIMEOUT 4
SET !ERRORIGNORE YES
SET !DATASOURCE c:\myfile.csv
SET !DATASOURCE_COLUMNS 3
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
TAG POS=1 TYPE=INPUT:EMAIL FORM=ID:form0 ATTR=ID:Email CONTENT={{!COL1}} //lets assume the error is here, how can I log it ?
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:form1 ATTR=ID:Passwd CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:form2 ATTR=ID:PersistentCookie CONTENT=NO
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form3 ATTR=ID:signIn

try to use profiler:
http://wiki.imacros.net/Performance_Profiler
other option is to convert your code to javascript or similar format and catch and save thrown errors::
http://wiki.imacros.net/Error_and_Return_Codes

you could use:
SET !FILE_PROFILER myprofile.xml
documented here: http://wiki.imacros.net/Performance_Profiler
..and than you have to write yourself a script that looks for errors in this file.

Related

How to select-all, copy, and paste in iMacros

I'm using iMacros 9 with Firefox, and I'm having a brutally difficult time doing a simple select-all, copy-paste.
VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=BUTTON ATTR=ID:share_on_stats
TAG POS=1 TYPE=BUTTON ATTR=TXT:comma-separated
##need to do select all, and copy here.
TAG POS=1 TYPE=DIV ATTR=ID:modal-close
TAB T=2
##need to paste what was copied here
##TAG POS=1 TYPE=TEXTAREA FORM=ID:myform ATTR=ID:paste_code CONTENT=ALL
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:Next<SP>page
Anyone have any suggestions? I've tried clipboard, "EVENTS TYPE=KEYPRESS CHARS=”a” MODIFIERS=”ctrl” and some selection codes but nothing seems to work. After the click into "comma-separated" the page puts me in a modal with a txt CSV i need to copy.
Thanks!
One of the more common ways to perform this type of operation with iMacros is to extract the text you need to 'copy' using a TAG...EXTRACT command, and then use the extracted data, which gets stored in the !EXTRACT variable, in the CONTENT parameter of another TAG command that clicks the field you want to 'paste' into.
I'd recommend recording a click somewhere inside that modal that has the text you need, and then modify the command by adding EXTRACT=TXT to the end of it. Next, modify the TAG command for the textarea field like so:
TAG POS=1 TYPE=TEXTAREA FORM=ID:myform ATTR=ID:paste_code CONTENT={{!EXTRACT}}
c.f. How to copy-and-paste with iMacros
Below I'd like to show you how to select-all, copy, and paste in iMacros:
TAB T=1
TAG POS=1 TYPE=BUTTON ATTR=ID:share_on_stats
TAG POS=1 TYPE=BUTTON ATTR=TXT:comma-separated
' perhaps a small wait for a modal to pop up
' ##need to do select all, and copy here.
' your selector instead of *
EVENT TYPE=KEYPRESS SELECTOR=* CHAR="a" MODIFIERS="ctrl"
EVENT TYPE=KEYPRESS SELECTOR=* CHAR="c" MODIFIERS="ctrl"
TAG POS=1 TYPE=DIV ATTR=ID:modal-close
TAB T=2
' ##need to paste what was copied here
TAG POS=1 TYPE=TEXTAREA FORM=ID:myform ATTR=ID:paste_code CONTENT={{!CLIPBOARD}}
' or this line with the paste event
'EVENT TYPE=KEYPRESS SELECTOR="#paste_code" CHAR="v" MODIFIERS="ctrl"
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:Next<SP>page

Save extracted value as HTML file in iMacros

I wrote this code for iMacros:
SET !EXTRACT '<html><head></head><body><p>TEST</p></body></html>'
SAVEAS TYPE=EXTRACT FOLDER=E:\MyFolder FILE=test.html
But instead of HTML file, I get CSV file with name "test.html" and extension ".csv"
Same goes if I try with FILE=test.txt or any other format, it simply always saves files with CSV extension.
Is there any way to change file extension?
Perhaps this workaround will be helpful to you:
SET !EXTRACT "<html><head></head><body><p>TEST</p></body></html>"
SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/</g, '&lt').replace(/>/g, '&gt');")
TAB OPEN
TAB T=2
URL GOTO=javascript:'{{!EXTRACT}}';
WAIT SECONDS=0.5
SAVEAS TYPE=TXT FOLDER=E:\MyFolder FILE=test.html
TAB CLOSE
TAB T=1

Looking a solution to extract Email address with iMacros

I am not good in coding but I managed to create this simple macro to extract email address from a specific page with iMacros for Firefox.
The macro works flawlessly... Except
There is a little problem with extracted data.
This is the extracted data:
" Some Name ","some#domain.comHello"
" Some Other Name ","other#domain.netThis"
" Any Name ","some#domain.com.twSomeothertext"
I believe there is a line break and/or pharagraph problem with the email fields. There are also 4 space at the begining and 2 spaces at the end of the Name field.
I want to get rid of it and fix the email extraction problem.
This is what i want:
"Some Name","some#domain.com"
"Some Other Name","other#domain.net"
"Any Name","some#domain.com.tw"
And that is the code
VERSION BUILD=8970419 RECORDER=FX
SET !TIMEOUT_STEP 0
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
TAB T=1
EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV:nth-of-type(2)>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>DIV:nth-of-type(2)>DIV:nth-of-type({{!loop}})>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>DIV>A>SPAN" BUTTON=0 MODIFIERS="ctrl"
TAB T=2
TAG POS=1 TYPE=DIV ATTR=ID:profile-display-name EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=DIV ATTR=ID:profile EXTRACT=TXT
SET !VAR2 EVAL("'{{!EXTRACT}}'.match(/(([^<>()[\\]\\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/g)[0];")
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}[EXTRACT]{{!VAR2}}
SAVEAS TYPE=EXTRACT FOLDER=D:\ FILE=Contacts.txt
TAB T=1
TAB CLOSEALLOTHERS
'URL GOTO=javascript:window.scrollBy(0,2000)
Thanks for your help...
Try to make the folowing corrections:
SET !VAR1 EVAL("'{{!EXTRACT}}'.trim();")
and
TAG POS=1 TYPE=DIV ATTR=ID:profile EXTRACT=HTM
Thank you very much
I used the code
extract commented posts on facebook that are awesome
VERSION BUILD=8970419 RECORDER=FX
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
TAB T=1
SET !EXTRACT NULL
TAG POS={{!LOOP}} TYPE=SPAN ATTR=CLASS:UFICommentBody* EXTRACT=HTM
SET !VAR2 EVAL("'{{!EXTRACT}}'.match(/(([^<>()[\\]\\\.,;:\\s#\\\"]+(\\.[^<>()[\\]\\\.,;:\\s#\\\"]+)*)|(\\\".+\\\"))#((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/g)[0];")
SET !EXTRACT {{!VAR2}}
SAVEAS TYPE=EXTRACT FOLDER=D:\ FILE=MAIL_FB.txt

Imacros script stops if HTTP answer code != 200

I have an iMacros macro, which actually works like expected:
VERSION BUILD=8881205 RECORDER=FX
TAB T=1
URL GOTO=https://example.com/?page={{!LOOP}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:Excel
TAG POS=1 TYPE=A ATTR=TXT:Next<SP>Page<SP>>
But if any page gives any other HTTP status code as 200, my macro stops and then want to begin from the first page.
The question is: how can i achieve, that the macro doesn't stop, but just omit the page, which isn't available, in the best case after 5 access tryings.
Thank you!
Use this:
SET !ERRORIGNORE YES
This will keep the macro running and skip to the next page.

IMacros cannot find a POS (position) in Outlook Web App-See video

I'm trying to create emails from a .csv file but the TO; field and the BODY field cannot be identified by IMACROS. I attached a video to show you what I'm seeing and to better explain my question. http://screencast.com/t/euhT6X17
Below is the error and script:
RuntimeError: element INPUT specified by SRC:https://webmail-be.tomtomgroup.com/owa/14.3.169.1/themes/resources/clear1x1.gif was not found, line 15 (Error code: -921)
Script:
VERSION BUILD=8820413 RECORDER=FX
SET !DATASOURCE capterra.csv
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=https://webmail-be.tomtomgroup.com/owa/?modurl=0
TAG POS=2 TYPE=SPAN ATTR=TXT:New
TAB T=2
wait seconds=4
CLICK X=114 Y=46
TAG POS=1 TYPE=DIV ATTR=ID:divTo CONTENT={{!COL5}}
wait seconds=4
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:txtSubj CONTENT={{!COL5}}
wait seconds=4
CLICK X=28 Y=32
TAG POS=30 TYPE=INPUT:TEXT ATTR=SRC:https://webmail-be.tomtomgroup.com/owa/14.3.169.1/themes /resources/clear1x1.gif CONTENT={{!COL5}}
TAG POS=1 TYPE=SPAN ATTR=TXT:Send
SET !LOOP 2
Thanks in advance for your help.
Try changing it to this.
TAG POS=30 TYPE=INPUT:TEXT ATTR=SRC:https://webmail-be.tomtomgroup.com/owa/14.3.169.1/themes/resources/clear1x1.gif CONTENT={{!COL5}}