Any way to play iim on the firefox which is already open?

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
StockForum
Posts: 1
Joined: Sat Jul 30, 2011 4:52 am

Any way to play iim on the firefox which is already open?

Post by StockForum » Sat Jul 30, 2011 5:05 am

### Work Environment ###
Test OS: Ubuntu 10.04 32bit.
Firefox Version: 3.6.18
iMacros(add-on) Version: 7.3.0.0
Language: Python 2.6
Downloaded: iMacros Scripting Interface for Linux V1.00.

### Question(Problem) We Have ###
We have created 3 firefox profile named Dev1, Dev2, Dev3
What we would like to do is that playing 'test.iim' on the specific profile which is already open.

### Our work procedures ###
First, we open firefox profile called 'Dev3' from a terminal: "firefox -no-remote -P Dev3"

Second, we run a python script to play 'test.iim' on the 'Dev3' profile: Our python script looks like this:
#!/usr/bin/python
import imacros
iret = imacros.iimInit("-fx -fxProfile Dev3", False)
iret = imacros.iimPlay("..file path/test.iim")


The script correctly play the iim; however, it opens a new firefox window to play the iim. We just wonder, "Is there any way to let the iim play on the specific profile which is already open(in this case, Dev3) instead opening a new firefox window to play the iim?"


We appreciate for your any feedback.
With best regards,
Tom, Tech Support
Posts: 3601
Joined: Mon May 31, 2010 4:59 pm

Re: Any way to play iim on the firefox which is already open

Post by Tom, Tech Support » Wed Aug 03, 2011 9:50 am

Hello StockForum,

Please see the following post and add your comments there:

http://forum.imacros.net/viewtopic.php?f= ... =15#p36918
Regards,

Tom, iMacros Support
mlisa
Posts: 3
Joined: Thu Aug 18, 2011 6:45 pm

Re: Any way to play iim on the firefox which is already open

Post by mlisa » Thu Aug 18, 2011 7:55 pm

I have a very similar question but could not figure an answer from the previous replies.
I have a lot of test automation experience with commercial tools like Silk test and Winrunner but I am new to both iMacros and Python, trying to evaluate iMacros for my company.
My environment: Win XP and IE8.
Here is what I try to do:
I run a Python script that opens my application and logs in a user:

# Start my app and log in
import win32com.client
def StartApp():
import win32com.client
w=win32com.client.Dispatch("imacros")
w.iimInit("", 1)
w.iimPlay("App Automation\\App_Login")
if __name__=='__main__':
StartApp()

This starts iMacros browser with my application and works fine.
Next I need to run more Python scripts and recorded iMacros for example, mymacro1.iim, mymacro2.iim and so on to test the application when it is already up and running without opening another instance of the browser and application.
So my first question is: how do I call more iMacros from a python script(s) to continue testing the same instance of my application?
Should it be the same Python script that opens the iMacros browser or can it be a different script?

My second question is: how do I pass a variable value from Python script to my iMacros script?
For example: I have a list with values in Python:
# my code
mylist = ["2137", "2755", "5478"]
for value in mylist:
myVar1 = value
print value
# here I need to pass myVar1 value to iMacros and then play mymacro1 with CONTENT={{myVar1}}
iimPlay("App Automation\\mymacro1")

My efforts failed at this point and my brain got sick :(

Could someone proficient in both Python and iMacros provide an easy to understand answer and code sample for my problem.

Any help greatly appreciated.
Thanks a lot.
Lisa
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Any way to play iim on the firefox which is already open

Post by MattBell7 » Fri Aug 19, 2011 10:56 am

to play extra macros in the browser, just use another iimPlay command.
e.g.
w.iimPlay("App Automation\\App_Login")
w.iimPlay("App Automation\\Test1.iim")
w.iimPlay("App Automation\\Test2.iim")

to pass a variable in use iimSet

e.g.
yourVar="random value"
v.iimSet("macroVarName", yourVar)

then in your macro reference it with {{macroVarName}}
mlisa
Posts: 3
Joined: Thu Aug 18, 2011 6:45 pm

Re: Any way to play iim on the firefox which is already open

Post by mlisa » Fri Aug 19, 2011 5:16 pm

Great help, my scripts work fine that way.
This is exactly what I need.
I was wrong on this part:
yourVar="random value"
v.iimSet("macroVarName", yourVar)

Thanks a lot.

My only question is: is it possible to call more iMacros (Test2.iim, Test3.iim and so on) using different Python scripts (test modules) for the same application instance that is already running without repeating this part:
# Start my app and log in
import win32com.client
def StartApp():
import win32com.client
w=win32com.client.Dispatch("imacros")
w.iimInit("", 1)
w.iimPlay("App Automation\\App_Login")
if __name__=='__main__':
StartApp()

as the w.iimPlay variable value will be lost.
In other words how to let Python know that iMacros is running already and just run another iim.Play(Test.iim) without starting the browser.
I try to avoid long Python scripts and break them into different logical modules (test cases).

Thanks a lot.
Lisa
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: Any way to play iim on the firefox which is already open

Post by MattBell7 » Mon Aug 22, 2011 7:43 am

when you do iimInit you can pass in -false (possible just false) and this will tell the engine to re-use the existing browser. this would save you repeating Macro1, but not the other lines. I don't know much about Python, but could you not pass w around as a variable to reuse in other modules?
mlisa
Posts: 3
Joined: Thu Aug 18, 2011 6:45 pm

Re: Any way to play iim on the firefox which is already open

Post by mlisa » Mon Aug 22, 2011 8:38 pm

Thank you again for your help.
Everything works fine now.

Lisa
Post Reply