Code Monkey home page Code Monkey logo

pythonmonkey's Introduction

PythonMonkey

A python library for writing automatic UI testing tools.

This module is a replacement for the Jython monkeyrunner library that comes with the Android SDK.

monkeyrunner compatibility layer

The monkeyrunner module is (almost) a drop-in replacement for the com.android.monkeyrunner Jython module. There is an issue with python 2 vs 3 language compatibility. The Jython interpreter shipped with the android SDK is quite old, it supports python 2.5.3. This python version does not have any of tbe future compatibility features which came with v2.6 and v2.7. This makes writing code which works both on python 3.x and in the Jython environnent a bit more difficult. Mostly this means, you can not use the print function, and you will have to use sys.exc_info() to access the most recent exception.

To be able to use this module, create a subdirectory com/android, and put a symbolic link to the monkeyrunner.py file there.

Then run your monkey script using:

python3 mymonkey.py

Android sdk tools

monkeyrunner

monkeyrunner is an Android SDK tool which runs Jython scripts in a context which provides access to various device resources.

Google sourcecode:

monkeyrunner uses two tools on the device to accomplish it's tasks: adb and monkey.

To execute a Jython monkeyrunner script, type:

$ANDROID_HOME/tools/bin/monkeyrunner mymonkey.py

monkey

monkey is the tool running on the device providing the UI interaction support for monkeyrunner.

As a standalone tool it can also be used to monkey-test a ui, by sending random taps to it.

Google sourcecode:

adb

adb is the tool for all developer interactions with android devices,

Author

Willem Hengeveld [email protected]

pythonmonkey's People

Contributors

nlitsme avatar rdoverspike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pythonmonkey's Issues

MonkeyRunner.waitForConnection() wakes device from sleep

Not sure if this is intended behavior but every time I reconnect to the device using IE MonkeyRunner.waitForConnection(10) it turns the screen on from sleep (I want it to connect "silently" to my TV).

I tried following the code path but I couldn't figure which part does that, any idea?

BrokenPipeError

My python program uses monkeylib to drive an application on an Android device. It works fine for about 3 hours and then crashes with this trace:

  File "monkeylib.py", line 119, in tap
    res = self.send("tap %d %d" % (pos[0], pos[1]))
  File "monkeylib.py", line 47, in send
    self.sock.send((cmd + "\n").encode('utf-8'))
BrokenPipeError: [Errno 32] Broken pipe

It crashes after running for 3 hours (+/- 1 minute). Is there something about the monkey program that quits after 3 hours that would cause the pipe to break? Any ideas about other processes on the Android that could be interfering? Any tips on a workaround?
Thanks for any advice you can offer.

AttributeError: 'ADB' object has no attribute 'uploadfile'

I am getting following error:

File com\android\monkeyrunner.py", line 351, in installPackage
    self.adb.uploadfile(path, remotename)
AttributeError: 'ADB' object has no attribute 'uploadfile'

on following line:
device.installPackage(path_to_local_apk)

seems symbolic link issue on windows 10

I created The symbolic link targeting monkeyrunner.py and putted inside the com.android folder in my python project but its still saying:
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
ModuleNotFoundError: No module named 'com.android'

please help to sort out this issue i really need Monkeyrunner.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.