Code doesn't work all of the time

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
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
shaves
Posts: 77
Joined: Tue Apr 29, 2008 6:50 pm

Code doesn't work all of the time

Post by shaves » Mon Feb 10, 2014 2:45 pm

I have a macro that goes into a homegrown Web based application and navigates to a specific tab. The macro goes into an items and extracrs some data. Once it gets the data, it closed the item and uses the following code to go to a specfici tab in the application and opens the appropriate tab:

IM = ""
IM = "CODE:"
IM = IM + "TAB T=1" + vbNewLine
IM = IM + "FRAME NAME=menu" + vbNewLine
IM = IM + "TAG POS=1 TYPE=DIV ATTR=ID:title1" + vbNewLine
IM = IM + "DS CMD=CLICK X={{!TAGX}} Y={{!TAGY}} " + vbNewLine
IM = IM + "DS CMD=KEY X=0 Y=0 CONTENT={ENTER}" + vbNewLine

iret = iim1.iimPlay(IM)

The problem is sometimes this opens the appropriate tab but sometimes it doesn't. Does anyone have any suggestion to add to this code to ensure that the tab is opened before the macro moves on to the next step?

Should I add a line for DOWNLOAD_COMPLETE or PAGE_COMPLETE? Would that help?

Thanks for the help.........
chivracq
Posts: 9683
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Code doesn't work all of the time

Post by chivracq » Tue Feb 11, 2014 11:15 am

My 2cts..., if it's a question of time until the new Tab is opened, you can (try to) switch anyway to TAB2, extract some Element that must be present on the Page if the Tab was correctly opened and use that Extract to issue one or several conditional WAIT Statement(s) like I did in this Thread using EVAL():
Re: Any way to "WAIT UNTIL IP CHANGE" OR seomthing?

And if after a certain amount of time, your Tab has still not be opened, you could still reuse that Extract together with EVAL to spit out a "1" or a "0" that you can use for POS={{!VAR1}} in "TAG POS=1 TYPE=DIV ATTR=ID:title1" and/or a "100" or a "0" that you can use for "X={{!TAGX}} Y={{!TAGY}}" so that the click won't do anything if you are already on the new Tab and/or to spit out a "{ENTER}" or "Nothing" to use for CONTENT={{!VAR2}} in "DS CMD=KEY X=0 Y=0 CONTENT={ENTER}"...
(The aim of the game is then to conditionally fire again the Command that will open the new Tab.)

Or you split your Macro in 2 Parts and handle the Check on TAB2 being open from VB before launching the second Part with the Processing on TAB2...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply