[Sikuli Java API] Getting null pointer exception if i use muliple ScreenRegion in one test method

Asked by Gnanadeep

Hi,

I am writing a sample test method for 7-zip software to zip a folder. When i exexute the method i am getting "NullPointerException". How to use 2 ScreenRegions in one test method. Please help me.

Below is the test method :

@Test
  public void f() throws FindFailed {

 ScreenRegion s = new DesktopScreenRegion();
   Target target = new ImageTarget(new File("C:\\Users\\gnanadeep.bitra\\Desktop.sikuli\\7zip.png"));
   ScreenRegion r = s.find(target);
   Mouse mouse = new DesktopMouse();
   mouse.click(r.getCenter());

   Target target1 = new ImageTarget(new File("C:\\Users\\gnanadeep.bitra\\Desktop.sikuli\\sensoricon.png"));
   ScreenRegion sensorregion = s.find(target1);
   mouse.click(sensorregion.getCenter());

  }

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

*** recommendation for issues with Sikuli Java API:
pls. post on
http://code.google.com/p/sikuli-api/issues/list
which is the direct access to the developers.

Revision history for this message
Sridevi K (ksdevi99) said :
#2

Hi,

I too see the same error. NullPointerException on mouse.click(ScreenRegion.getCenter()); Could somebody please provide a solution?

Revision history for this message
Sridevi K (ksdevi99) said :
#3

Update: I was able to solve that issue by adding some sleep time before find and click. So, for the question above, add Thread.sleep(1000); after the first click.

Can you help with this problem?

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

To post a message you must log in.