monkeyrunner

Appium自动化测试教程-自学网-monkeyrunner间接

徘徊边缘 提交于 2019-12-06 03:18:27
monkeyrunner简介 MonkeyRunner工具是使用Jython(使用Java编程语言实现的Python)写出来的,它提供了多个API,通过monkeyrunner API 可以写一个Python的程序来模拟操作控制Android设备app,测试其稳定性并通过截屏可以方便地记录出现的问题。 官网介绍如下 The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code. With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation. The monkeyrunner tool is primarily designed to test applications and devices at the

How can I pass an Extra to an Android intent using MonkeyRunner?

守給你的承諾、 提交于 2019-12-06 02:13:39
问题 I am trying to test my app using the MonkeyRunner tool. I am trying to add an EXTRA to my activity. The python script executes without error: device = MonkeyRunner.waitForConnection() device.wake() extra = {'MY_EXTRA', True} device.startActivity(component="org.mycompany.myapp/.activity.Show",extras=extra) But when I inspect the intent in my app I do not get the value passed: boolean myExtra = i.getBooleanExtra("MY_EXTRA", false); What am I missing? Am I passing in the intent wrong? Am I

How do I catch SocketExceptions in MonkeyRunner?

断了今生、忘了曾经 提交于 2019-12-06 01:52:54
问题 When using MonkeyRunner, every so often I get an error like: 120830 18:39:32.755:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: display.density 120830 18:39:32.755:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Connection reset From what I've read, sometimes the adb connection goes bad, and you need to reconnect. The only problem is, I'm not able to catch the SocketException . I'll wrap my code like so: try: density = self

Why the MonkeyRunner.waitForConnection() doesn't work in my environment?

蓝咒 提交于 2019-12-06 00:39:59
Script: from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice device = MonkeyRunner.waitForConnection(5,'192.168.6.60:5555') device.installPackage('Douban_Radio.apk') Before it runs: ~/android-sdk-linux_86/tools$adb connect 192.168.6.60:5555 connected to 192.168.6.60:5555 ~/android-sdk-linux_86/tools$adb devices List of devices attached 192.168.6.60:5555 device The output of monkeyrunner: ~/android-sdk-linux_86/tools$./monkeyrunner monkeyrunnerTest.py 110412 18:12:35.017:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception 110412 18:12:35.017

How to tell if screen is on with ADB [duplicate]

丶灬走出姿态 提交于 2019-12-05 22:10:02
问题 This question already has answers here : Obtain screen status using ADB (3 answers) Closed 5 years ago . I am looking to find out whether or not it is possible to determine if the screen is on on an android device using ADB. I need to know this for some tests I am trying to run using monkey runner. Is there a shell command I can enter, and thus include as part of a monkey runner command, that will tell me definitively if the screen is on or off? 回答1: In doing some testing I've found that

cannot use raw_input if monkeyrunner is included in python script

大兔子大兔子 提交于 2019-12-05 21:44:26
I want to input some values in my python script. Part of my code is: import os,sys,subprocess,shlex,time from com.android.monkeyrunner import MonkeyRunner import com.android.monkeyrunner.MonkeyDevice from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder user = raw_input("enter your username") print user When i am executing the code as "monkeyrunner camautoopen.py" Then i can only input username. But i cannot print it. when my code is : import os,sys,subprocess,shlex,time user = raw_input("enter your username") print user and i execute the script as python camautoopen.py ,

Monkeyrunner自动化测试由浅入深(第一节)

自古美人都是妖i 提交于 2019-12-05 17:44:25
(原版)Monkeyrunner自动化测试由浅入深(第一节) 博主原创,请勿转载 第一、相关软件和环境的配置 1、Android sdk下载和配置 2、java jdk下载和配置 第二、Monkeyrunner认识 Monkeyrunner是Android SDK中提供的一个测试工具,存放位置在SDK-tools中,以bat文件存在,即monkeyrunner.bat,双击此文件即启动monkeyrunner(启动是不是很简单,小编之前还以为monkeyrunner是需要何等高级配置) 官方定义(官方地址: http://developer.android.com/tools/help/MonkeyDevice.html ):monkeyrunner工具,其本身提供了一个API来供大家编程啦,用以控制一个android设备或者模拟器,而不用了解这个android及其应用的源码。有了monkeyrunner,我们可以写一个Python(monkeyrunner指定脚本语言,不会没关系,继续看)的程序来安装android程序或者测试包,运行编写好的脚步语言,则通过monkeyrunner则会给模拟器或者真机发送一系列控制事件,并且测试的过程中,还可以自定义重要步骤的截图(代码自动完成)。monkeyrunner的工具的作用是在功能/框架层上测试应用和设备,跑单元测试用例

How to determine whether softkeyboard is shown on the screen - while using monkeyrunner

折月煮酒 提交于 2019-12-05 03:00:14
问题 I am trying to automate few screen clicks and entries using monkeyrunner(using AndroidViewClient ) Whenever there is a edittext in the screen, the soft keyboard is popping up, and if I want to press a button though findViewById, (assuming that this particular button is behind the soft keyboard) fails. Instead of clicking this button, it clicks on some button in the soft keyboard. So as a work around I need to press back key through monkey runner, to hide the soft keyboard. My question is how

How to click a view of android program through MonkeyRunner?

好久不见. 提交于 2019-12-05 02:25:11
I want to use MonkeyRunner to test the compatibility of my android program for a list of devices with different screen resolutions. I need to click a view, but the view is not in the same position for different resolutions. How can I get the position of it or do something else to click it? NEED your help! I know it's a little late, but you can use hierarchyviewer in android sdk to get the view id. Then, in your script, use this: from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice from com.android.monkeyrunner.easy import EasyMonkeyDevice, By device = MonkeyRunner.waitForConnection(

How does Python (or MonkeyRunner) locate imported modules?

痴心易碎 提交于 2019-12-04 20:53:30
Update: Following @dtmilano's suggestion, I added import sys print(sys.path) to the beginning of my MonkeyRunner script. This results in ['e:/path/android-sdk/tools/lib/monkeyrunner.jar:e:\\path\\bbct\\android\\functional-tests', 'E:\\path\\android-sdk\\tools\\lib\\Lib', '/E:/path/android-sdk/tools/lib/jython-standalone-2.5.3.jar/Lib', '__classpath__', '__pyclasspath__/'] At first glance I thought this included the current working directory. However, a closer inspection showed that the output is a list of strings where the first string is 'e:/path/android-sdk/tools/lib/monkeyrunner.jar:e:\