If you have not yet done so, you should complete the Module 05 lab before working on this activity.
Design a small suite of tests for your Web application. This suite should include:
Functional Testing, such as:
· Checking links
· Test Web forms
· Validate CSS tags
· Validate Javascript tags
Database Testing, such as:
· A search that returns a single record
· A search that returns no records
· A search the returns multiple records
Browser Compatibility Testing
· Function with some browser features turned off (e.g., Javascript)
Make sure you add comments to your test scripts to explain what is happening with each test case. Include your name with the comments as well.
Submit your test code files to your instructor as a ZIP file named <first_initial><Last_name>_Mod05Dev.zip. So a student Edith Palka would name her file epalka_Mod05Dev.zip
Module 05 Lab WorksheetBuilding a Test Plan
Lab Activities:· What is Web Application Testing?· Introduction to Selenium· Creating a Test Case: Recording· Creating a Test Case: Scripting· Creating a Test Suite
Introduction
At this point you should have, at minimum:
· An IDE (Integrated Development Environment) for your code
· An SQL administration utility (command-line, desktop or Web-based)
· A MySQL database dbtest.
· A basic Web search form for dbtest that will let the user search by surname
In addition, to complete this lab you will need to have the following software installed:
· Mozilla Firefox (https://www.mozilla.org/en-US/firefox/new/)
· Java (http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
This lab assumes that you have a working knowledge of HTML, CSS and Javascript.
What is Web Application Testing?
Web applications are like any other software. They need to be tested before they are unleashed on the world.
Software testing and test development are normally the subject of an entire course, so this lab is meant to give you an overview and let you experiment with developing your own Web application tests.
There are five basic categories of software tests:
· Functional Testing - Does the application work according to specifications? Does it produce the correct output for a given input? How does it handle errors?
· Compatibility Testing - Does it work with different browsers? Different operating systems? DIfferent hardware?
· Database Testing - Does the information displayed in the application match what’s in the database? Does the database correctly display any updates from the application?
· Security Testing - Does the application handle potentially malicious inputs gracefully? Does it give away information that could aid an attacker?
· Performance Testing - Will the application handle the proposed workload? How stable is it under load? How well does the application scale?
Software testing is an important part of the development lifecycle and the more rigorous, the better. Fortunately there are many tools that make creating and running tests easier. In this.
If you have not yet done so, you should complete the Module 05 lab.docx
1. If you have not yet done so, you should complete the Module 05
lab before working on this activity.
Design a small suite of tests for your Web application. This
suite should include:
Functional Testing, such as:
· Checking links
· Test Web forms
· Validate CSS tags
· Validate Javascript tags
Database Testing, such as:
· A search that returns a single record
· A search that returns no records
· A search the returns multiple records
Browser Compatibility Testing
· Function with some browser features turned off (e.g.,
Javascript)
Make sure you add comments to your test scripts to explain
what is happening with each test case. Include your name with
the comments as well.
Submit your test code files to your instructor as a ZIP file
named <first_initial><Last_name>_Mod05Dev.zip. So a student
Edith Palka would name her file epalka_Mod05Dev.zip
Module 05 Lab WorksheetBuilding a Test Plan
Lab Activities:· What is Web Application Testing?·
Introduction to Selenium· Creating a Test Case: Recording·
Creating a Test Case: Scripting· Creating a Test Suite
Introduction
At this point you should have, at minimum:
· An IDE (Integrated Development Environment) for your code
· An SQL administration utility (command-line, desktop or
Web-based)
· A MySQL database dbtest.
2. · A basic Web search form for dbtest that will let the user
search by surname
In addition, to complete this lab you will need to have the
following software installed:
· Mozilla Firefox (https://www.mozilla.org/en-US/firefox/new/)
· Java
(http://www.oracle.com/technetwork/java/javase/downloads/jre8
-downloads-2133155.html)
This lab assumes that you have a working knowledge of HTML,
CSS and Javascript.
What is Web Application Testing?
Web applications are like any other software. They need to be
tested before they are unleashed on the world.
Software testing and test development are normally the subject
of an entire course, so this lab is meant to give you an overview
and let you experiment with developing your own Web
application tests.
There are five basic categories of software tests:
· Functional Testing - Does the application work according to
specifications? Does it produce the correct output for a given
input? How does it handle errors?
· Compatibility Testing - Does it work with different browsers?
Different operating systems? DIfferent hardware?
· Database Testing - Does the information displayed in the
application match what’s in the database? Does the database
correctly display any updates from the application?
· Security Testing - Does the application handle potentially
malicious inputs gracefully? Does it give away information that
could aid an attacker?
· Performance Testing - Will the application handle the
proposed workload? How stable is it under load? How well does
the application scale?
3. Software testing is an important part of the development
lifecycle and the more rigorous, the better. Fortunately there are
many tools that make creating and running tests easier. In this
lab we’re going to look at Selenium, an open-source Web
testing tool.
Introduction to Selenium
Selenium isn’t a single tool but a suite of interoperable
programs and plug-ins. The three main components are:
· Selenium Server - This is a Java command line application
that processes your test scripts and controls the Web browser
through the appropriate Webdriver.
· Selenium IDE - This is a Mozilla Firefox plugin that lets you
create and run tests and test suites
· Webdriver - This is a software interface between the Selenium
Server and the browser under test. The Firefox Webdriver is
installed by default with the IDE, but you will need to install
drivers for all of the browsers you plan on testing. If you’re
running Windows, you will need to make sure you install the
Internet Explorer Webdriver.
Since the native format for a Selenium test case is HTML, you
can create and edit them in any text editor.
Selenium downloads - http://docs.seleniumhq.org/download/
Test Scripting
Selenium has a native scripting language. Commands have three
parts and act on a Base URL:
<command> <target> <value>
The target and value parameters are optional and depend on the
command. The Base URL is the address of the Web page under
test and all target paths in the test are relative to that URL.
For example, with the Base URL set to http://www.google.com:
open /
4. will open the main Google search page. No additional value is
required. Modifying the Base URL lets you use the same test
cases with different sites.
Test cases are saved as HTML files. Here’s the source code for
the previous test case, with the command and target in bold:
<table>
<tr><td>open</td><td>/</td><td></td></tr>
</table>
Each row is three columns wide with the columns containing the
command name, target and value, respectively.
Note that even if the command doesn’t require a target or value,
those other fields must be present.
You can create a test suite (a collection of tests that run one
after the other) by writing an HTML file that links to individual
test cases, like so:
<html>
<head>
<title>Test Suite 1</title>
</head>
<body>
<table>
<tr><td><b>Suite Of Tests</b></td></tr>
<tr><td><a href="./mail.html">Mail</a></td></tr>
<tr><td><a href="./Search.html">Test Search</a></td></tr>
<tr><td><a href="./Print.html">Test Print</a></td></tr>
</table>
</body>
</html>
5. This defines a table with each row linking to a different test
case file. You can reference additional commands and examples
at the Selenium IDE home page
http://docs.seleniumhq.org/docs/02_selenium_ide.jsp
Like any other HTML file, you can add comments to make
maintaining and updating your code easier. This is strongly
recommended.
You can also write test cases in other languages such as Java,
PHP, C#, Objective-C, Python and Javascript.Installation
· Selenium IDE - Go to the Downloads page listed above using
Firefox and when you click on the IDE download, Firefox will
ask you to approve the install. Do so. The browser will offer to
restart to activate the plugins. Let it.
· Selenium Server - Download it to your Inisope project
directory so you can find it later.
· WebDrivers - These let you control various browsers. Each
browser has its own WebDriver. The Firefox WebDriver is
installed by default. Download any additional WebDrivers you
may need for the other browsers you want to test.
Start up the Selenium Server from the command line (assuming
for this example that the server file is named selenium-server-
standalone-2.28.0.jar):
(Mac OS X and Linux):
java -jar selenium-server-standalone-2.28.0.jar
(Windows, all on one line)
java -jar selenium-server-standalone-2.28.0.jar -
Dwebdriver.ie.driver=.
6. On Windows, you might get a security pop-up that asks you to
confirm that you’re okay with Java having local network access.
The IDE will start recording browser actions automatically
when started.
We want to change that.
In Firefox, select Tools->Add-ons.
Under Extensions, select Selenium IDE->Preferences
The preferences dialog box will open:
Uncheck Start recording immediately on open. Click OK to save
your changes.
Open the Selenium IDE from the Firefox Tools menu and we’ll
create a simple test.Creating a Test Case: Recording
The simplest way to build a test is by having Selenium record
your actions in the browser. Starting the IDE
Open the IDE in Firefox by clicking on Tools->Selenium IDE.
The IDE will start up in a separate window:
Recording our Test Case
Make sure your VM is up and running.
Set the Base URL in the IDE to a Web site of your choice
Click on the Record button in the IDE (upper right corner).
In Firefox, browse to the Web page you selected earlier.
Right-click on any element in the page (ex. image, text, video)
7. and select a test from the context menu presented.
Do this for at least four more elements in the page.
Click on the Record button to stop recording and save your test
case in your Inisope project directory as TestCase01.html.
In the main IDE window, select the Source tab, then copy and
paste your test case script source here:
Here are some of the commands your test may have used:
8. · open - pretty straightforward. It just opens a Web page to the
URL relative to the Base URL.
· verifyText - This checks to see that the specified text shows
up in the browser, then logs success or failure before moving to
the next command.
· assertText - This is similar to verifyText except that if the
specified text fails to show up, the test will end. There is
another command, waitForText, that will wait a specified
amount of time for the given text. If it doesn’t show up in time,
the test halts. (This is useful for performance testing.)
Creating a Test Case: Scripting
Recording a test doesn’t always give you the control that you
want so once you’re comfortable with the scripting language
you can write your own test cases using your favorite text
editor.
The easiest way to create a script is to record a set of actions
that approximate what you want and then modify that test script
to fine-tune it. You can also modify an existing test case.
Make a copy of TestCase01.html and call it TestCase02.html.
Delete the final command and change it to a command that will
store the text value of the page title into a Javascript variable
called title_main.
Run the script to make sure it works, then copy and paste it
here.
9. Creating a Test Suite
You can create a test suite (a collection of test cases that run
one after the other) by writing an HTML file that links to
individual test cases, like so:
<html>
<head>
<title>My First Test Suite</title>
</head>
<body>
<table>
<tr><td><b>Suite Of Tests</b></td></tr>
<tr><td><a href="./mail.html">Mail</a></td></tr>
<tr><td><a href="./Search.html">Test Search</a></td></tr>
<tr><td><a href="./Print.html">Test Print</a></td></tr>
</table>
</body>
</html>
10. Notice that we are still using the table tag but this time each
row represents a link to a test case file instead of a single test
command. This also lets us modify individual test cases without
having to change any of the others as well as re-use our test
cases in multiple test suites.
Take the two test cases we previously created and write a test
suite file that calls them in sequence. Load the test suite into
the Selenium IDE and verify that both cases run properly.
Close the IDE window.
Stop the Selenium Server with <Ctrl>-C.
Archive your lab worksheet and test files in a single Zip file
named <initial><surname>_wk5lab.zip. For example, if your
name is Edith Palka, you would create a file named
epalka_wk5lab.zip. Submit this file to your instructor.
1