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?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With