Archive for May, 2009

Using WatiN to test browse Yahoo mail.

May 27, 2009

Summary:

The objective of this exercise is to compare testing of a web site (Yahoo Mail) with WatiN to the test previously done with AutoIt:

Automating Internet Explorer with Auto It. (Windows Tasks Automation software)

The first major advantage is the availability of the Test Recorder. This Test Recorder is able to get the names or id’s (and other properties) of the IExplorer. The Test Recorder is available from: http://watintestrecord.sourceforge.net/ A big plus is that it can generate source code in VB.NET. (The beta 2 version is not generating C# code at the moment)

TestRecorderSmall

Note: the note in red in the above capture: “Scripting to VB.Net and copying to clipboard.”

I modified the example shown in: http://watin.sourceforge.net/gettingstarted.html in order to have the code in C# to access http://mail.yahoo.com, login, and click on Mail.

I have a video that shows the recording process and the code generated using the Test Recorder:

Notice that the example is done with Visual Studio 2003. Since I used Visual Studio Express 2005 there is a minor difference: when adding the Reference to the Project, I needed to click on the Browse tab.

During this exercise I came across the need to address the log-in button in Yahoo but it was not obvious how to invoke it. Then I ran the recorder, compiled the script to VB.Net Console and then copied the results to the console. The button I needed was: Button btn_save = window.Button(Find.ByName(“save”));

Since I am using the C# version I coded the call to the button as:

ie.Button(Find.ByName(“.save”)).Click();

Notes:

1. A useful tool to find out the names, id’s, etc of IExplorer fields is the ie developer toolbar.

2. Here is the C# code:

//**WatiN example**
// Adapted by Omar Flores
//
using System;
using WatiN.Core;
using System.Threading;

