Created
September 15, 2017 12:53
-
-
Save knezmilos13/d207ab5600ac1a61d7476752aa494cc4 to your computer and use it in GitHub Desktop.
Trying out monkeyrunner. Not quite getting it, but might find out a use for it in the future.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Imports the monkeyrunner modules used by this program | |
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice | |
import os | |
PROJECT_PATH = 'C:\\Users\\User\\AndroidStudioProjects\\WowStore' | |
SCREENSHOTS_PATH = PROJECT_PATH + '\\screenshots' | |
APK_PATH = PROJECT_PATH + '/app/build/outputs/apk/app-debug.apk' | |
def doStuff(): | |
if not os.path.exists(SCREENSHOTS_PATH): | |
os.makedirs(SCREENSHOTS_PATH) | |
package = 'rs.fsd.wowstore' | |
activity = 'rs.fsd.wowstore.common.main.IntroActivity' | |
runComponent = package + '/' + activity | |
device.startActivity(component=runComponent) | |
MonkeyRunner.sleep(3) | |
result = device.takeSnapshot() | |
result.writeToFile(SCREENSHOTS_PATH + '/intro.png','png') | |
def main(): | |
global device | |
print "waiting for connection..." | |
device = MonkeyRunner.waitForConnection(30) | |
if device: | |
doStuff() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment