unable to configure sikuli in eclipse IDE

Asked by Ram

Hi,

I am using Linux machine, i made a simple Android project in eclipse and add sikuli.script.jar file and Junit.jar file.
i wrote basic program :
package com.sikuli;

import org.sikuli.script.*;

public class testSikuli {
        public static void main(String[] args) {
                Screen s = new Screen();
                try{
                        s.click("imgs/spotlight.png", 0);
                        s.wait("imgs/spotlight-input.png");
                        s.type(null, "hello world\n", 0);
                }
                catch(FindFailed e){
                        e.printStackTrace();
                }

        }

}

When i am going to run this program , it is saying that the Failed to launch the sikuliScript. error should be like .png not found...

Please revert ASAP.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

  • by Ram
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- what exactly are the error messages?

--- does Sikuli IDE work on your machine?

--- ASAP enough?

Revision history for this message
Ram (payasiramprakash) said :
#2

Thanks for reply Rai--- few information is added....

yes Raiman, Sikuli IDE is working on my machine, when i am going to run program (above mention) ,it is saying that the Sikuili Script launch to fail.

-- how we can add python library in sikuli IDE script, ,my python library is for reading data from excel/csv sheet.
-- I have pythin library file which will read the data from the mention target.

--My Objective

My objective is to make automation script for download and install the application from given excel sheet, mean it will take app name from excel sheet /.csv sheet and through sikuli script it will open appstore and tap on the download button once the application is downloaded and appear for installation then it will tap on Install button , as android third party apps generally do..

Request---- I am very new in Sikuli, so please help me to do this, it would help me to understand the Sikuli :)

Revision history for this message
Ram (payasiramprakash) said :
#3

it's great to me to do this , and understand the Sikuli in better way..

Please revert me .. as i am keen to make this happen...

Revision history for this message
Ram (payasiramprakash) said :
#4

Hi,

i am running my sikuli program with jave application(Sikuli.exe), it is showing the mentioned error

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

--- i am running my sikuli program with jave application(Sikuli.exe), it is showing the mentioned error
The above snippet is written in Java, which cannot be run in Sikuli IDE (Sikuli.exe). Sikuli scripts are written in Python language.

So again what exactly is the error message you are getting, when doing what?

--- it's great to me to do this , and understand the Sikuli in better way..
The best first step is to have a look through the docs at
http://sikuli.org/docx/
to get a first impression about the possibilities.

--- how we can add python library in sikuli IDE script,
Python libraries can only be added to Sikuli script, when they are either Python only (no native C stuff) or available for Jython.
The xls reader module xlrd (I guess you are talking about this) can be used in Sikuli script (Python only).
Have a look at related posts here.

--- Sikuli-IDE vs. Eclipse
When starting with Sikuli, it is recommended to do the first steps with scripts in the Sikuli IDE (should be started with the contained bat files instead of using the exe).

Then you can decide to move to Eclipse/PyDev (see docs) or even Eclipse/Java, which is really a new game.

If you are not really skilled in Python, but in Java instead, it might be a good idea to start with Java in Eclipse right away (many posts here with tips and solutions)

Revision history for this message
Ram (payasiramprakash) said :
#6

Thanks RaiMan, that solved my question.

Revision history for this message
Ram (payasiramprakash) said :
#7

click( )
click( )
import xlrd,os
def Open_ExcelFile(Filepath):
 ExcelWorkBookObject = xlrd.open_workbook(filepath)
 return ExcelWorkBookObject
def Select_WorkSheet_byName(bookobject, sheetname):
 sname = sheetname.encode('ascii' , 'sheetname')
 ExcelWorkSheetObject=xlrd.Book.sheet_by_name(bookobject,sname)
 return ExcelWorkSheetObject
def Select_WorkSheet_byIndex(bookobject, sheetindex):
 ExcelWorkSheetObject=xlrd.Book.sheet_by_index(bookobject, sheetindex)
 return ExcelWorkSheetObject
def Get_Row(Sheetobject, rowindex):
 rowindex=int(rowindex)
 rw= sheetobject.row(rowindex)
 for col_cnt in range(sheetobject.ncols):
  rw[col_cnt]= Get_Cell_Value_by_index(sheetobject, rowindex, col_cnt)
  return rw
def Get_Row_Count(sheetobject):
 return sheetobject.nrows-1
def Get_Cell_Value_by_Index(sheetobeject, rowindex, colindex):
 rowindex = int(rowindex)
 colindex =int(colindex)
 return sheetobject.cell_value(rowindex, colindex)
def Get_Cell_Value_by_column_name(sheetobj, rowindex, colindex):
 rowindex = int(rowindex)
 spec_col_ind = -1
 for col_cnt in range(sheetobj.ncols):
  tmep_col = sheetobj.cell_value(0, cal_cnt)
  if str(colname) == str(tmep_col):
   spec_col_ind = col_cnt
   break
 if spec_col_ind ==-1:
  errortext = 'column name' +colname +'Not found'
  raise AssertionError(errortext)
 return Get_Cell_Value_by_index(sheetobj, rowindex, spec_col_ind)
if __name__=="__main__":
 fileobj = Open_ExcelFile("D:\\other_Stuff\\test_amazon.xls")
 shtIbj = Select_WorkSheet_byName(Fileobj, "TestSheet")
 print Get_Cell_Value_by_Column_name(shtIbj, 5, "Application URL")

