Use iMacros to automate pressing a button when it appears?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Thedark7
Posts: 4
Joined: Sat Mar 12, 2011 3:57 pm

Use iMacros to automate pressing a button when it appears?

Post by Thedark7 » Sat Mar 12, 2011 4:04 pm

Here's an example of what I'm trying to do.

On a website, a button will appear on the page. It won't always be there. How could I use iMacros to do this:
Refresh a page until it xan click a button. When it can, it would click the button as well as another one that would appear after it.

Thanks!
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Use iMacros to automate pressing a button when it appear

Post by Daniel, Tech Support » Mon Mar 14, 2011 3:10 pm

Hi

I think the easiest thing to do would be to:

1. Run the macro in a loop
2. Ignore errors (SET !ERRORIGNORE YES)
3. Try pressing the buttons

If the button isn't there, the macro will just continue to the next iteration.

Of course you could also use iMacros Scripting.

Best regards,
Daniel, iOpus Support
Thedark7
Posts: 4
Joined: Sat Mar 12, 2011 3:57 pm

Re: Use iMacros to automate pressing a button when it appear

Post by Thedark7 » Mon Mar 14, 2011 8:40 pm

Thanks. I had a script written in VBScript to do it, but I'm not sure how to click something without using coordinates.

The syntax for iMacros doesn't seem too difficult to make the program. Could I make it click the button without entering the coordinates of where the mouse should click? I want to only enter the button name in HTML instead.

I couldn't record the macro while the button isn't there, right?

Thanks again.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Use iMacros to automate pressing a button when it appear

Post by Daniel, Tech Support » Wed Mar 16, 2011 9:39 am

Hi,

Well, there are 2 options:

1. You can try to catch the moment when the button is there and record it with iMacros, or view the source and put the button name (or id) into iMacros manually, or just try to use the text on the button:

Code: Select all

TAG POS=1 TYPE=INPUT:SUBMIT ATTR=VALUE:TEXT_ON_THE_BUTTON_GOES_HERE
2. You can also use the coordinates (if you're using iMacros Browser or IE) by using the DirectScreen Commands:
http://wiki.imacros.net/DirectScreen_Technology

Example:

Code: Select all

DS CMD=CLICK X=411 Y=434
Best regards,
Daniel, iOpus Support
Thedark7
Posts: 4
Joined: Sat Mar 12, 2011 3:57 pm

Re: Use iMacros to automate pressing a button when it appear

Post by Thedark7 » Thu Mar 17, 2011 9:08 pm

Thanks again.

Because I'm not familiar with the iMacros syntax, here's the general idea of what I want to do. Could you convert the code to something that would work in iMacros? Should be fairly simple and hopefully well-commented.

SET !ERRORIGNORE YES -- ignore errors

while true do -- loop the code
NavigateTo: WebsiteNameHere.com -- load/refresh the website
if (Button_Name_Here) == nil then return end -- if the button isn't there, *keep looping*
else LeftClick:Button_Name_Here -- clicks the button if it is there
LeftClick:Button_Number_Two -- clicks a button that appears after the 1st is clicked
break loop -- stop the loop from running agin
end
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Use iMacros to automate pressing a button when it appear

Post by Daniel, Tech Support » Fri Mar 18, 2011 9:08 pm

Hi,

All you have to do is write the code on the scripting/programming language of your choice and call the following macro in the loop:

Code: Select all

SET !ERRORIGNORE YES
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=VALUE:TEXT_ON_THE_BUTTON_GOES_HERE
WAIT SECONDS 1
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=VALUE:TEXT_ON_THE_SECOND_BUTTON_GOES_HERE
This macro tries to click the first button, if its not there, the error is ignored, if its there, the button get's clicked and the 2nd one gets clicked in one second too.

To run the macro from your code have a look at these 2 wiki articles:
http://wiki.imacros.net/iimInit
http://wiki.imacros.net/iimPlay

Basically these 2 commands (iimInit and iimPlay) are the only ones you'll need to run the macro from your code.

Best regards,
Daniel, iOpus Support
Thedark7
Posts: 4
Joined: Sat Mar 12, 2011 3:57 pm

Re: Use iMacros to automate pressing a button when it appear

Post by Thedark7 » Sat Mar 19, 2011 2:02 am

Thank you very much, the code you posted looks great. But wouldnit repeatedly refresh the page?
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Use iMacros to automate pressing a button when it appear

Post by Daniel, Tech Support » Mon Mar 21, 2011 7:37 am

Hi,

Not unless you add a URL GOTO statement. So I suggest you 1st go to that page and then run the macro.

Best regards,
Daniel, iOpus Support
dpackham
Posts: 5
Joined: Tue May 07, 2013 10:40 pm

Re: Use iMacros to automate pressing a button when it appear

Post by dpackham » Tue May 07, 2013 11:40 pm

following this I cannot get it to click on a button with the following text on it.

"Click to Re-submit" without the quotes.

is the - throwing it off? can I use a wildcard? like "Click*" or something like that??

Thanks
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Use iMacros to automate pressing a button when it appear

Post by Daniel, Tech Support » Wed May 08, 2013 9:23 am

Hi,

Could you please post your full macro or tell me where I can see that submit button?

Thanks,
Daniel, iOpus Support
dpackham
Posts: 5
Joined: Tue May 07, 2013 10:40 pm

Re: Use iMacros to automate pressing a button when it appear

Post by dpackham » Sat May 11, 2013 3:39 pm

So this is a form that I fill out with time slots. then I click continue with this

TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:Update ATTR=NAME:submit&&VALUE:Continue

I get the second page that has the "Click to Re-Enter" button on it that I need to click with the below HTML info.

<input type="button" value="Click to Re-Enter" onClick="history.go(-1)" id="button2" style="color: maroon; font-size: 10pt; font-weight: bold" name="button2"><br>

this is the HTML code for that button. when I try to use this in iMacros it doesnt work

TAG POS=1 TYPE=INPUT:SUBMIT ATTR=VALUE:"Click to Re-Enter"

with or without the quotes.

using the ID does work

TAG POS=1 TYPE=INPUT:BUTTON ATTR=ID:button2

But i need to catch the button by the text on it.

there is also another button that will randomly pop up on this page that I need to press IF it exists and this one is by TEXT as well and that one says "CLICK TO ACCEPT" and NOT click on the "Click to Re-Enter" button

THanks
dpackham
Posts: 5
Joined: Tue May 07, 2013 10:40 pm

Re: Use iMacros to automate pressing a button when it appear

Post by dpackham » Sat May 11, 2013 3:40 pm

and then LOOP it. reading on looping now :)

I need something external to loop the script right?
dpackham
Posts: 5
Joined: Tue May 07, 2013 10:40 pm

Re: Use iMacros to automate pressing a button when it appear

Post by dpackham » Wed May 22, 2013 3:02 pm

any ideas on searching for the text? maybe it doesn't work because it has a - in it?
dpackham
Posts: 5
Joined: Tue May 07, 2013 10:40 pm

Re: Use iMacros to automate pressing a button when it appear

Post by dpackham » Mon Jun 03, 2013 8:34 pm

ok so searching for text on buttons with <sp> in them works on firefox but NOT chrome. so my workaround is use firefox. bug report on chrome :)

Thanks
Post Reply