cannot use raw_input if monkeyrunner is included in python script

大兔子大兔子 提交于 2019-12-05 21:44:26

Are you using Mac OS X? I had the same problem, and I found the fix here: https://code.google.com/p/android/issues/detail?id=56318

I basically needed to swap out Jython with a newer version. Hope that helps!

you can either include the libraries of monkey and write the script by your own in java

import eu.fbk.se.androidmonkey.Monkey;

import android.app.Instrumentation;
import android.content.pm.PackageManager;
import android.test.ActivityInstrumentationTestCase2;
import android.view.Display;

public class MonkeyLoginActivityTest extends ActivityInstrumentationTestCase2<LoginActivity> {

private int NUM_EVENTS = 320;
public MonkeyLoginActivityTest() {
    super(LoginActivity.class);
    // TODO Auto-generated constructor stub
    }
     @Override
     protected void setUp() throws Exception {
             super.setUp();
             setActivityInitialTouchMode(false);

     }

     public void testMonkeyEvent() {
             Display display = getActivity().getWindowManager().getDefaultDisplay();
             Instrumentation inst = getInstrumentation();
             PackageManager pm = getActivity().getPackageManager();

             Monkey monkey = new Monkey(display,"com.wisemoo.tickleboards.dev.activities", inst, pm);



             // Generate and fire a random event. 
             for (int i = 0; i < NUM_EVENTS; i++) {
                 monkey.nextRandomEvent();
             }

     }

     @Override
     protected void tearDown() throws Exception {
             super.tearDown();
     }

    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!