// For loop
///
///

type( , "App name from excel sheet")
click( )
wait( )
find( )
click( )
wait( )
click( )
click( )

it showing error in import xlrd,os..

can you please check the code .. and suggests me, it would graceful to me

--R

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

Could you PLEASE paste the error message !

TALKING only about like "it showing error in import xlrd,os.." does not help.

Where did you put the xlrd folder containing the xlrd module?

Revision history for this message
Ram (payasiramprakash) said :
#9

Hi Rai

Sorry for your inconvenience, but again this code is implemented in sikuli IDE, and python is already install on my machine.

The error message is :

[sikuli] click on (647,424), MOD: 0
[sikuli] click on (606,636), MOD: 0
[sikuli] click on (591,591), MOD: 0
[sikuli] Stopped
[sikuli] An error occurs at line 4
[sikuli] Error message:
Traceback (most recent call last):
  File "/tmp/sikuli-tmp5122004769039663446.py", line 4, in <module>
    import xlrd,os
ImportError: No module named xlrd

Can you please tell me where i should put xlrd folder containing the xlrd module and how i can find xlrd folder

and can you please guide me step by step for eclipse(Helios) in Linux
Till i did--
Made one java project and sikuli_script.jar file.
Add Junit.jar file

Please help :)

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

--- where i should put xlrd folder
look: https://answers.launchpad.net/sikuli/+question/188386
comment #1

--- guide me step by step for eclipse(Helios)
This is like every other Java project.
The only thing: add path-to-sikuli-script.jar to your projects library references
(supposing, that Sikuli IDE is running on your system)

Revision history for this message
Ram (payasiramprakash) said :
#11

Hi RaiMan

I want to test Android application , should i make android project or simple java project.

I installed PyDev pluguin , how i have to run the application.

Can you please send me the demo code for launching the application suppose i want to launch the Google play Store..

I set up with java simple project ...

Please send me the demo code for the same...

Please reply

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

No idea, what you are talking about.

generally I have no "demo code" for android stuff.

Revision history for this message
Ram (payasiramprakash) said :
#13

Hi Raiman,

I wrote a simple code (given is sikuli doc) in eclipse by creating java project. it gives ...

Window utilities loaded
Sikuli vision engine loaded
FindFailed: can not find imgs/panda.png on the screen.
line?, in File?
....
...

Steps :
-- Created a simple java project.
-- Add a scikuli-script.jar file as ref. lib
-- Write a program
-- make a folder (imgs) and a paste a images into it.

Program:
  import org.sikuli.script.*;
public class TestSikuli{
public static void main(String{} args){

screen s= new screen();
try{
s.click("imgs/panda.png",0);
}
catch(FindFailed e)
e.printStackTrace();}}}

Note: I am taking images from printscreen and then i crop it... import it to the img folder in eclipse

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

@ Ram
You should make up your own question, since this is not an Eclipse setup problem!
Already looked at the docs, to understand how Sikuli works and what the features are?

Your problem:
As Sikuli tells you: the image cannot be found on the screen, when your Java stuff is running.
It might be hidden behind the Eclipse window ??
So arrange the windows on your system in a way, that YOU can see the image - Sikuli will then see it as well.

Revision history for this message
Ram (payasiramprakash) said :
#15

Hi Rai,

Thankx ,now am able to configure the program in eclipse and it is executing successfully:

Now i want click on the app which is installed in android phone, i make a reflection of android phone in window through androidscreencast..

when i type
S.click("Google play",0);

the error message is: could not find the Google play..

how i can click on android phone...

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

It is what it says:
The text "Google play" cannot be found in the region S (which I guess means the whole screen).

- 1.
you should restrict the ROI of the screen to the androidscreencast window to get better and faster search results.

-2.
you should start with captured images in the first steps, since the text feature is critical.

To both points there are many tips and tricks around here and the basics are in the docs.

Revision history for this message
Ram (payasiramprakash) said :
#17

Thanks Rai, now i am able to launch the application from phone, now i want to press menu key...

Please share me the idea

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

if "menu key" is something like a shortcut key combination to access a menu entry: what about type() and the Key class???

Revision history for this message
Ram (payasiramprakash) said :
#19

Rai.. i am still unable to run the code through images.. please guide me..

-- Should i use printscreen and then crop it.
-- i saved images in eclipse project and when i am call to images by s.click("/images/Email.png" ,0)

when i run the code it click on the Email.png which is attached in the eclipse project.....

how i can run the code through image base in eclipse

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

If you do not have a proper screenshot tool, just use Sikuli-IDE to shoot and name your images.

The respective .sikuli folder can be used as image folder in your Eclipse project.

Or you copy the images to your project.

Revision history for this message
Ram (payasiramprakash) said :
#21

Thankx Rai,

Script is running successfully , some times it is showing error while operation..

Now i want to implement a data reading function in java, that can read data from excel sheet.

~R

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

--- Now i want to implement a data reading function in java, that can read data from excel sheet.
Sorry, but this is no longer a Sikuli related question.

Look for xls access packages for Java (like xlrd for Python) or convert the xls to a csv and use the standard IO-features of Java.

Revision history for this message
Ram (payasiramprakash) said :
#23

Thanks Rai,

Now i am able to successfully run application using sikuli.

~R

Can you help with this problem?

Provide an answer of your own, or ask Ram for more information if necessary.

To post a message you must log in.