Creating Generic Functions with parameterization and calling them from qtp

Asked by swagatsamal2000@gmail.com

Hi
Thanks for your reply.

As I shared with you earlier I am using .exe format to execute sikuli scripts from qtp.

e.g :

from qtp i am invoking command prompt and executing the below line.
"...\Sikuli-IDE.bat" "...\myScript.skl"

Now could you please take out some of your busy time and explain me how to parameterize ?
I can do no changes to a exported .exe sikuli script.

I am not aware of sikuli-IDE-w.bat.

Is it possible to run .sikuli files(without converting the files to .exe) from qtp without invoking sikuli IDE.(I mean the tool).

More Info : When I create my scripts from sikuli IDE, it is saved as .Sikuli folder , after that I try to export the same to a .exe format and execute like the above I mentioned.
This solution will not work for me if I want to make the script dynamic.

Please do explain me or direct me some link to go through.

Regards

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
swagatsamal2000@gmail.com (swagatsamal2000) said :
#1

Say I want to design a function which will click on a User creation button and enter the username and password driven from a excel sheet.

Whole part of the application is web but for this user creation, its a flash application. Now is it possible to create a function which will take username and password as two inputs and perform the action.

Procedure :
My script will run through qtp on the web application.
All the data will be read from an excel sheet .
VBScripting is used.
As soon as it encounters the flash application of User Creation the sikuli function will be called and it will take input as parameters from exccel sheet.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

You can either use the command line interface and hand over the username and password as parameters to the execution of the script using Sikuli-IDE-w.bat (as you already do I guess)

or use the Python modul xlrd (see some posts here) to access the excel sheet from inside the script.

Revision history for this message
swagatsamal2000@gmail.com (swagatsamal2000) said :
#3

Hi
Thanks for your reply.

As I shared with you earlier I am using .exe format to execute sikuli scripts from qtp.

e.g :

from qtp i am invoking command prompt and executing the below line.
"...\Sikuli-IDE.bat" "...\myScript.skl"

Now could you please take out some of your busy time and explain me how to parameterize ?
I can do no changes to a exported .exe sikuli script.

I am not aware of sikuli-IDE-w.bat.

Is it possible to run .sikuli files(without converting the files to .exe) from qtp without invoking sikuli IDE.(I mean the tool).

More Info : When I create my scripts from sikuli IDE, it is saved as .Sikuli folder , after that I try to export the same to a .exe format and execute like the above I mentioned.
This solution will not work for me if I want to make the script dynamic.

Please do explain me or direct me some link to go through.

Regards

Revision history for this message
Best RaiMan (raimund-hocke) said :
#4

--- .skl format
this is not an .exe format (the menu entry "export executable" is misleading), it is simply a zipped version of the .sikuli folder. So if you want to access its contents, simply rename it to .zip and unzip.
This format does not make any sense, if you work on your own. The only convenience is, that if you want to share a .sikuli folder, you might export it and send the .skl file as mail attachment.
So the menu entry might be named better: export portable

Recommendation: forget .skl in your normal work with Sikuli and use the .sikuli instead (.skl is double work).

--- commandline parameters for your script
as shown in the docs at http://sikuli.org/docx/faq/010-command-line.html
there is a command line argument --args (must be the last one of the Sikuli parameters), that can be followed by parameters for your script

This works like this

path-to-Sikuli-IDE.bat -r some-script.sikuli --args parm1 parm2

In your script the parameters are accessible as sys.argv[1] and up (but that is normal Python/Jython).

There is generally an alternative to run your scripts, but this does not accept the --args parameter and hence no script parameters:

java -jar path-to-sikuli-script.jar some-script.sikuli

But it would be possible, to make a command file, that accepts parameters, puts them in a file (e.g. using echo) and you can read the file in your script to get the parameters.

Revision history for this message
swagatsamal2000@gmail.com (swagatsamal2000) said :
#5

Hi Raiman,

Thanks for your reply and it is of great help to me. I am able to pass arguments to my sikuli script.
My question is answered but I need some more clarifications.

1. When I try to run .sikuli from command line it is trying to invoke Sikuli IDE and then it is not migrating to the corresponding script and executing. The execution haults after invoking IDE. But if I execute the same command and use .skl instead of .sikuli -- its working fine and IDE is not invoked.

2. My configuration is Windows 7, installed JRE correctly -- specified the path and SIKULI_HOME environment variables correctly,
Still when I open Sikuli IDE and try to click on find, Exist or any related event - my Sikuli IDE crashes, But when I use Type Event it does not happen.

Could you please let me know any steps to be taken ?

Regards and Thanks in advance,
Swagat R. Samal

Revision history for this message
RaiMan (raimund-hocke) said :
#6

--- The execution haults after invoking IDE when running a .sikuli
The usage is:
Sikuli-IDE.exe -r some-script.sikuli
I guess you missed the -r

--- my Sikuli IDE crashes
from the symptom it is either a Java problem ( must be Java 6) or a path problem.

please run from command line using
Sikuli-IDE.exe -s
and report the (error) printout.

Revision history for this message
RaiMan (raimund-hocke) said :
#7

... and enter the command set on command line and paste the printout (your environment settings)