namespace WatiNGettingStarted
{
class WatiNConsoleExample
{
[STAThread]
static void Main(string[] args)
{
// Open a new Internet Explorer window and
// goto the google website.
IE ie = new IE(“http://www.mail.yahoo.com”); //(“http://localhost/”);

// Find the search text field and type Watin in it.
ie.TextField(Find.ByName(“login”)).TypeText(“yourUserID”);
Thread.Sleep(2000);

// Find the search text field and type Watin in it.
ie.TextField(Find.ByName(“passwd”)).TypeText(“yourPassword”);
Thread.Sleep(2000);

// Click the Google search button.
ie.Button(Find.ByName(“.save”)).Click();
Thread.Sleep(1000);

// Click the Google search button.
ie.Button(Find.ById(“global_check_mail_top”)).Click();
Thread.Sleep(1000);

// Uncomment the following line if you want to close
// Internet Explorer and the console window immediately.
//ie.Close();
}
}
}

Advertisements

Load / Stress Testing Using Pylot ver. 1.24.

May 15, 2009

Summary:

Load testing in a web server has been performed in order to find out if response times meet requirement.

The load test was carried with one user using a python script that sends requests every 110ms over a time span of 1hour.

In order to have multiple users, an open source package called pylot was used. This python bases web testing tool allows to have multiple virtual users through the use of threads.

The Results show that the web site visited: gmail behaves rather well though occasional spikes in the response time are seen.

Notice the spike that shows in the 42nd attempt.

The script used can be found in:

https://florespino.wordpress.com/2009/03/26/load-testing-a-web-server/

Using Pylot – an open source python package.

The use of open source is considered below. The program can be found in: http://www.pylot.org/

Version recommended: 1.24.  Although the results below show version 1.22, a defect in version 1.22 caused the reports to fail if the web site experienced a time-out.  This has been corrected in ver 1.24.

The following sample run has been done using the following Test parameters:

number of agents: 1

test duration in seconds: 60

rampup in seconds: 0

interval in milliseconds: 500

test case xml: c:\tmp\testcase.xml

log messages : False

The process can be started with the graphical user interface, which is invoked with the –g at the end of the python command:

C:\Tmp\pylot_1.22\pylot_1.22>python run.py -g.  Notice that the test case is specified in the file test cases.xml, which is located in the pylot_1.22\pylot_1.22 folder.

Pylot – GoogleMail Performance Results

report generated: 05/06/2009 12:08:06
test start: 05/06/2009 12:07:06
test finish: 05/06/2009 12:08:04

Workload Model

test duration (secs)

58

agents

1

rampup (secs)

0

interval (millisecs)

500

Results Summary

requests

35

errors

0

data received (bytes)

643637

Response Time (secs)

Throughput (req/sec)

Frame1

Frame2

Response Time

Throughput

Timer Groups – Response Times

Timer Group

Count

avg

stdev

min

50th %

80th %

90th%

95th %

99th %

max

default_timer

35

1.711

0.561

1.395

1.505

1.603

2.626

2.895

4.010

4.010

Agent Details

Agent

Requests

Errors

Bytes Received

Avg Response Time (secs)

1

35

0

643637

1.711

Fastest Responding Requests

Request URL

Avg Response Time (secs)

http://mail.google.com/mail/#inbox

1.711

Slowest Responding Requests

Request URL

Avg Response Time (secs)

http://mail.google.com/mail/#inbox

1.711

Using three agents:

Notice how the Response Times are higher, as well as the throughput:

Response Time

Throughput

Ramp-up time

The following is an example that introduces the concept of ramp-up time1.

Pylot – Web Performance Results

http://www.pylot.org/samples/results/results.html

report generated: 08/10/2007 12:19:58
test start: 08/10/2007 12:09:58
test finish: 08/10/2007 12:19:57

Workload Model

test duration (secs)

600

Agents

10

rampup (secs)

600

interval (millisecs)

0

Results Summary

Requests

2202

Errors

0

data received (bytes)

87285078

Response Time (secs)

Throughput (req/sec)

Frame3

Frame4

Response Time

Throughput

Agent Details

Agent

Requests

Errors

Bytes Received

Avg. Response Time

1

484

0

19185276

1.24

2

408

0

16172712

1.32

3

340

0

13477260

1.41

4

278

0

11019642

1.51

5

223

0

8839497

1.61

6

169

0

6698991

1.77

7

128

0

5073792

1.86

8

89

0

3527871

2.01

9

57

0

2259423

2.10

10

26

0

1030614

2.30

Appendix:

Other sample discussions:

On Automating Windows Tasks

Using sqlite to convert a csv file to a database, and viceversa!

Uninstalling Microsoft Sharepoint Services x64

1  Ramp-up Time:

To find out if your hardware is robust enough to handle a certain number of users simultaneously accessing the application, you want to do a stress test. A stress test progressively increases the load of the application to discover the different breaking points  -ref: http://java.sys-con.com/node/782824/mobile

The test results should answer the following questions:

* How many users can the application handle while maintaining an acceptable response time?

* What is the load threshold above which the server begins to generate errors and/or refuse connections?

* Does the server remain functional under high load or does it crash?

To do a stress test, testers should ramp up the load, starting from normal and up to the maximum predicted limit, and monitor the response times and error rates. A sudden change indicates that a threshold has been passed.

Automating Internet Explorer with Auto It. (Windows Tasks Automation software)

May 7, 2009

Summary:

This article presents the automation of browsing using Internet Explorer and a commercial email provider: Yahoo.

Auto It was used to:

1. automatically start Internet Explorer,

2. login to Yahoo (if the user was not using the option auto-login) via sending key strokes,

3. and then to open the Inbox using the mouse.

Introduction:

Auto It is a free-ware application: http://www.autoitscript.com/autoit3/downloads.shtml

It has a set of functionality that can be readily deployed, i.e., a utility that provides the windows’ names, mouse coordinates, etc.  The caption is shown below:

AutoItWindowDetection

To start a program we issue the command: Run(“C:\Program Files\Internet Explorer\iexplore.exe”)

Since automation is accomplished using the windows’ names, the window name is used:

WinWaitActive(“Google – Windows Internet Explorer”)

The script is shown at the end.

Brief description of the script:

Two functions have been defined: login() and go2inbox().

The login function waits until the Yahoo! Mail window is active and then sends keystrokes (user id, tab, password, tab, enter) in order to access the email provider.

The go2inbox also waits until the Yahoo! Mail window is active and then it controls the mouse and directs it to the coordinates specified with:

MouseClick(“left”,45,505,1)   –Notice that the IExplore window must be maximized.

Notes:

Handling the active windows takes the following into consideration:

1. If some windows have similar title but not exactly the same, and still they need to be considered as the same (Yahoo! Mail is common for login and for inbox.  But the exact names differ.  Auto It provides a way to use a substring of the name)

2. If tabbing doesn’t work in a certain window, mouse click is the alternative.

3. When browsing some window the info doesn’t appear immediately.  It is advisable to use the sleep function with a time of 5 seconds to ensure the needed control is available.

Script:

; AutoIt Version: 3.0
; Language:       English
; Platform:       WinXP
; Author:         Omar Flores (omar.flores.i.t@gmail.com), modified from an example by Jonathan Bennett (jon@hiddensoft.com)
; Script Function:
;   Opens IExplorer, types mail.yahoo.com, logs in, checks the inbox.
;
Opt(“WinTitleMatchMode”, 2)  ;match substring of window

; Prompt the user to run the script – use a Yes/No prompt
$answer = MsgBox(4, “AutoIt Example (English Only)”, “This script will run IExplorer, browse to YahooMail, login and check the Inbox.  Run?”)

; Check the user’s answer to the prompt (see the help file for MsgBox ;return values),If “No” was clicked (7) then exit the script
If $answer = 7 Then
MsgBox(0, “AutoIt”, “OK.  Bye!”)
Exit
EndIf

; Run IExplorer
Run(“C:\Program Files\Internet Explorer\iexplore.exe”)

; Wait for the IExplorer to become active – it is titled “Google – Windows Internet Explorer” on English systems
WinWaitActive(“Google – Windows Internet Explorer”)
Sleep(1000)
send(“{tab 11}”)  ;to be in the url location

Sleep(2000)
Send(“mail.yahoo.com{Enter}”)   ;type the yahoo mail url

login()   ;if the yahoo user has signed out, then login will sign in.
copymail function
go2inbox()

Func login()
WinWaitActive(“Yahoo! Mail”)
if WinExists(“Yahoo! Mail: The best web-based email! – Windows Internet Explorer”) then
Send(“florespino”)
Sleep(1500)
send(“{TAB}password”)
sleep(2500)
send(“{TAB 2}{Enter}”)
endif

EndFunc

Func go2inbox()
WinWaitActive(“Yahoo! Mail”)  ;WinWaitActive(“Yahoo! Mail”,3) didn’t work, I removed the 3.
if WinExists(“Yahoo! Mail”) Then
sleep(5000)
MouseClick(“left”,45,505,1)  ;ONLY worked with full size window!  Otherwise the window always moved.
EndIf
EndFunc

Omar Flores

System Integration Test Engineer

Omar.flores.i.t@gmail.com