I want to fill in a form to search.
Some times there may be 0-19 results, it's ok, it works.
But as long as there's a button "next", I'd like to simulate click on it, then save the page as [namefile]-2, [namefile]-3, [namefile]-4 and so on.
Any idea how you would do this?
var macroClickNext;
macroClickNext ="CODE:";
//this is just example of button not like your case
macroClickNext +="TAG POS=1 TYPE=BUTTON ATTR=TXT:Next";
var macroTestNext;
macroTestNext ="CODE:";
//this is just example of the button not like in your case
macroTestNext +="TAG POS=1 TYPE=BUTTON ATTR=TXT:Next CONTENT=EVENT:MOUSEOVER";
var test=false;
while(true)
{
test=iimPlay(macroTestNext)
if (test>0)
{
iimPlay(macroNext)
}
else
{
break;
}
}
In your example this would do the job. It will click the Next button as long as it's on the page. CONTENT:EVENT:MOUSEOVER is a simple event that hovers over a page element. If it's present it will return true , if not it will return false.
Related
Trying to automate gmail account creation using iMacros. Facing problem in selecting Gender and Month.
Tried StackOverFlowSolution but it is not working for me. It reports that the command not found. Is it some version mismatch issue or am I missing something?
Can anybody help me in resolving this?
Pasted below the recording along with this fix for reference.
VERSION BUILD=8340723 RECORDER=CR
URL GOTO=https://accounts.google.com/SignUp?dsh=447577167596141020&continue=https%3A%2F%2Faccounts.google.com%2FManageAccount#FirstName=&LastName=
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:createaccount ATTR=ID:PasswdAgain CONTENT=asdf123
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:createaccount ATTR=ID:BirthDay CONTENT=15
TAG POS=1 TYPE=SPAN ATTR=ID:birthyear-placeholder
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:createaccount ATTR=ID:BirthYear CONTENT=1989
TAG POS=1 TYPE=INPUT:TEL FORM=ID:createaccount ATTR=ID:RecoveryPhoneNumber CONTENT=+919791151088
SET monthNum 7
SET monthSlc EVAL("var s = '{{monthNum}}'; switch ('{{monthNum}}') {case '10': s = 'a'; break; case '11': s = 'b'; break; case '12': s = 'c'; break;} '#\\\\:' + s + '>DIV';")
SET listSlc "#BirthMonth>DIV>DIV:nth-of-type(2)"
EVENT TYPE=MOUSEDOWN SELECTOR={{listSlc}} BUTTON=0
EVENT TYPE=MOUSEUP SELECTOR={{listSlc}} BUTTON=0
EVENT TYPE=MOUSEDOWN SELECTOR={{monthSlc}} BUTTON=0
EVENT TYPE=MOUSEUP SELECTOR={{monthSlc}} BUTTON=0
You could definitely do this with imacros. Just a small workaround for this.
Below is the code
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=ID:HiddenBirthMonth CONTENT=05
TAG POS=1 TYPE=INPUT:HIDDEN ATTR=ID:HiddenGender CONTENT=MALE
You can change the above Hidden Input Field's value, and the Month and Gender will get updated (though it might not be visible for the user)
Cheers!
I just checked and actually they seem use div and not a select to do it.
The change is probably triggered by javascript. But I thing it would be a waste to time trying to go through their's.
I just saw that the month change the attribute aria-posinset="6". Here it is for June. I don't think that you can change one with iMacros.
For the current form, dated 11/1/2018. I did the following and it worked to populate gender and month:
TAG POS=1 TYPE=SELECT ATTR=ID:gender CONTENT=3
TAG POS=1 TYPE=SELECT ATTR=ID:month CONTENT=3
The #3 for CONTENT is just the option number to select. You can change that accordingly.
VERSION BUILD=6060703 RECORDER=CR
URL GOTO=URL
TAG POS=1 TYPE=INPUT:BUTTON ATTR=*
WAIT SECONDS=6
This is the code I'm using for .iim file to click on a button on a website. But I couldn't understand what this code is and what are those tag pos and button attr. When I run this code there's an error like this.
RuntimeError: element INPUT specified by * was not found, line: 3
What is this error and how to tackle it. Please help.
TAG POS=1 TYPE=INPUT:BUTTON ATTR=*
This is a button that submits something. Find that button on web page. Right click on it and select "Inspect Element". Then you will see HTML code of that button.
If it has property name="somename" or id="someid" then you will put
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:somename
TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:someid
i want imacros to go to a specific page
and search for a word then refresh the page and loop search if word is found else move to next step
For this you can use javascript scripting. No one will make you a script like this but here is an example.
var macro;
macro ="CODE:";
macro +="TAG POS=1 TYPE=DIV ATTR=TXT:sometext";
if(iimPlay(macro)>0)
{
//text is there
//do something
}
else
{
//text is not there
}
I am using the concept of imacro to auto fill a form. I have recorded one and got the script.
For eg:-
VERSION BUILD=7601105 RECORDER=FX
TAB T=1
URL GOTO=http://mysite/home.aspx
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:home.aspx ATTR=ID:ContentPlaceHolder1_txtUsername CONTENT=samual
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:home.aspx ATTR=ID:ContentPlaceHolder1_txtPassword CONTENT=sampassword
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:form1 ATTR=ID:ContentPlaceHolder1_btnLogin
TAG POS=1 TYPE=A ATTR=ID:ContentPlaceHolder1_bpo_TabContainer_tbpnl_lnk_address_0
TAG POS=1 TYPE=INPUT:IMAGE FORM=ID:form1 ATTR=ID:Logout
But my actual requirement is on a button click I need to call this macro and each time the form field value may changes. So I need to dynamically pass these new values to the macros. I am thinking like clicking on that button I will pass new value to these script and save this macro and call that macro. But I am not sure is this the way it will work or is it possible to call a macro (like above) from a program that is created using imacro?
Thanks
Thanks a lot for the answer . It gave some insight. But can you explain a bit more. Because I am completely new to the imacro concept.
<html>
<body>
<script type="text/javascript">
function runimacros() {
var iim1 = new ActiveXObject("imacros");
var ret
ret = iim1.iimInit("-fx");
ret = iim1.iimDisplay("Test Macro");
ret = iim1.iimPlay ("testmacro.iim");//this is the macro which I created in firefox and located C:\Users\MyName\Documents\iMacros\Macros\testmacro.iim
ret = iim1.iimExit();
}
</script>
Click to run iMacros</font>
</body>
</html>
Please note that the macro which created(testmacro.iim) is using firefox and it is located in the above location.
I tried the approach 'http://wiki.imacros.net/JavaScript' but is not working. Am I missing something? I tried the above code in Visual studio and made the default browser as IE. Please give any suggestion.
Thanks
You can't call an Imacros program (.iim) from another one, but you can use javascript to call one or more iim files passing one variable:
var ret;
ret = iimDisplay ("optional message to be displayed on the Imacros banner");
var i='input variable'
ret = iimSet("i", i);
ret = iimPlay("myScript.iim");
/* Check for error */
if (ret = 1) {
/* do useful stuff */
}else
{
err = "The following error occurred: "+iimGetLastError();
alert(err);
};
In the macros script:
'this way we pass the variable to the input field
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:ContentPlaceHolder1_txtUsername CONTENT={{i}}
I am trying to use iMacros with Firefox to click an UnFollow button ONLY if this code exist on the page...
<small class="follow-status">follows you</small>
If the above does not exist in the page source then it would run this iMacros code...
TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow
From what I have read, there is no if/else type syntax but you can run Javascript with
EVAL("Javascript code here")
If anyone knows how I could do this I could really use the help
You can trick Imacros to make an If statement, but first you have to SET !ERRORIGNORE YES for this macro. Then:
SET EXTRACT NULL
'if this exist you extract the text(even if you know it)
'if doesn't exist should return error but we turned that off; Extract remains Null
TAG POS=1 TYPE=SMALL ATTR=TXT:follows<SP>you EXTRACT=TXT
SET !VAR1 EVAL("var text=\"{{!EXTRACT}}\"; if(text==\"follows you\") text = \"jibber\";else text = \"UnFollow\";text;")
'this one executes if the text is right, if not should give error but we turned that off
TAG POS=1 TYPE=DIV ATTR=TXT:{{!VAR1}}
Use a javascript file for this
run();
function run() {
var exists = doesElementExist();
alert('element exists? ' + exists);
if (exists) {
iimPlay('CODE: TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow');
}
else {
// do something else here
}
}
// test if element exists
function doesElementExist() {
iimDisplay('looking for small element with class "follow-status" on page');
var code = iimPlay('CODE: SET !TIMEOUT_TAG 1\n'
+ 'TAG POS=1 TYPE=SMALL ATTR=CLASS:follow-status EXTRACT=TXT');
if (code !==1) {
return false;
}
var extract = iimGetLastExtract();
if (extract === '#EANF#') {
return false;
}
return true;
}