How to refresh the page if it is not loaded

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
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
potatoer
Posts: 20
Joined: Sun Mar 21, 2010 4:28 am

How to refresh the page if it is not loaded

Post by potatoer » Tue Jul 20, 2010 10:29 am

Hello
Sometimes a page does not load at first (maybe the internet is lagging or the server etc.)
My question is how to make Imacros refresh the page if it is not loaded, for example it may have this text:

"This program cannot display the webpage
Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address. "

So if Imacros finds it (maybe a with TAG command) then it does REFRESH and if it does not find it then it continues. And it has to this only once, so for example if it does REFRESH and the page doesn't load again it shouldn't REFRESH again
I would like to add this check at every Imacro I have so that they would become a lot more reliable. And since I have a lot of imacroses done already I need help to find the simpliest way to implement it.

PS if this can be achieved only with the use of additional Windows Scripting or programming language then what is the most popular programming language to learn for web based programs ( like Imacros :D )? What would you advise to use for Imacro? I don't know any programming language anyway. Even if it is going to take some time to get into, I think the possibilities it would bring are worth it
potatoer
Posts: 20
Joined: Sun Mar 21, 2010 4:28 am

Re: How to refresh the page if it is not loaded

Post by potatoer » Tue Jul 20, 2010 12:48 pm

Ok so this is what I've came up so far, obviously it doesn't work, but it's a start

the test imacro is

VERSION BUILD=7010818
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=anything
TAG POS=1 TYPE=LI ATTR=ID:causeNotConnected
with this tag i'm trying to see if the page has the default text which says that it doesn't work

the .vbs script is



Set iim1 = CreateObject ("IMacros")
i = iim1.iimInit()


i = iim1.iimPlay("e:\tests\test.iim")


If i > 0 Then
a = "site doesn't work"
MsgBox a
Else
a = "site works"
MsgBox a
End If

MsgBox a

i = iim1.iimExit()


First problem is that the Imacro doesn't even return an error if the tag command fails.
Any other way except imagesearch to check if the site doesn't work?
potatoer
Posts: 20
Joined: Sun Mar 21, 2010 4:28 am

Re: How to refresh the page if it is not loaded

Post by potatoer » Tue Jul 20, 2010 4:23 pm

It seems I've actually managed to make it with no experience in programming languages, found everything with imacros wiki and google :shock:

It is a .vbs file


Set imacros = CreateObject("imacros")
iret = imacros.iimInit()
MyMacroCode = "CODE:"
MyMacroCode = MyMacroCode+"URL GOTO=http://google.com/ " + vbNewLine
MyMacroCode = MyMacroCode+"TAG POS=1 TYPE=LI ATTR=ID:causeNotConnected EXTRACT=TXT" + vbNewLine
iret = imacros.iimPlay(MyMacroCode)

extracted = imacros.iimGetLastExtract
MsgBox extracted
offline = InStr(extracted,"You are not connected to the Internet.")

If offline>0 Then

MsgBox "site doesn't work, Imacros will wait 3 sec and refresh"
MyMacroCode = "CODE:"
MyMacroCode = MyMacroCode+"WAIT SECONDS=3" + vbNewLine
MyMacroCode = MyMacroCode+"REFRESH" + vbNewLine
iret = imacros.iimPlay(MyMacroCode)

Else

MsgBox "site works, Imacros will do cool stuff"
MyMacroCode = "CODE:"
MyMacroCode = MyMacroCode+"TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT=imacros<SP>rocks! " + vbNewLine
MyMacroCode = MyMacroCode+"TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG " + vbNewLine
iret = imacros.iimPlay(MyMacroCode)
End If

The script checks if the page has text "You are not connected to the Internet"
If it is there it waits 3 seconds and does REFRESH
If it is not there it just goes on and does whatever you want (if needed)

Any suggestion how to make it simplier and shorter (if possible) are welcome
Post Reply