iMacro cannot save extract value to file - imacros

I am trying to save EXTRACT variable data to text file by using iMacro. However, I show the EXTRACT variable with value. Please save this file as .js before you try on iMacros. Thank you.
Show EXTRACT variable value.
iimSet("EXTRACT", "abcde");
iimPlay("CODE: PROMPT {{EXTRACT}}");
Save EXTRACT variable value to abc.txt.
scmd = "CODE:SAVEAS TYPE=EXTRACT FOLDER=/Users/user1/iMacros FILE=abc.txt";
iimPlay(scmd);

make it simple,since you are using javascript anyway, use javascript prompt like this
var ask=prompt("Please enter your name");
iimSet("ask",ask);
iimPlay("code: set !extract {{ask}}\nSAVEAS TYPE=EXTRACT FOLDER=/Users/user1/iMacros FILE=abc.txt");

Related

IMacros Extract, How to extract title from html code using IMacros and RegEx?

I want to extract the title from an HTML code, using Imacros and RegEx, the title is wrapped in some code that I want to filter out, I don't know how to use EVAL neither RegEx, I just found some RegEx that worked with my code, so it extracts the title from other codes,
but I am not sure how to use it with Imacros, appreciate it if anyone knows how to make it work, whether with RegEx or other ways.
Here is the html part:
<a data-test-id="search-guide" href="" title="Search for "skin care routine""><div
class="Jea Lfz XiG fZz gjz qDf zI7 iyn Hsu" style="white-space: nowrap; background-color: rgb(115,
115, 115);"><div class="tBJ dyH iFc MF7 erh tg7 IZT mWe">Routine</div></div></a>
the part from the title I want is: skin care routine
the RexEx part that I use:
title="Search for "([^"]*)"
and here is my Imacros:
TAG POS=3 TYPE=a ATTR=data-test-id:search-guide EXTRACT=href
SET !VAR1 EVAL('s = '{{!EXTRACT}}'[title='Search for "([^']*)"]')
PROMPT {{!EXTRACT}}
I get an error on the EVAL Line:
wrong format of SET command, line 15 (Error code: -910)
OK, I got it working, Here is the working code:
TAG POS=3 TYPE=A ATTR=data-test-id:search-guide EXTRACT=TITLE
SET !VAR1 EVAL("\"{{!EXTRACT}}\".substr(10,100);")
PROMPT {{!VAR1}}
Several "Mistakes" in your Script and Approach indeed...
'EXTRACT=HREF' won't get you anywhere, => simply use directly 'EXTRACT=TITLE' + 'EVAL()' (with 'replace()' if you don't mind keeping the Double Quotes, or 'split()' if you want to get rid of them)...
(Much easier without 'RegEx' anyway...)
(Spell "iMacros" correctly (x5) + Add a Question Mark to your Title (you are not sharing a 'HowTo'...) + Mention your FCI if you need me to "elaborate" in more Details...)

iMacros - Removing HTML Elements

I don't know much about HTML or imacros.
I'm trying to make an imacros script that takes a screenshot of an image on the page, but the website has a navigation bar which when imacros takes the screenshot covers half of the image.
How can I create an imacros script to remove this navigation bar from my screen?
In inspect elements, I can get rid of it by removing:
So how can I remove this in imacros please?
Thank you
Use Javascript for this.
To remove element by ID use this code.
var id = window.document.getElementById("page-container");
id.parentNode.removeChild(id);
Instead of "page-container" put your ID you want to remove
To remove elements by class
Use this:
var collection = window.content.document.getElementsByClassName("Class-name");
Array.prototype.forEach.call(collection, function(node) {
node.parentNode.removeChild(node);
});
It's possible with imacros and url goto as iim script. Or you can use pure javascript as js file in your imacros.
Example with url goto and class name:
URL GOTO=javascript:var<SP>delclass=window.content.document.getElementsByClassName("class<SP>name");Array.prototype.forEach.call(delclass,function(node){node.parentNode.removeChild(node)});

How to replace "()" from extracted text with some other character in Imacros

I want to extract image name and then use the name to save the image
here is the js code that i use
macro += "TAG POS=1 TYPE=SPAN ATTR=ID:txt2ArtikelNr EXTRACT=TXT" + "\n";
...
...
..
macro += "ONDOWNLOAD FOLDER=* FILE={{!EXTRACT}}.jpg WAIT=YES" + "\n";
It works fine until there are brackets () in the image name. In this case it does not download the image.
e.g. If image name A123, it works fine.
If image name A (123), it does not download image
and gives me this error wrong format of SET command, line 4 (Error code: 910)
Thanks in advance
I am using firefox 38.0.5, and imacros addon 8.9.2.1
SET !EXTRACT EVAL("'{{!EXTRACT}}'.replace(/[\\(\\)]/g, '');")
If you want to replace the space sign as well, just add it into the square brackets.
And here is the code for your js-script:
macro += 'SET !EXTRACT EVAL("\'{{!EXTRACT}}\'.replace(/[\(\)]/g, \'\');")' + "\n";

Apex 4.2 capture filepath using file browse item

Apex 4.2 : I want to capture the filepath after browsing and selecting a file using item File browse (WWV_FLOW_FILES). The file is uploaded as a BLOB but all info regarding its original location is missing, as it is replaced by f.i. F12457/<name doc>.docx. When using File Browse (browsing for a document and selecting) however the complete path (f.i. L:\abc\def\document.docx) is shown in the field (although its value then is already F999999/document.docx).
Browser security stops JavaScript from accessing this information
How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?
eg:
$('#P6_FILE').val()
"C:\fakepath\12c_notes.txt"
declare
v_doc varchar2(100);
begin
select :P_DOCUMENT into v_doc from dual;
:P59_DOCNAME := v_doc;
end;

Get number of elements in Imacros

There are 10 li tags in an html. I need the number to use it with a loop in a vbs file.
I tried this simple code but it didn't work, even in firefox extension
URL GOTO=javascript:document.getElementsByClassName('movableListItem').length;
One can try the code below to set the built-in variable !EXTRACT to the number of image tags in a document. And your question is similar.
SET !EXTRACT_TEST_POPUP NO
URL GOTO=javascript:{window.document.getElementsByTagName("img").length}
URL GOTO=javascript:{window.history.back()}
TAG POS=1 TYPE=HTML ATTR=* EXTRACT=TXT
BACK
Imacros can do it but you need to make a loop and catch the first error. It's kinda complicated for just this simple question but in Selenium IDE just do this:
Command: storeCssCount
Target : css=a
Value : n
And that's all. A single line of code