Skip to content

Instantly share code, notes, and snippets.

@dtmilano
Created May 12, 2018 21:00
Show Gist options
  • Save dtmilano/7e3de1526ad9fa8ae5f06d9e3f96e684 to your computer and use it in GitHub Desktop.
Save dtmilano/7e3de1526ad9fa8ae5f06d9e3f96e684 to your computer and use it in GitHub Desktop.
Culebra Alexa Android script sample
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (C) 2013-2018 Diego Torres Milano
Created on 2018-04-07 by Culebra v15.1.2
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
"""
import re
import sys
import os
from com.dtmilano.android.viewclient import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
kwargs2 = {'ignoreuiautomatorkilled': True, 'autodump': False}
vc = ViewClient(device, serialno, **kwargs2)
vc.dump(window=-1)
vc.findViewWithContentDescriptionOrRaise(u'''Ask Alexa''').touch()
vc.sleep(2)
print '----------------------- Start Conversation -----------------------'
u = 'Alexa, what is the price for bitcoin?'
ViewClient.sayText(u, verbose=True)
vc.dump(window=-1, sleep=10)
print vc.findViewWithTextOrRaise(re.compile('1 Bitcoin is worth.*')).getText()
vc.findViewWithContentDescriptionOrRaise(u'''Close''').touch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment