Capture network traffic through proxy with Appium and C# - 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.

U can try burp proxy or Charles proxy to sniff the requests through the mobile

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.

Related

How to get the web socket (WS) tab data programmatically?

I want to get information from a web socket running on a website. however since I am not aware of handshaking process I am unable to establish a successful connection to the websocket and retrieve the information being published on the websocket. I assume this falls on the website confidentiality and unless they provide me the documents it is highly unlikely I can get the data directly from the websocket (please correct me if I am wrong).
However since I can view the data from "WS" tab in network section of the chrome (developer mode). I was wondering if there is a way to replicate this programmatically using selenium or any headless browser and I get this information inside my program. my main objective is to get the information using C# however I am open to any other way to get this data.
This is the sample picture of a WS
I have also found this extension "chrome.devtools.network" but I am not sure if it can do the thing I want. I am still searching any advice or help is highly appreciated
With new versions of Selenium webdrive (version 4 - It's beta version) you can create a devtool session of the driver
driver.getDevTools().createSession();
With wich you can send any devtool commands. You should create a web socket event and send the request through it. You can refer this link for Network Domain Chrome DevTools Protocol.
Also, you can use logging preferences properties and intercept performance logs to fetch messages sent and received through websocket.
driver.manage().logs().get(LogType.PERFORMANCE);
I tried the last solution using Java ang get this result for requesting this link
Complete source code is provided here
Note that you should wait until the chrome driver quit. Then in console you'll see the sent and received messages

I can't call API from another PC at the same network

I connected two laptops together with a wi-fi modem.
Laptop1 got the IP 192.168.0.20
Laptop2 got the IP 192.168.0.21
I launched an ASP.Net Core web application on Laptop2 on port 44382.
I turned off both laptops' firewalls.
The result of ping 192.168.0.20 from laptop2
The result of ping 192.168.0.21 from laptop1
When I call my API from the laptop2(localhost) there is no problem and I see the result
The problem is when I call API from laptop1(another laptop), after a long time I see this
I can't find what my problem is.
You're most likely using IIS Express, which doesn't automatically bind everything the way you need for remote access. This answer breaks down what you'll need to accomplish that fairly well, but you may just want to look at installing IIS.
Make sure door 44382 is open in the firewall.
Create new rule in/out for port here (advanced configs of firewall)

What is the best way of communicating from web->web api->console app and back again?

I'm starting up a little code project to learn from the process, but I am not sure what's the best way of communicating between the different parts.
First, I have a pure html/js client where the users need to get live updates frequently.
Secondly, I'm considering having a web api application running to provide data.
Thirdly I have a console application running, that needs to communicate with the web api application.
So I'm thinking about using WebSockets all the way from client->web api->console app, but I have trouble making it work. I can make the console app work as a server, but I can't figure out how to make the web api work as a client, so that when it spins up, creates a connection to the console app, and keeps it open for communication, while it delivers data to the clients upon requests.
I tried with different implementations and I have ended up with SignalR, as it seems like that's what people use today :)
Since I have all these problems getting a connection I am wondering if there are better ways of sending data that fulfills my requirements?
If WebSocket (using SignalR) is the way to go, can you provide some links with working examples? I have tried all the top links from Google with no success ^^
Thanks in advance
Your WebAPI project can act as WebSocket server as well. Check this link that uses an IHttpHandler, but you can also do it in a WebAIP's controller how is explained here : Using WebSockets with ASP.NET Web API
The console application should connect as client, using for example ClientWebSocket class.
WebSockets are persistent full duplex connections, so once the client is connected both ends can push information to the other end.

How to test the WebSocket over head?

I need to test the over head on my WebSocket application. How to test it and see the results?
If you use Fiddler you can track all the communication between your browser and the server using WebSockets. (look in the log section).
This should allow you to get a feel for exactly what the communication looks like, including whatever you have defined as "overhead".
I find the WebSocket pane in Google Chrome's Developer Tools to be great for measuring and debugging WebSocket traffic.

Have Client-Server App, need to create a Client Simulator - ideas needed

We've got a client app which connects using TCP to a server. Additionally, the client app makes use of .NET remoting to talk to another piece of locally running code.
I'm tasked with creating a "Client Simulator" to do some testing, where we'd need to have 100's of clients connected simultaneously to the server. Ideally, this would work out great if I were to run each client in it's own space, such as a VM, but this is not logistically feasible.
Any suggestions on how to handle this? Is there a tool that could do something like this? Or some sort-of .NET concept I could use?
Thanks in advance.
What about stress testing? http://support.microsoft.com/kb/231282
You can do it with Test Edition of Visual Studio: http://msdn.microsoft.com/en-us/vstudio/dd408381.aspx
There is load runner but we found it to be a very expensive piece of shelf ware. We created a server controlled client spawner that could once installed on a machine listen to broadcast message and perform actions on the server. We simulated 3000 + clients very eisly on 10 machines since the clients didn't have to do any processing.
In an old project i worked on, I implemented a set of NUnit tests that executed cookie-less web requestes on a locally running Cassini server.
Each request generated a unique sessions and the session persistence was handled by the unit tests using the session id returned by asp-net on the first response.
The check on the output was handled via regular expressions that verified the presence of well-knowns contents parts.
That was enough for my needs, but maybe you need something more exaustive.

Categories