Search code examples
c#androidproxyappiumbrowsermob

Capture network traffic through proxy with Appium and C#


I have spent a lot of time browsing for a solution to my problem: I am testing an Android app and will be testing the same app on iOS too very soon, using Appium and C#. My app receives response from the server, which I would want to go through a proxy so that I can sniff as part of my NUnit test to ensure that the response returned from the server is correct and compare it with the response I receive on the app (through SDK).

I understand I can use BrowserMob (using Automated Tester C# library) to do this on desktop browsers using Selenium but I cant find any info for doing this using Appium. 1. Firstly, is it possible to sniff network traffic going to the mobile app? 2. Are there any other possibilities that I should consider to achieve my goal?

I want the response to pass through the proxy so that I can assert my tests at run time. Please help/suggest.


Solution

  • I was able to do this using FiddlerCore library. A lot of usage documentation can be found here: Rick Stahl's web log

    Configured fiddlerCore to constantly listen on port 8888 and loop back address and starts running when my test is started and interecepts the traffic going to or coming from the server.