Issue
I've been writing this script on Linux in order to automate some parts of the app that I'm working on. My next goal is to get the login process of the app automated, which amounts to clicking a couple buttons and entering a 6-digit code into a separate login page on a website. We're doing this using a combination of ADB shell scripting and a Python script running the Selenium webdriver for the webpages that need to be logged into and whatnot.
This leaves me where I am at now; I found how to input button presses (or rather the "taps" themselves) at specific coordinates using ADB shell commands, so that's half the problem... however, I was unable to find the command required to grab specifically the contents of a TextView for use in my script; it's for the login flow, so I need it to be assigned to a variable in the script, like you would a directory, if possible ...
(i.e. $TEXTCONTENT=****** where *s are the 6-digit code)
... so it can be used later when Selenium webdriver needs to login and enter the 6-digit code. Is there a specific command I'm looking for in order to grab this?
Solution
You can use uiautomator here. There is a Python package uiautomator that can help:
from uiautomator import device as d
d(resourceId="id/mytextfield").text
Or if you want to do it the more manual way, the screen contents can be dumped to an XML file using adb shell uiautomator dump
. Then you can adb pull
it locally, where your script can then parse the XML for the text.
Answered By - Maurice Lam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.