Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CodeFest 2018. Rajdeep Varma (badoo) — Applicat...

CodeFest 2018. Rajdeep Varma (badoo) — Application Backdoor via Appium

Посмотрите выступление Rajdeep: https://2018.codefest.ru/lecture/1276/

There's a shift towards open-source mobile test automation tools happening today among developers and QAs. Whether it be Appium, Calabash or anything else: all are good, with some major limitations. While a chosen tool may work well when you first start using it, things can quickly get out of hand with changing business requirements. We started using Calabash at Badoo when there was no Appium. Given the capability of Appium to drive the whole device, we started automation of new apps with Appium. However, we realized a powerful feature was missing in Appium for Android! : The ability to call Application code from automation code like Calabash Backdoors. As Appium UiAutomator server is based on instrumentation, we modified it such that we could instrument our app under test. This gave us the power to access context of Application under test and invoke public methods of Activity using reflection APIs. We use these methods to setup app state, seed DB OR even enable/disable some client-side A/B tests. This makes our application more testable and our tests more predictable. This talk is going to be about how I achieved the above solution and benefits of backdoors.

CodeFest

April 09, 2018
Tweet

More Decks by CodeFest

Other Decks in Programming

Transcript

  1. • Common issues in Mobile test Automation • Solution —

    Backdoors (CheatCodes !) • Demo • How we use Backdoors at Badoo Agenda
  2. Problem #3 • Firstly, Login takes 30 seconds • And

    Then dismissing “What’s new” takes another 30 sec • I don’t want to repeat this in each test Our tests are so slow.
  3. public class LoginActivity extends Activity {
 
 public void foo()

    {
 // code to set some app state // Or seed DB before test // Or Disable ‘Rate Us’ popup
 }
 }
  4. public class LoginActivity extends Activity {
 
 public void foo()

    {
 // code to set some app state // Or seed DB before test // Or Disable ‘Rate Us’ popup
 }
 } Imagine foo() can be called from automation code def invoke_foo backdoor('foo') end
  5. • Change Backend URLs • Change App Locale • Getting

    session_id from app • Disable “What’s new” tutorials after login Where do we use Backdoors?
  6. • Disable client side A/B tests • Faking SIM card

    for payments • Get Analytics data from app to validate it Where do we use Backdoors?
  7. Appium Client AppUnderTest apk J S O N W P

    Android Device Automation Code androidTest apk Uiautomator2Server apk
  8. Appium Client AppUnderTest apk J S O N W P

    Android Device Automation Code androidTest apk Uiautomator2Server apk Instrumentation UiAutomator2
  9. Appium Client AppUnderTest apk J S O N W P

    Android Device Automation Code androidTest apk Uiautomator2Server apk Instrumentation UiAutomator2
  10. Appium Client AppUnderTest apk J S O N W P

    Android Device Automation Code UiAutomator2 androidTest apk
  11. Appium Client AppUnderTest apk J S O N W P

    Android Device Automation Code UiAutomator2 androidTest apk Instrumentation
  12. $ gem install 'appium_instrumenter' $ appium_instrumenter instrument my_app.apk $ adb

    install appium-uiautomator2-server-debug- androidTest.apk $ adb install appium-uiautomator2-server- v0.3.0.apk
  13. On Client side.. curl -X POST -H "Content-Type: application/json" http://localhost:<forwarded_port>/wd/hub/

    session/:sessionId/backdoor -d '{"methods":[{"name":"<method>", "args":["<method_arg>"]}]}'
  14. On Client side.. def backdoor(*args) url = "http://localhost:#{FORWARDED_PORT}"+ “/wd/hub/session/:sessionId/backdoor" body

    = {'methods' => args}.to_json # code to post data end backdoor({name:”methodName",args:["Arg"]})
  15. Quiz 1. Add a backdoor method to change refersh interval:

    changeRefreshInterval(time) 2. Add a backdoor method to refresh weather refreshWeather() Weather refresh every 30 min. How will you test this case?