UNIT-V
UNIT-V
WinRunner facilitates easy test creation by recording how you work on your
application. As you point and click GUI (Graphical User Interface) objects in your
application.
WinRunner generates a test script in the C-like Test Script Language (TSL). We can
further enhance our test scripts with manual programming. WinRunner includes the Function
Generator, which helps quickly and easily add functions to our recorded tests.
Context Sensitive
Context Sensitive mode records your actions on the application being tested in terms
of the GUI objects you select (such as windows, lists, and buttons), while ignoring the
physical location of the object on the screen.
Every time you perform an operation on the application being tested, a TSL statement
describing the object selected and the action performed is generated in the test script.
This allows you to easily reuse your Context Sensitive test scripts on future versions
of your application.
Analog
Analog mode records mouse clicks, keyboard input, and the exact x- and y-
coordinates traveled by the mouse. Use Analog mode when exact mouse coordinates are
important to your test, such as when testing a drawing application.
Starting WinRunner
To start WinRunner:
After installing the WinRunner on your computer, invoke the WinRunner application
The opening screen of the WinRunner application is displayed, prompting you to select one
of the three options:
To test any application, first we can run the application and understand its operation.
Then, you can invoke WinRunner, again run the application and record the GUI operations.
During the recording mode, WinRunner will capture all your actions, which button
you pressed, where you clicked the mouse etc. You need to work with the application as
usual and perform all the actions to be tested.
Once the recording is completed, WinRunner generates a script in TSL (Test Script
Language). You can run this test script generated by WinRunner to view the results. The test
results will show whether the test has passed or failed.
Step 1: Open a new document: File -> New (or) Select "New Test" from the WinRunner's
Welcome screen.
Create ->Record - Context Sensitive (or) click on the toolbar's "Record" button once,
to record in Context Sensitive mode.
Step 4: Select the application to be tested by clicking on the application's title bar.
Step 6: Once all required actions are recorded, stop the recording.
Create -> Stop (or) Click on the toolbar's "Stop" button to stop the recording
WinRunner generates the script for the recoded actions.
Run -> Run from top (or) press F5 to run the test.
WinRunner executes the generated script and displays the results in the Test Results window.
We will now illustrate using WinRunner to test the "Standard Calculator" application
available on your Windows system.we can invoke the calculator application from the desktop
Start -> Programs -> Accessories -> Calculator. The GUI of the "Calculator"
application is shown in Fig.
The symbols on the buttons of Calculator application represent the following functions:
+: To perform addition
-: To perform subtraction
*: To perform multiplication
/: To perform division
.: Decimal point
sqrt : To find square root of a number
%: To find percent
1/x : To find inverse of a number
MC : To clear the memory
MR : To recall from memory
MS : To save in the memory
M+ : To add to the memory
C: To clear the current calculation
CE : To clear the displayed number
+/- : To give sign to a number (positive or negative)
Backspace: To remove left most digit
To test the complete functionality of the application, we need to generate test cases in
such a way that all the buttons are made use of. We need to generate some test cases which
will give correct output and also some test cases which will give error messages. Table gives
such test cases and the expected output for each test case.
Test Cases and the Expected Output for Testing the Calculater
Test Case #1: To test the Inverse operation (inverse of 4 using 1/x button)
File -> New or Click New option on tool bar or press Ctrl+N
Step 4: Start recording
Create -> Record-Context Sensitive (or) press F2 (or) Click on the toolbar
Click the (Record-Context Sensitive) button on the toolbar of WinRunner as shown in Figure
or Select "Record - Context sensitive" option from the "Create" menu as shown in Figure.
Step 5: Select the Calculator application and start recording the actions. a Click "4" on the
Calculator
Click the "1/x" button on the Calculator to find the inverse of 4.
The result, 0.25 will be displayed on the Calculator.
File-»Save
In the "Save" dialog box that appears, save the test script with name "inverse".
The Results column indicates whether the test has "Passed" or "Failed". The test
results also give useful information such as the name of the test case, the line numbers in the
test script and the time taken for executing the test case.
The "call" function can is used to execute a series of test cases without any user interaction.
The syntax of call function is:
All the preceding test cases can be combined into one file as follows:
Call inverseO; call sqrootO; call clearO; call MultiplayO; call divideO; call add_subtract()
call PercentO; call msjnrO; call maddmrO; call mclearO; call backspaceO;
When you execute this test script, all the earlier test cases are executed in one shot.
The test results screen will be as shown in Figure. As you can see from the table, the
"Details" column gives the various test cases executed. The "Result" column shows whether
the test has passed or failed. The "Time" column gives the time taken to execute the test case.
When you have to retest the application using the same test cases, you can run the script in
unattended mode. You can save the script in a file and run the script at specified time.
This feature of WinRunner is extremely useful for regression testing. When you are
developing the software, you need to run the same set of test cases many times.
Test Script Language(TSL)
1. Analog functions: These functions are used when you record in Analog mode, a
mode in which the exact coordinates of the GUI map are required.
2. Context sensitive functions: These functions are used where the exact coordinates
are not required.
3. Customization functions: These functions allow the user to improve the testing tool
by adding functions to the Function Generator.
4. Standard functions: These functions include all the basic elements of programming
language like control flow statements, mathematical functions, string related functions
etc.
In WinRunner, it takes by default one second to execute the next statement. But
sometimes there may be a case where the WinRunner has to wait for a few seconds to accept
the data from the user or wait till the current operation is completed, before executing the
next statement.
Though, by default, WinRunner takes one second to execute the next statement, it is
possible to change the default time to any desired value.
Changing the value of the "Timeout for Checkpoints and CS Statement" option in the Run tab
of the General option's dialog can do this.
Settings -> General Options.
Step 2: Place the cursor at the point where the test has to be synchronized.Insert a line after
the statement
obj_mouse_click ("Add", 49,12, LEFT);
as our aim is to make the WinRunner application wait till the insertion is over.
Once you select the status message, it inserts the following statement into the test
script: obj_wait_bitmap("ThunderRT6TextBox_4"."Irngl",1);
Step 5: By default one-second delay time will be inserted. Manually change the wait time to
10 seconds as it takes about 10 seconds for the insertion action to be completed.
Once the test script is created, we may sometimes want to check how the test script behaves
for multiple data. This can be done by creating that many number of test cases and by running
each test case individually, which is a very tedious process. In such cases we make use of
Data-Driver wizard. This involves 3 steps.
The Rapid test script wizard is the fastest way of performing the test process. It
systematically opens up all the windows in the application, stores the learnt information in
the GUI Map file and generates the test cases based on the information learnt from the
application.
It is possible to apply these tests only on those applications, which open windows
upon performing some task (like clicking a button, selecting the menu item etc
GUI Checkpoint used to Verify Properties Of objects which has 3 options such as
1. Verify mode: By default it is in verify mode. This mode is used to run the test
script. It compares with the expected and actual values
2. Debug mode:This mode is used to check the values of the variables during runtime
to monitor the variables. The results will be stored in debug folder
3. Update mode: This mode is used to change the expected value that you assigned
during the checkpoint
5.2 LoadRunner
Mercury Interactive’s load runner is used to test the client/server applications such as
database management systems and websites.
Load runner accurately measures and analyzes the performance of the client/server
application.
Load runner creates Virtual users(Vusers). The Vusers submit the requests to the
server. Vuser script is generated and this script is executed for simulating multiple
users
For creating the Vuser script, follow the steps given below:
Step 3: Click the "New Single Protocol Script" button. It displays the list of protocols as
shown in Figure.
Select the "Category" under which the application to be tested falls. In case of our example,
select the "Web (HTTP/HTML)" option and click "OK" button.
Step 3: When you click the "OK" button, it displays the dialog as shown in Figure.
The Virtual user script is divided into 3 sections: Vuser_init, Actions, Vuser_end.
Vuser_init: These actions are performed when the Vuser is loaded or initialized.
Actions: These actions are performed when the Vuser is in "Running" state.
Vuser_end: These actions are performed when the Vuser finishes or stops.
You can select the section before or while the recording is under progress.
Step 4: Select the "Actions" section. Click the »»«<*,« button or select the "Start Recording"
option from the "Vuser" menu as shown in Figure.
Step 5: On selecting "Start Recording" option, it displays the "Start Recording" dialog as
shown in Figure.
This prompts you to enter the "URL" of the application for which the test has to be
performed. Enter the URL and select the "Action" section from the "Record into Action"
combo box as shown in Figure and click the "OK" button.
Note that you need to give the URL based on where you installed the application.
Step 6: LoadRunner now opens the specified URL and a "Recording Toolbar..." appears as
shown in Figure.
LoadRunner is now in the "Recording" mode. Perform the actions that are to be recorded
such as clicking on a link to obtain the weather information for a particular city. Once all the
actions are recorded, stop the recording by clicking the "Stop" button in the Recording
toolbajr.
Step 7: LoadRunner generates the script for the actions that are recorded as shown in Figure.
Vuser Scripts can be generated by using a number of tools such as WinRunner, VuGen,
QuickTest etc. which together form a testing suite of Mercury Interactive Corporation.
Step 10: Once the execution is completed, examine the "Execution log" to see whether the
script ran without errors or not.
Step 11: The test results are displayed in the "Test Results" window, which contains various
sections:"Vuser_init_summary", "Iteration","Vuser_end_summary".
The Results Summary Report is shown in Figure, the Iteration Report is shown in Figure and
Vuser_end Summary Report is shown in Figure
Creating Virtual Users Using Loadrunner Controller
LoadRunner Controller is used to create the virtual users who replace the human users
to test the performance of the application.
By default, it creates 10 virtual users who will access the application simultaneously
and tests the load on the application. It is also possible to increase the number of virtual users.
Let us now create virtual users for the web-based application for which we have
already generated the test script using the LoadRunner Virtual User Generator.
To create the Virtual users and test the performance of the "Weather India" application whose
home page is shown in Figure, follow the steps given below.
Select the "Manual Scenario" option and the required test script from the "Available Scripts"
list and click the "OK" button.
Step 3: From the "LoadRunner Controller Scenario 1" dialog, click the "Generator" button or
select the "Load Generators" from the "Scenario" menu. "Load Generators" dialog is opened
as shown in the Figure.
Click the "Add'' button to add a generator, or double-click the "Status" column o the default
host details, which displays the "Load Generator Information" as shown in Figure.
Host Name refers to the identity of the system. Enter the name of the system in this field.
Select the platform (in case of our example select "Windows") and click the "OK" button.
Step 4: In the "Load Generators" dialog, click the "Connect" button to change the status of
the load generator from "Down" to "Ready" and click the "Disconnect" button to change the
status of the load generator from "Ready" to "Down".
Step 6: In the "Load Runner Controller - Scenario 1" dialog, click the "Add Group" to create
the group for the virtual users. It then displays the "Add Dialog" as shown in Figure.
Enter the group name as "gl", select the host name from the "Load Generator Name" and
select the test script from the "Select Script" list box that has to be tested. Enter the number of
virtual users to be created in the "Vuser Quantity" and click the "OK" button.
Step 7: The Group "gl" will be displayed along with its host name and the number of virtual
users in the "Load Generator Controller - Scenariol" dialog as shown in Figure.
Step 8: Click "Vuser" button to view the virtual users. Initially all the users are in "Down"
State as shown in Figure. Select all the users and right click to select the "Initialize Vuser/s"
option as shown in Figure.
All the Vusers will change their state from "Down" - "Initializing" - "Ready" mode. Now to
run the Vusers, again select all the Vusers, right click and select "Run Vuser/s" or click the
"Run" button. The status of the Vusers will change from Ready - Running - Done. Passed or
Done. Failed.
Step 9: Once all the Vusers complete the execution of the script, it displays which user has
passed the test and which has not, as shown in Figure
If only 5 Vusers are allowed to test the "Weather India" application simultaneously, then all
the Vusers successfully complete the test as shown in Figure.This means that the "Server"
that is processing the requests is not able to take the load of all the 10 users at a time.
Step 10:Click the "Close" button to close the "Vusers" window.
Tools -> Analysis Load Runner internally opens the "Load Runner Analysis". It displays
"LoadRunner Analysis" dialog as shown in Figure.
It automatically displays the list of reports that can be analyzed. You can obtain the following
reports:
1. Running Vusers: Whole Scenario graph lets you monitor the number of Vusers that
are running at a given time.
2. Hits per second: Whole Scenario graph lets you monitor the number of hits (HTTP
requests) on the Web server made by Vusers during each second of the scenario run.
This enables you to follow the amount of load that is generated on the server.
3. Transaction Response Time - Whole Scenario graph lets you monitor the amount of
time it takes for each transaction to be completed. You can see how long it takes for
your customers to log on, search flights, purchase flights, check itineraries, and log
off the system
4. Windows Resources graph lets you monitor the Windows resource usage measured
during a scenario (such as CPU, disk, or memory utilization).
5. Throughput
Step 12: Analyze the results by studying graphs shown in Figure which shows the transaction
summary report.
The Transaction Summary report specifies the number of Vusers that passed and failed the
various sections of the script i.e. Action, Vuser_init,Vuser_end in the form of Bar graph.
gives the Throughput Report. The Throughput Report shows the rate which the Vusers run
the script and produce the test results.
"Running Vusers" report, shown in Figure, describes the elapsed time for each user in mnv.ss
format shows the graph which indicates the number of requests made by user per second1
5.3 JMeter
JMeter is a software that can perform load test, performance-oriented business
(functional) test, regression test, etc., on different protocols or technologies.
Stefano Mazzocchi of the Apache Software Foundation was the original developer of
JMeter.
Apache later redesigned JMeter to enhance the GUI and to add functional
testing capabilities.
JMeter is a Java desktop application with a graphical interface that uses the Swing
graphical API. It can therefore run on any environment / workstation that accepts a Java
virtual machine, for example: Windows, Linux, Mac, etc.
Test Plan
A Test Plan can be viewed as a container for running tests. It defines what to test and
how to go about it.
A complete test plan consists of one or more elements such as thread groups, logic
controllers, sample-generating controllers, listeners, timers, assertions, and
configuration elements. A test plan must have at least one thread group.
This is a plain and blank JMeter window without any additional elements added to it. It
contains two nodes:
Test Plan node: It is where the real test plan is kept.
Workbench node: It simply provides a place to temporarily store test elements while
not in use, for copy/paste purposes. When you save your test plan, Workbench items
are not saved with it.
Elements can be added to a test plan by right-clicking on the Test Plan node and
choosing a new element from the "add" list.
Alternatively, you can load an element from a file and add it by choosing the "merge"
or "open" option.
For example, let us add a Thread Group element to a Test Plan as shown below:
To remove an element, make sure the element is selected, right-click on the element, and
choose the "remove" option.
You can save an entire Test Plan by using either Save or "Save Test Plan As ..." from the
File menu.
You can run the Test Plan by clicking Start (Control + r) from the Run menu item.
When JMeter starts running, it shows a small green box at the right-hand end of the section
just under the menubar.
The numbers to the left of the green box are the number of active threads / total number of
threads. These only apply to a locally run test; they do not include any threads started on
remote systems when using client-server mode.
Step 7: Stop the Test Plan
You can stop your test in two ways:
Using Stop (Control + '.'). It stops the threads immediately if possible.
Using Shutdown (Control + ','). It requests the threads to stop at the end of any
current work.
Thread Group elements are the beginning points of your test plan. As the name
suggests, the thread group elements control the number of threads JMeter will use during the
test. We can also control the following via the Thread Group:
Setting the number of threads
Setting the ramp-up time
Setting the number of test iterations
The Thread Group Control Panel looks like this:
Samplers
Samplers allow JMeter to send specific types of requests to a server. They simulate a
user request for a page from the target server. For example, you can add a HTTP Request
sampler if you need to perform a POST, GET, or DELETE on a HTTP service.
HTTP Request
FTP Request
JDBC Request
Java Request
SOAP/XML Request
RPC Requests
The following screenshot shows an HTTP Request Sampler Control Panel:
Logic Controllers
The following list consists of all the Logic Controllers JMeter provides:
Simple Controller
Loop Controller
Random Controller
Runtime Controller
If Controller
While Controller
Switch Controller
ForEach Controller
Module Controller
Include Controller
Transaction Controller
Recording Controller
Test Fragments
A Test Fragment is a special type of element placed at the same level as the Thread
Group element. It is distinguished from a Thread Group in that it is not executed unless it is
referenced by either a Module Controller or an Include_Controller. This element is purely for
code re-use within Test Plans.
Listeners
Listeners are used to view the results of Samplers in the form of tables, graphs, trees,
or simple text in some log files. They provide visual access to the data gathered by JMeter
about the test cases as a Sampler component of JMeter is executed. Listeners can be added
anywhere in the test, including directly under the test plan. They will collect data only from
elements at or below their level. The following list consists of all the
By default, a JMeter thread sends requests without pausing between each sampler.
This may not be what you want. You can add a timer element which allows you to define a
period to wait between each request.
The following list shows all the timers that JMeter provides:
Constant Timer
Gaussian Random Timer
Uniform Random Timer
Constant Throughput Timer
Synchronizing Timer
JSR223 Time
BeanShell Time
BSF Time
Poisson Random Time
The following screenshot shows a Constant Timer Control Panel:
Assertions
Assertions allow you to include some validation test on the response of your request
made using a Sampler. Using assertions you can prove that your application is returning the
correct data. JMeter highlights when an assertion fails.
The following list consists of all the assertions JMeter provides:
Beanshell Assertion
BSF Assertion
Compare Assertion
JSR223 Assertion
Response Assertion
Duration Assertion
Size Assertion
XML Assertion
HTML Assertion
XPath Assertion
XML Schema Assertion
A pre-processor element is something that runs just before a sampler executes. They
are often used to modify the settings of a Sample Request just before it runs, or to update
variables that are not extracted from response text. The following list consists of all the pre-
processor elements that JMeter provides:
HTML Link Parser
HTTP URL Re-writing Modifier
HTTP User Parameter Modifier
User Parameters
JDBC Pre-processor
Introduction
To
Selenium
1
Table of Contents
1. What is Selenium?
2. Selenium Components
3. Who developed Selenium?
4. Selenium IDE
Benefits of Selenium IDE
Drawbacks of Selenium IDE
5. Selenium RC
6. Selenium WebDriver
Selenium WebDriver Architecture
2
7. Selenium Grid
Features
When to use Selenium Grid
8. 8 Platforms supported by Selenium
Operating Systems
Browsers
Programming Languages
Testing Frameworks
9. Advantages of Selenium
10. Disadvantages of Selenium
11. Advantages of Selenium over QTP
3
What is Selenium?
SELENIUM is a free (open-source) automated testing
framework used to validate web applications across different
browsers and platforms. You can use multiple programming
languages like Java, C#, Python etc. to create Selenium Test
Scripts. Testing done using the Selenium tool is usually
referred to as Selenium Testing.
4
Selenium Components
Selenium is not just a single tool but is a combination of different suites of
software. Selenium has four components.
03 Selenium WebDriver
04 Selenium Grid
5
6
Who developed Selenium?
7
An engineer at ThoughtWorks, he was working on a web
application that required frequent testing. Having realized
that the repetitious Manual Testing of their application
was becoming more and more inefficient, he created a
JavaScript program that would automatically control the
browser's actions. He named this program as the
"JavaScriptTestRunner“.
8
Selenium IDE
9
Benefits of Selenium IDE
It is used to
Has built- No create and
Very use
in test programming execute Test
to use
results experience is cases using
and
reporting required Firefox or
install
module Chrome
browsers
The user
The user The user
can easily
can edit can create
record the
the Test Test Suites.
Test
scripts
scripts
10
Drawbacks of Selenium IDE:
It doesn’t
It doesn’t support error
support iteration handling
statements
Available only
No support for in Firefox and
conditional Chrome
statements Drawbacks
It doesn’t generate
It does not a detailed Test
support Reports summary.
Database testing
11
Selenium RC
12
Selenium RC
13
Selenium RC
14
Selenium RC
15
Selenium WebDriver
16
Selenium WebDriver Architecture
17
Selenium WebDriver Architecture
18
Selenium WebDriver Architecture
19
Selenium WebDriver Architecture
20
Selenium Grid
21
Features
04
Perform cross browser testing.
22
When to use Selenium Grid
You should use Selenium Grid when you want to do either one or both
of the following:
When you run your tests against various browsers, operating systems,
and machines all at the same time. This will ensure that the application
you are testing is fully compatible with a wide range of browser
operating system combinations.
Save execution time of your test suites. If you set up Selenium Grid to
run, say, 5 tests at a time, then you would be able to finish the whole
suite around 5 times faster.
23
Platforms supported by Selenium
Selenium works with different Operating systems, browsers,
programming languages and Testing Frameworks.
Operating Systems:
Microsoft Windows
Macintosh
Linux
Browsers:
Mozilla Firefox
Google Chrome
Internet Explorer
Safari
Opera etc.
24
Programming Languages Testing Frameworks
Java C#.Net – NUnit
C#.Net Java – JUnit or TestNG
Perl Python – unittest, pyunit
Python PHP – Behat + mink
Ruby
PHP
25
Advantages of Selenium
26
Disadvantages of Selenium
27
Advantages of Selenium over QTP
Selenium QTP
Open source, free to use, and free of Commercial.
charge.
Highly extensible Limited add-ons
Can run tests across different browsers Can only run tests in Firefox, Internet
Explorer and Chrome
Can execute tests while the browser is Needs to have the application under test to be
minimized visible on the desktop
Can execute tests in parallel. Can only execute in parallel but using Quality
Center which is again a paid product.
28