NullPointerException in onMouseEvent

Queries related to T-Plan Robot
Post Reply
JamesPTanner

NullPointerException in onMouseEvent

Post by JamesPTanner » Wed Aug 22, 2012 11:42 am

Hi,
I am using the Robot API for version 3.0.1 to write a intergrated Deployment/test application for our Windows mobile software. When trying to use the mouseDrag() method from an extension of the DefaultJavaTestScript class I get the following error.

Code: Select all

java.lang.NullPointerException
	at com.tplan.robot.scripting.DefaultJavaTestScript.mouseEvent(DefaultJavaTestScript.java:1198)
	at com.tplan.robot.scripting.DefaultJavaTestScript.mouseDrag(DefaultJavaTestScript.java:1872)
	at com.cognitomobile.mobile.automation.DI.RobotInterface.drag(RobotInterface.java:537)
	at com.cognitomobile.mobile.automation.Testing.TW.TWNavigation.enterSystemScreen(TWNavigation.java:149)
	at com.cognitomobile.mobile.automation.Testing.TW.Silver.ScreenSwiping.ExecuteTest(ScreenSwiping.java:22)
	at com.cognitomobile.mobile.automation.Testing.Test.Run(Test.java:73)
	at com.cognitomobile.mobile.automation.Testing.TW.TWTestRunner.test(TWTestRunner.java:130)
	at com.tplan.robot.scripting.interpret.java.JavaTestScriptInterpret.execute(JavaTestScriptInterpret.java:649)
	at com.tplan.robot.scripting.ExecOrCompileThread.run(ExecOrCompileThread.java:58)
I am using the method in the following way:

Code: Select all

mouseDrag(new Point((int) (0.5 * VNCdesktopwidth), (int) (0.5 * VNCdesktopheight)), point, 0, MouseEvent.BUTTON1, clickDelay);
I am hoping that you could explain what I am doing incorrectly because from what I understood in the API documentation this should work.

Thanks

rpes
User
User
Posts: 74
Joined: Thu Oct 29, 2009 5:43 pm
First Name: Robert
Last Name: Pes
Company: T-Plan

Re: NullPointerException in onMouseEvent

Post by rpes » Wed Aug 22, 2012 1:16 pm

The exception reveals that you are calling mouseDrag() on a test script class instance that was not initialized properly with the context (the getContext() method returns null). I suppose that your Java code fails to set the context through the setContext() method on the class instance. Is it the case?

For a description of how an externally called test script must be initialized see the second Java class example in the Java Test Script Basics chapter:

http://t-plan.com/robot/docs/v3.0ee/api ... ml#develop

A lesson for us is that all the methods should throw a meaningful runtime exception in such a case and not an NPE. I'll put this on the wish list and get it scheduled for implementation.

JamesPTanner

Re: NullPointerException in onMouseEvent

Post by JamesPTanner » Wed Aug 22, 2012 2:42 pm

Thanks for your help. That was exactly what I was (not) doing. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest