Comments (2)
I would do something like this to simplify the use of the API as AndroidViewClient/culebra includes most of the cases:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
from com.dtmilano.android.viewclient import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
kwargs2 = {'useuiautomatorhelper': True}
vc = ViewClient(device, serialno, **kwargs2)
for o in vc.uiAutomatorHelper.findObjects(by_selector='text@$[A-Z].*'):
print(vc.uiAutomatorHelper.getText(o.oid))
This is a simple example based on your request.
Here, we use AndroidViewClient bindings. We request the backend to be CulebraTester2-public by passing {'uiautomatorhelper': True}
to the constructor. Notice that the default backend is adb
, therefore we need to specify we want uiautomatorhelper
(a synonim for CulebraTester2-public) and have the service already running on the device or emulator.
Then, we invoke findObjects
(see API) passing a selector text
with a value starting with $
which is then interpreted as a regular expression.
We loop over the list of objects found and we invoke getText
passing the specific object id.
I run it on an emulator with the Clock as the top Activity to obtain these results:
{'text': 'Alarm'}
{'text': 'Clock'}
{'text': 'Timer'}
{'text': 'Stopwatch'}
{'text': 'Thu, Nov 25'}
If AndroidViewClient does not satisfy your needs my second recommendation would be to use CulebraTester2-client which is the lower level API python client used by AndroidViewClient.
And there's more, if you need bindings for another language other than python you can generate the client from the openapi.yaml spec.
Hope this helps.
Feel free to follow up with more questions here or in Stackoverflow using tag androidviewclient.
Resources
from culebratester2-public.
Thanks, very helpful
from culebratester2-public.
Related Issues (18)
- How to select by index when there is more than one object by same id HOT 3
- install error HOT 1
- Server-start error HOT 1
- CulebraTester2 block Accessibility service for other apps HOT 3
- Android Nougat HOT 11
- Dump via adb HOT 6
- Big delay HOT 6
- <node NAF="true" ... HOT 3
- Unable to start the server HOT 2
- How to perform scroll action HOT 2
- Unable to download artifact. HOT 1
- Does it works on windows os? HOT 3
- Cannot install android-select-device HOT 1
- Why I can not download Culebra Tester and Culebra Tester Instrumentation? HOT 4
- Question regarding CulebraTester2 UI beta availability HOT 1
- Stuck the start server HOT 3
- How to get the code generator HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from culebratester2-public.