Android Automation next level sh****t
Heyo!I’M RAN BEN AHARON
Android & Automation lead @EverythingMe
Pain
Mobile development is not easy
FIXED A TYPO
NOW APP CRASHES IN PRODUCTION
RELEASE DAY
SCARED SHITLESS
DREAMED OFBUILDING APPS
NOW I CAN’T SLEEP
“In order to move fast - you need good brakes
We love open source
at EverythingMe we utilize, create and contribute
Open source Android automation
CostCommunityOur own fork
AppiumCalabashEspressoMonkeyTalkRobotiumSelendroid...
How the big boys do it
ebayCalabash (ruby)
MozillaRobocop (java)
SoundcloudRobotium (java)
FacebookSelendroid (java)
YelpEspresso (java)
GrouponRoboRemote (java)
Struggling to make it work
Gaining and maintaining trust
Distrust and disengagement
Unreliable resultsNot part of the release flowNo visibilityCumbersome tools
Trust and cooperation
Reliable resultsPart of the release flowFull visibilityDelightful tools
We’re hiring anAutomation engineer
?
“
What’s so special about
Yet another UI testing FW?
Fits our needs
FasterLeanerReliable resultsPython goodnessLots of essential test methods
1.Setup was a big hassle
1.Setup was a big hassle
Magneto is easy to install and run
$ pip install magneto
Install
$ magneto run [tests_path]
Run
Boilerplate
$ magneto init [package]
Example test
def test_button(self): # and click button button = self.magneto(text='Click me') button.click()
# scroll list list = self.magneto(className='android.widget.ListView') list.fling.toEnd()
# make sure last item exists last_item = self.magneto(text="last item") Assert.true(last_item.exists)
2.Time sleeps causedflaky results
2.Time sleeps causedflaky results
Magneto is truly ready for async
wait_for_element
wait for an element to appear
# wait for button button = self.magneto.wait_for_element(text=’click’) # make sure it’s there Assert.true(button.exists)
wait for button to appear
wait_for_true
wait for a function to return True
# click button self.magneto(text=’Click me’).click()
# wait for text to change self.magneto.wait_for_true(lambda: button.info[‘text’] != ‘Click me’ )
wait for button text to change
Assert.current_package
wait for package to focus
# tap chrome icon self.magneto(text=’Chrome’).click() # wait for chrome to open Assert.current_package(‘com.android.chrome’)
wait for chrome to open
ADBLogWatch
Tune in to logcat
# install app with ADBLogWatch() as w: w.watch(‘android.intent.action.PACKAGE_ADDED’) ADB.install(‘apps/facebook.apk’) w.assert_done()
# make sure it’s on homescreen app = self.magneto(text=’Facebook’) Assert.true(app.exists)
wait for app to be installed
3.Stats were hard to trace
3.Stats were hard to trace
Using logcat for immediate feedback
# click button with ADBLogWatch() as w: w.watch(‘Stat1 sent’)
self.magneto(text=’click’).click() w.assert_done()
assert stat
# click button with ADBLogWatch() as w: w.watch(‘Stat1 sent’) w.watch(‘Stat2 sent’)
self.magneto(text=’click’).click() w.assert_done()
assert multiple stats
# click button with ADBLogWatch() as w: w.watch(‘Stat sent’,screen=’home’,action=’click')
self.magneto(text=’click’).click() w.assert_done()
assert stat params
4.Failed tests were unclear
4.Failed tests were unclear
Magneto supplies screenshots, videos...
$ magneto run --save-data-on-failure
Save test fail data
$ magneto run --save-data-on-failure --include-video-on-failure
Save test fail data
- 3-test_name-time.hierarchy.uix- 3-test_name-time.screenshot.png- 3-test_name-time.logcat.log- 3-test_name-time.video.mp4
- 12-test_name-time.hierarchy.uix- 12-test_name-time.screenshot.png- 12-test_name-time.logcat.log- 12-test_name-time.video.mp4
Failed tests artifacts
5.Device miscommunication
5.Device miscommunication
Magneto gives you ADB power
ADB.install(apk_path)ADB.uninstall(app_package)ADB.start_activity(app_package, app_activity)ADB.kill_process(app_package)
ADB.exec_cmd(command)ADB.set_date(date)ADB.getprop(prop)ADB.get_log()ADB.clear_log()
ADB power
6.Painful debugging
6.Painful debugging
iMagneto + UiAutomatorViewer
$ imagneto
In magneto(text=”click”).click()In magneto.orientation = “r”
In f = magneto(resourceId=”el”)In f.info
imagneto
Much more!
Skipping, tagging, blockingFragmentation handling
The FUTURE
It’s gonna get osom
Fail on GC
Fail on log > n
Web inspector?
Non-active windows
Docs
Known limitations
○ Android 4.2+○ Sequential UI actions only
FORK and CONTRIBUTE
http://github.com/EverythingMe/magneto
“http://mobileautomators.com
We’re Hiring!
We’re Hiring!Experienced Android Dev
We’re Hiring!Experienced Android Dev
Automation Engineer
THANKS!Any questions?
Top Related