62320

cannot use raw_input if monkeyrunner is included in python script

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 , then i get the desired result.

Answer1:

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(); } }

Answer2:

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!

Recommend

  • Google OAuth Webflow Android
  • Java error---cannot find symbol symbol : constructor (seems to be the new keyword)
  • how to do a has_many relation on two tables?
  • Items not showing up in RecycleView from Room database
  • spring JPA CRUD Repository and updating a record
  • The safety of data protected by RSA, in long term
  • IE and Edge flexbox bug?
  • How to focus on a particular portion of an another html page when click on a button or link
  • Android Studio - MonkeyTalk Integration - Issues
  • Python RegEx, match words in string and get count
  • adMob | Extend Banner size?
  • Is storing an OAuth token in cookies bad practise?
  • How to combine two lists together?
  • How can I encode a filename according to RFC 2231?
  • Underlying type for Tuple in Swift
  • java.lang.IllegalStateException: getInputStream() has already been called for this request + Struts2
  • How do I prepend to a stream in Bash?
  • Remove “\\n” from a string, but leave the actual linebreaks?
  • Time taken for Hadoop job to execute
  • Recreate the Oracle DUAL table
  • Initialization section of the package
  • Iterate through permissions on a file in the windows file system in C#
  • How to synchronize two scrollview in Android?
  • Why are “sc.addFile” and “spark-submit --files” not distributing a local file to all workers?
  • Thread synchronization with syncwarp
  • How to add closing tag for canvas in three js rendered Canvas?
  • Converting query results into DataFrame in python
  • VSCode change debug shell to bash on windows
  • Magento site down due to mysql error General error: 1030 Got error -1 from storage engine
  • ASP.NET MVC 2 Preview 2 - display directory list rather than home/index
  • Security issues with PHP's Readfile method
  • onBackPressed() not being executed
  • Email format validation in mvc3 view
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • How to add date and time under each post in guestbook in google app engine
  • Join two tables and save into third-sql
  • Delete MySQLi record without showing the id in the URL
  • coudnt use logback because of log4j
  • Programmatically clearing map cache