Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUMA fails on emulator - NullPointerException in dump_screen #1

Open
shauvik opened this issue Oct 19, 2014 · 0 comments
Open

PUMA fails on emulator - NullPointerException in dump_screen #1

shauvik opened this issue Oct 19, 2014 · 0 comments

Comments

@shauvik
Copy link

shauvik commented Oct 19, 2014

Hi @shuai-hao and team,

Good job with Puma. It seems to be a nice tool!

For me, it threw a null pointer exception when running in an emulator (log below).
I fixed it by changing dev.takeScreenshot() to takeScreenshot() function, which seems to be a workaround for the emulator.

Perhaps, a better approach would be to change the screenshot taking strategy based on whether PUMA is running inside an emulator or real device. It seems that a good approach for this is to check if the String returned by UIDevice.getProductName() contains 'sdk', in which case it is an emulator. Seems like this will be easy to integrate.

Cheers!
Shauvik

Original log:

INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
nsl.stg.tests.LaunchApp:
INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=testMain
INSTRUMENTATION_STATUS: class=nsl.stg.tests.LaunchApp
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 1
1413692517161: Traffic: 0
1413692517521: --------------- iter 0
1413692518175: New UIState: [6, 0/4]
1413692518175: UI_LOAD_DONE
1413692518223: Clicking 0
1413692518332: screenshot: FAIL
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
Error in testMain:
java.lang.NullPointerException
    at nsl.stg.tests.LaunchApp.dump_screen(LaunchApp.java:484)
    at nsl.stg.tests.LaunchApp.testMain(LaunchApp.java:379)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at nsl.stg.uiautomator.testrunner.MyUiAutomatorTestRunner.start(MyUiAutomatorTestRunner.java:147)
    at nsl.stg.uiautomator.testrunner.MyUiAutomatorTestRunner.run(MyUiAutomatorTestRunner.java:82)
    at nsl.stg.uiautomator.cmds.MyRunTestCommand.run(MyRunTestCommand.java:73)
    at nsl.stg.uiautomator.cmds.MyLauncher.main(MyLauncher.java:65)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)
    at dalvik.system.NativeStart.main(Native Method)

INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
INSTRUMENTATION_STATUS: test=testMain
INSTRUMENTATION_STATUS: class=nsl.stg.tests.LaunchApp
INSTRUMENTATION_STATUS: stack=java.lang.NullPointerException
    at nsl.stg.tests.LaunchApp.dump_screen(LaunchApp.java:484)
    at nsl.stg.tests.LaunchApp.testMain(LaunchApp.java:379)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at nsl.stg.uiautomator.testrunner.MyUiAutomatorTestRunner.start(MyUiAutomatorTestRunner.java:147)
    at nsl.stg.uiautomator.testrunner.MyUiAutomatorTestRunner.run(MyUiAutomatorTestRunner.java:82)
    at nsl.stg.uiautomator.cmds.MyRunTestCommand.run(MyRunTestCommand.java:73)
    at nsl.stg.uiautomator.cmds.MyLauncher.main(MyLauncher.java:65)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)
    at dalvik.system.NativeStart.main(Native Method)

INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: -1
INSTRUMENTATION_STATUS: stream=
Test results for WatcherResultPrinter=.E
Time: 9.556

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant