Automatically testing UIWebView content with Selenium - testing

I have an iPhone application that contains a UIWebView for rendering certain UI aspects. The UIWebView content communicates with the Objective-C side through NSURLRequests. I'd like to test the UIWebView contents with Selenium so it could be automated.
The problem is the communication with the native side, as this is not supported by Selenium. Therefore, a way is needed to "fake" the Objective-C side. The UIWebView sends requests to a specific (non-existant) URL that are then interpreted by the native code and processed. When running the UIWebView's contents with Selenium, these requests will always fail.
Is there a way to somehow provide support in Selenium that would allow catching these requests and providing a dummy response, or is there a better tool for this?
Preferably, I'd also like to run the Selenium tests with Sauce Labs, or a similar Selenium service, so hacking /etc/hosts is not an option either.

Have you tried Appium? It should allow you to write WebDriver tests that invoke the UIAutomation library.

Related

JMeter Screenshotting

I am able to get a screenshot in my JMeter test scripts using the Selenium chrome web driver. This works, but now I want to get screenshots following an authentication request. Is there a way to capture the screen as displayed in the HTTP request?
I don't think there is, theoretically you could try libraries like this one or this one from JSR223 Test Elements using Groovy language, but I don't think you will get what you want
The main reason is given at JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
HTTP Request sampler downloads only HTML, you won't get any images, scripts, styles, fonts, etc. so even if you try to use the aforementioned libraries you will get a "screenshot" which doesn't have anything in common with how does the page look in reality.

Handle Client side actions through JMeter (NOT through Selenium integration)

The Web Application having a list of features(Client-side actions) and These features are not captured, when I record through Jmeter/Blazemeter (NON-API (NON-HTTP) kinds of Stuff). These actions are handled through Javascript functions and .js file is not displayed in Network Tab.
So, I created the selenium scripts and integrated them with Jmeter. When I run the scripts it opens many browser instances(Headless) and performance stats get impacted.
I have to run this script with 5000 Threads. So Opening up so many browser instances is not an appropriate approach.
How to handle the client-side actions through JMeter?
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So you need to figure out what this "client JavaScript" code is doing and replicate this functionality by:
either using a suitable JMeter Plugin
or writing your own JMeter Plugin
or simulating this client-side JavaScript using JSR223 Test Elements and Groovy language

How to make sure video script in JMeter is actually working? Type a message

I have a url https://www.dummyvideo.com/ As soon as this url is hit, there is a single video which starts playing. When I check on browser, segment is not showing in response. Same is the case in JMeter. I would like to know which protocol should I use for acfor achieving this goal. Also, how do I conclude that if my script is working as I dont see segment response on browser as well as on JMeter.
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
The video is being "played" via JavaScript function call and JMeter doesn't automatically "play" the video as it's not capable of executing JavaScript
Since your URL doesn't lead to the website with the video I can only give general recommendations:
If it's possible to find out the exact URL of the video from the page source you can extract it using a suitable JMeter Post-Processor and add another HTTP Request sampler which will download the video
If the video is in form of M3U playlist you can use JMeter HLS Plugin which parses the playlist and gets media streams out of it
In both cases make sure to add a relevant Timer to simulate the user watching the video before proceeding to next page/iteration

Selenium Jmeter differences on websocket calls

I am researching the differences between Selenium and JMeter and I stumbled across the following statement about Selenium:
Even though WebSocket might be encapsulated into a web session and
affect the browser, the user/Selenium will not realise it. So, we will
use JMeter for testing WebSockets.
which confuses me because even though Selenium can't detect that specific scenario, Selenium still uses a programming language like JAVA, hence you can still use Java to accomplish the same thing JMeter does in this case. Or am I missing something here?
I don't know what you're reading however I would recommend stopping referring this source as they don't really realize what they're talking about.
According to The WebSocket API documentation:
The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
Selenium is browser automation framework therefore you get this WebSocket API support "for free". If you need to perform some custom use cases you can use JavascriptExecutor to call WebSocket object functions.
When it comes to JMeter:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
Therefore JMeter will not trigger any WebSocket-related events unless you use a plugin and manually open connection, send message, read response, etc.

How does Webdriver / Selenium "talk" to your local web browser?

For example with FirefoxDriver, how is it sending out clicks and commands to the firefox instance?
It does this by having a webserver within the Webdriver addon for firefox. The language bindings then do a REST-ish type call to it to get something done, like clicks, typing etc.
You can see the REST-ish interface Here. We call it the Json Wire protocol. We also have more native events via the Advanced User Interactions API. This does more native clicks and typing, at the OS level.
Each language binding takes care of that for you so you dont need to worry about it.