Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I monitor iOS simulator/Android emulator's HTTP traffic from Appium JUnit tests?

So I am writing JUnit tests for iOS/Android apps using Appium to drive the tests on an iOS simulator and Android emulator. The app sends and receives HTTP calls to a remote server. I would like to test that the app is sending the correct HTTP traffic from my JUnit tests. What are some ways that I can monitor the network traffic from within my code?

like image 759
Bruce Tu Avatar asked Mar 16 '16 19:03

Bruce Tu


People also ask

Does Appium support emulators in iOS?

With Sauce Labs, you can run automated Appium tests for your native and hybrid mobile apps against many virtual OS and platform combinations with Android Emulators and iOS Simulators.

Can I run Android Appium test in emulator?

Appium Studio can connect and perform tests on all Android Emulators. The main requirement is for the emulator to be identified by the ADB. Most SDKs require a high-performance machine.


1 Answers

I had the same issue a few months back and tried two solutions for it.

1) Use a proxy in your code. I tried a little proxy. I kind of liked it but it increased my overhead for maintaining little proxy code as well. It works if you have extremely advanced knowledge with proxies; you will be able to handle it. https://github.com/ganskef/LittleProxy-mitm

2) I finally figured out it's best to use Android logcat. Whatever communication our phones do, everything gets logged in logcat. I just needed some commands to filter out the network requests that my App was making. I don't remember all of the commands but it's something like this. I know its not correct, but it will give you a headstart and I am 100% sure someone will correct this.

adb logcat -d | grep com.xyz.abc

like image 50
vishal Avatar answered Oct 17 '22 00:10

vishal