Headless IE browser automation, tracking site runtime

I need to track the rendering time of my sites for common tasks (Login, Search, etc.). I need something automatic that can simulate user actions on IE and be able to time how long a page will take to render.
Example of automatic execution:

1) open IE browser without browser

2) go to http://google.com

3) enter "stackoverflow"

4) click submit

5) start timer

6) wait for the completion of the rendering results page

7) stop timer

8) Close IE

9) recording results

I need this to run as a scheduled task during server time, without user login.

I was looking for something to help me do this. Does anyone have any experience with this type of thing or know anything that can do this?

+4
source share
4 answers

It depends on what you focus on, functionality or performance.

Functions

When monitoring functionality, you are aimed at automatically ensuring the correct functioning of the web application. Typically, this is a large part of the ongoing integration process - and less than part of production monitoring. This can be done using HtmlUnit, Selenium or WebDriver. HttpUnit is no longer recommended (API is lower-level, JavaScript is not very well supported, less widely accepted, fewer bug fixes and improvements).

HtmlUnit simulates a browser. Thus, you can never be sure that your application behaves exactly the same as in a real browser. This is especially important for complex Ajax applications. This compares to all the minor incompatibilities between FireFox and Internet Explorer. Pros: Headless, easy to understand. Cons: risk of undetected incompatibility.

Selenium remote control real browser. In our installation, we could not use it without a head, especially with Internet Explorer. But if you insert it into a virtual machine, it works without a head. If your application is accessible over the public Internet, you can even use Selenium Grid and the pre-configured virtual machine from Amazon Elastic Cloud EC2. Advantages of Selenium: compatibility in the real world, simple scripting. Cons: Headless only in a virtual machine, overhead for performance, more complicated setup of runtime, modeling stresses of simultaneous users only in the cloud.

Prior to version 1.5, Selenium uses a part of JavaScript called Selenium Core to control the browser. If your application has security restrictions for JavaScript, Selenium may not work correctly.

WebDriver uses a specific interface for each browser, for example. for FireFox, an extension for Internet Explorer Automation Controls. In addition, it uses an operating system, for example. to simulate keystrokes. It is more powerful, reliable and reliable than Selenium Core. Starting with Selenium 2.0, WebDriver is integrated into Selenium. But Selenium 2.0 is still beta.

Performance

You specify the measurement using a timer, and you specify the rendering times. When monitoring the performance of a web application, you want to receive a warning when using the application in real time is no longer possible due to excessive response time.

In this case, you are usually not interested in accurate millisecond results. You can use one of the tools mentioned above. For example, a browser with Selenium Core is slower than a real-world browser, but this is of little relevance for continuous monitoring.

If you absolutely need accurate measurements, none of the above are suitable. You must distinguish between client-side duration and network length plus server.

  • Client side duration is required for rendering HTML and for executing JavaScript. It does not depend on the number of simultaneous users. You can measure it once, for example. with firebug . You do not need to constantly monitor it.

  • The duration of the network plus the server part is necessary to transmit the request to the server, process the request and generate a response and transmit the response to the client. They vary depending on network usage and the number of concurrent users. You can accurately measure and control them, for example, using JMeter . But with complex Ajax functionality, simulating the right client requests in JMeter is a daunting task. Pros of JMeter: accurate measurement, the ability to emphasize the application with many concurrent users. Cons: Limited to Ajax, a lot of effort to create a request.

+11
source

Another option might be Selenium Remote Control (or Selenium in general).

+3
source

One option for silent automation is to use HtmlUnit. Have a look at this link for more information: Using HtmlUnit for .NET to Carefree Browser Automation

+1
source

The following IE port for the PhantomJS browser is currently in beta (v0.2):

http://triflejs.org/

Here is a brief introduction:

enter image description here

The API is the same as PhantomJs, so in the end you can do the following:

// 1. Create Page Object and navigate to Google page = require("webpage").create(); page.open("http://www.google.com", function(status) { if ( status === "success" ) { // 2. Inject jQuery for DOM operations page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() { // 3. Start Timer console.log('Start Timer: ' + (new Date()).getTime()); // 4. Type string and click search page.evaluate(function() { $(("input[type=text")[0]).val("stackoverflow"); $("button:contains('Google Search')).click(); }); // 5. Wait for loading and end timer. page.onLoadFinished = function() { console.log('Load Finished. End Timer:' + (new Date()).getTime()); phantom.exit(); }; }); } }); 
0
source

Source: https://habr.com/ru/post/1345020/


All Articles