I was wondering if somebody has an idea what Java/Groovy library/tool to use for sniffing, recording and processing HTTP traffic of native apps when running Appium tests ? Does anybody has experience with Browser Mob for that specific case ? Thanks! Best, Daniel
Yes browsermob can be used used with native apps and selenium. We tried many other network sniffing proxies but browsermob works best for selenium.
Can be done in 3 simple steps(not so simple by the way).
Run browsermob from standalone server and get response as har in localhost
Write code to validate your output.
Call browsermob methods in your selenium code to call
Validate the response you got with code you have already written for validation.
Mostly validation involves parsing JSON files as most of https responses will be in JSON format.
If you need help in any specific area of browsermob proxy or selenium or running feel free to ask me.
Related
I'am testing my iOS app, that use internet for getting data. Sometimes internet is unavailable, so I need a way to redirect remote connection to file on my local computer. I'am only need to test api. I have unit-tests with mocks,but they do not solve the problem completely.
I can setup server, and redirect connections to localhost, but I think there is a less complex and more accurate solution. Do you have any ideas?
Thank you.
are you trying to make a Unit Test for remote connection or for method that use a remote connection to get data ?
in case is a remote connection i don't know why you want to test it because for me it's an apple feature.
if because your method use a remote connection to get data, so i think that you have to broke this dependency by mocking the remote connection process and return something that you expect
So the best solution of my problem was to use framework for mocking network traffic: BarricadeKit (MMBarricade).
With this framework I can configure local server in iOS app. Framework will redirect all outgoing network traffic to this server.
Is there a way to mock requests when writing automated UI tests in Swift 2.0. As far as I am aware the UI tests should be independent of other functionality. Is there a way to mock the response from server requests in order to test the behaviour of the UI dependant on the response. For example, if the server is down, the UI tests should still run. Quick example, for login, mock if password failed then UI should show alert, however, if the login is successful the next page should be shown.
In its current implementation, this is not directly possible with UI Testing. The only interface the framework has directly to the code is through it's launch arguments/environment.
You can have the app look for a specific key or value in this context and switch up some functionality. For example, if the MOCK_REQUESTS key is set, inject a MockableHTTPClient instead of the real HTTPClient in your networking layer. I wrote about setting the parameters and NSHipster has an article on how to read them.
While not ideal, it is technically possible to accomplish what you are looking for with some legwork.
Here's a tutorial on stubbing network data for UI Testing I put together. It walks you through all of the steps you need to get this up and running.
If you are worried about the idea of mocks making it into a production environment for any reason, you can consider using a 3rd party solution like Charles Proxy.
Using the map local tool you can route calls from a specific endpoint to a local file on your machine. You can past plain text in your local file containing the response you want it to return. Per your example:
Your login hits endpoint yoursite.com/login
in Charles you using the map local tool you can route the calls hitting that endpoint to a file saved on your computer i.e mappedlocal.txt
mappedlocal.txt contains the following text
HTTP/1.1 404 Failed
When Charles is running and you hit this endpoint your response will come back with a 404 error.
You can also use another option in Charles called "map remote" and build an entire mock server which can handle calls and responses as you wish. This may not be exactly what you are looking for, but its an option that may help others, and its one I use myself.
I am developing a web application with Dart using redstone and polymer
Because Dart allows for server and client side development, I wonder what a good pattern for a web application is (specifically to Dart)
Option 1:
Have a server, say, /bin/server.dart
1.1. get a request there and respond with json
#app.Route("/user/:id", methods: const [app.GET])
getUser(int id) { ... }
have a client, i.e. web/user.html and web/user.dart
2.1 in user.dart make a request to server
2.2 receive json and form a proper user.html
Option 2:
Have a server /bin/server
1.1 get a request there and respond with an html page, similar to
#app.Route("/")
helloWorld() => "Hello, World!";
If in the first case I more or less know (and understand) how to make things work, while i find it really frustrating that I do not take advantage of Dart's server-client code-sharing: I need to encode to and decode back json to get the same data. Is there a way to avoid it?
The second option is much less clear for me: how would I serve a web page in this way? How would I make Polymer do its work?
Answers on the questions in the text and a general explanation of a darty way to develop web apps are very much appreciated.
You can see a Redstone + Polymer application example here: https://github.com/luizmineo/io_2014_contacts_demo
Basically, it works as Option 1: The client and server communicates through a service API, and the data is encoded as JSON. Although, Redstone uses the shelf_static package to serve the client code to the browser as well.
If you prefer, it's also possible to use a server side template engine, such as mustache, to build html pages in the server, although, I think it would be really difficult to integrate that with Polymer.
And finally, you always have to encode the data someway when transferring data between client and server, but this doesn't means they can't share code. They can use the same domain classes, for example. Check out the sample application linked above for more details.
I don't think the option 2 is possible. Polymer depends on dart:html which is not allowed on server side.
I'm currently developing a server that can get data over the internet from specific device i have and log it into a database. Unfortunately I dont have control on the way this device communicate.
Currently I set an IP adress and a port number and the device will open a socket and send a string. I dont really want to develop a server from scratch and i would much prefer to base on a web server. but the data is a plain string and not a full http request.
Is there a way around it using Ruby on rails ? Is it possible to do with other web-server-based technology ?
Thanks a lot
You can use just a regular old ruby socket to receive the string.
Sounds like an application that node.js would be useful for, if you want a pre-made node+rails app which would do what you want check out compound at GitHub mentioned in this article
I have started using the websocket php example in http://code.google.com/p/phpwebsocket/ It works pretty well on localhost but unfortunately, no client other than localhost can connect to the websocket server. And whenever I change the path to something like http://10.27.50.25:8787/client.html, it does not let the client to connect. Does anyone have any idea/sample about how to fix it?
Thanks in advance
Could be a crossdomain problem. Modern browsers prevent access to hosts other than the one where the page loaded from. You can get around it by providing JSON as an output then using jQuery Ajax JSON parsing.