Software Testing v.1.2
Software Testing v.1.2
Software Testing
6.1. Software Testing Fundamentals
6.1.1. Causes of Software Defects
6.1.2. Seven Testing principles
6.1.3. Fundamental Test Process
6.1.4. Testing Throughout the Software Lifecycle
6.1.5. Test Levels
6.1.6. Test Types
6.1.7. Tool Support for Testing
6.1.8. Test Tool Classification
6.1.9. The Psychology of Testing
6.1.10. Code of Ethics
6.2. Test Techniques
6.2.1. Categories of Test Design Techniques
6.2.2. Specification-based or Black-box Techniques
6.2.3. Structure-based or White-box Techniques
6.2.4. Experience-based Techniques
6.3. Defect Management
6.3.1. Reporting Defects
6.3.2. Defect Life cycle
6.3.3. Severity and Priority
6.4. Test Management
6.4.1. Test Organization and Independence
6.4.2. Tasks of the Test Leader and Tester
6.4.3. Test Planning and Estimation
6.4.4. Strategy and Approach
6.4.5. Test Progress Monitoring and Control
6.4.6. Risk and Testing
6.5. Testing Tools
6.5.1. Manual and Automation testing
6.5.2. Automation Testing Tools
6.5.3. Selenium IDE
6.5.3.1. Introduction to Selenium IDE
6.5.3.2. Creating your First Selenium IDE script
6.5.3.3 Selenium Commands Selenese
6.5.3.4. Locators in Selenium IDE
6.5.3.5. Selenium IDE Troubleshooting
6. Software Testing
Defect
A defect in software, systems or documents is a result of an error. Defects are also known as faults.
Failure
A failure is defined as a deviation of the component or system from its expected delivery, service or
result. There are many possible causes of a failure, such as:
Software defect
Hardware malfunction
Environmental conditions, for example radiation or magnetic interference
The most visible part of testing is test execution but there are other activities as well. Test plans
should also include time to be spent on planning the tests, designing test cases, preparing for
The activities in the process may overlap and take places concurrently. Tailoring these activities
within the context of the system and the project is usually required.
6.1.4. Testing Throughout the Software Lifecycle
What are the SDLC Phases? Software
Development Life Cycle, or SDLC is a process
used to develop software. There are different
stages or phases within the Software
Development Life Cycle and in each phase,
different activities take place.
SDLC creates a structure for the development
teams to be able to design, create and deliver
high quality software by defining various tasks
that need to happen. The life cycle defines a
methodology for improving the quality of
software and the overall development process.
The methodology within the SDLC process can vary across organizations, but standards such as
ISO/IEC 12207 represent processes that establish a life cycle for software, and provide a standard
for building and maintaining software.
The intent of a SDLC process it to help produce a product that is cost-efficient, effective, and of
high quality.
Some general rules apply to good testing in any kind of software development model:
Test levels can be combined or reorganized depending on the nature of the project or the system
architecture.
User acceptance testing is a typical form of acceptance test. This to verify the fitness of the system
by real business users.
Contract acceptance testing is performed against a contract's acceptance criteria for producing
custom-developed software.
Regulation acceptance testing is performed against any regulations that must be adhered to, such
as governmental, legal or safety regulations.
Alpha testing is performed at the developing organization's site. Beta testing or field testing, is
performed by people at their own locations. Both are tested by customers or potential customers,
not the developers of the product.
6.1.6. Test Types
Testing of Function
The functions are "what" the system does. Functional tests are based on functions and features and
their interoperability with specific systems.
Functional testing considers how the software behaves during normal usage for a user i.e. black box
testing.
Testing of Non-functional Software Characteristics
Non-functional testing is when we test the software characteristics, i.e. "how" the system works.
These test are broader and could include:
Usability
Maintainability
Portability
Reliability
Security
Performance
Scalability
Localization
Non-functional testing may be performed at all test levels. It considers the external behaviour and
the most common test design technique is black-box testing.
Load Testing
It is a process of testing the behavior of a software by applying maximum load in terms of software
accessing and manipulating large input data. It can be done at both normal and peak load
conditions. This type of testing identifies the maximum capacity of software and its behavior at
peak time.
Stress Testing
Stress testing includes testing the behavior of a software under abnormal conditions. For example, it
may include taking away some resources or applying a load beyond the actual load limit.
The aim of stress testing is to test the software by applying the load to the system and taking over
the resources used by the software to identify the breaking point.
Execution tools, test data generation tools and result comparison tools are examples of
tools that are used directly for testing.
Test management tools used to manage tests, results, data, requirements, incidents,
defects etc. They could also support reporting and monitoring of test execution.
Reconnaissance tools used for exploration, for example, monitor the file activity for an
application.
Common tools that aids the testing, e.g. a spreadsheet that contains information about
the tests or testing.
Tool support for testing can have one or more of the following purposes depending on the context:
Prioritization of incidents
Tracking incident status (e.g. rejected, ready to be tested or deferred to next release)
Help in planning and risk analysis through metrics for the code, e.g. complexity
Modelling Tools
Modelling tools are used to validate models of the software. For example, it may find defects and
inconsistencies in a physical data model (PDM) for a relational database.
Other modelling tools may find defects in a state model or an object model. These tools can often
aid in generating some test cases based on the model.
The major benefit of static analysis tools and modelling tools is the cost effectiveness of finding
defects earlier in the development process.
Tool Support for Test Execution and Logging
Test Execution Tools
Test execution tools enable tests to be executed automatically, or semi-automatically, using stored
inputs and expected outcomes, through the use of a scripting language. This makes it possible to
repeat the test with different data. Normally they also provide a test log for each run.
Test execution tools can also be used to record tests, they may be referred to as capture-playback
tools. These tools usually support scripting language or GUI-based configuration for
parameterization of data and other customization in the tests.
Tests designed by a person(s) from a different organization or company, for example a outsourced
test site.
Objectives
It is important that the objectives of testing is clearly stated because people and projects are driven
by objectives, which could vary between projects. People tend to meet the objectives that apply, or
at least that they think are applicable.
For example, in one project the objective could be finding as many defects as possible but in
another project it could be to get confidence in a business process.
Focusing on only one objective could lead to that other product aspects are missed, e.g. only
focusing on finding defects may result in a system that is not user friendly.
Communication
Identifying failures during testing may be perceived as criticism against the product and against the
author. Therefore, testing is often seen as a destructive activity, even though it is very constructive
in the management of product risks. To be successful looking for failures in a system requires:
Curiosity
Professional pessimism
A critical eye
Attention to details
Good communication with development peers
Experience on which to base error guessing
Bad feelings between the testers and colleagues, for example analysts, designers and developers,
can be avoided if issues are communicated in a constructive way. This is true for testing as well as
reviews.
Testers and test leaders need good interpersonal skills to be able to communicate factual
information in a constructive way about, for example, defects, progress and risks. This information
can help the author of the software or document to improve their skills by learning from their
mistakes.
Communication problems may occur if testers are seen only as messengers of unwanted news about
defects, i.e. we shall not shoot the messenger. There are several ways to improve communication
between testers and project members. Things to think about are for example:
Mutual understanding and collaboration between testers and developers is a powerful tool to
increase product quality and project efficiency.
Experience-based Techniques
The knowledge and experience of people are used to derive the test cases. Other sources of
information are:
Knowledge of testers, developers, users and other stakeholders about the software, its usage
and its environment
6.2.4
Experience-based Techniques
Experienced-based testing is when tests are derived from the tester's skill and intuition as well as
their experience with similar applications and technologies.
These techniques can be useful in identifying special tests not easily captured by formal techniques.
An experienced-based technique may yield varying degrees of effectiveness depending of the
tester's experience.
Error Guessing Technique
A commonly used experienced-based technique is error guessing, i.e. testers anticipate defects
based on experience.
A structured approach is to enumerate a list of possible defects and to design tests attacking these
defects. This systematic approach is called fault attack.
These defect and failure lists can be built based on experience, available defect and failure data, and
from common knowledge about why software fails.
Exploratory Testing
In exploratory testing, test design, test execution, test logging and learning, based on a test charter
containing test objectives and performed within time-boxes.
It is an approach that is most useful where there are few or inadequate specifications and severe
time pressure, or in order to augment or complement other, more formal testing. It can serve as a
check to help ensure that the most serious defects are found.
determines how quickly the defect should be fixed. The priority normally concerns the business
importance such as impact on the project and the likely success of the product in the marketplace.
Date and Time
The date and time that the defect occurred or reported is also essential. This is normally useful when
you want to search for defects that were identified for a particular release of software or from when
the testing phase started.
up
Stage
1,
defects
are
found
and
reported.
Stage 2, defects are reviewed and delegated.
Stage 3, defects are debugged and removed.
Stage 4, removed defects are confirmed.
discuss
the
validity,
severity
and
priority
At this stage, defects are categorised into three different states:
of
the
defects.
Not a defect
Defect will be fixed
Defect wont be fixed in this release
Defect Status is: Reviewed and Assigned. This is the second stage of defect life cycle.
Independent test specialist for specific test types, e.g. usability testers, security testers or
certification testers
Coordinate the test strategy and plan with project managers and others
Write or review a test strategy for the project and a test policy for the organization
Planning of the tests considering the context and understanding the test objectives and
risk including selecting test approaches, estimating the time, effort cost of testing,
acquiring resources, defining test levels, cycles and planning incident management
Initiate the specification, preparation, implementation and execution of test, monitor the
test results and check the exit criteria
Adapt planning based on test results and progress, and take any action necessary to
compensate for problems
Set-up adequate configuration management of testware for traceability
Introduce suitable metrics for measuring test progress and evaluating the quality of the
testing and the product
Decide what should be automated, to what degree and how it should be done
Select tools to support testing and organize any training in tool use for testers
Decide about the implementation of the test environment
Write test summary reports based on the information gathered during testing
Defining a overall approach for the project, including the definition of test levels and
entry and exit criteria
Determining the scope, risks and objectives of testing
Integrating and coordinating testing activities with software lifecycle activities, e.g.
acquisition, supply, development, operation and maintenance
Assigning resources for the different activities defined
Making decisions about what to test, what roles will perform the test activities, how the
activities should be done, and how the test results will be evaluated
Determine roles and assignments to the project
Scheduling test analysis and design activities, test implementation, execution and
evaluation
Defining the amount, level of detail, structure and templates for the test documentation
Selecting metrics for monitoring and controlling test preparation and execution, defect
resolution and risk issues
Setting the level of detail for test procedures in order to provide enough information to
support reproducible test preparation and execution
Entry Criteria
Entry criteria define when to start testing such as the beginning of the test level or when a set of test
is ready for execution. Typically entry criteria may cover the following:
Exit Criteria
It is not possible to find all bugs and defects in a product, because you cannot test everything. This
is one reason why an exit criteria is needed. The exit criteria define when to stop testing such as the
end of the test level or when set of tests has achieved a specific goal.
Typical exit criteria may cover the following:
Test Estimation
Because time and resources are limited, planning involves estimating how much test effort will be
needed. Two approaches for estimation of test effort are:
The metrics-based approach - Estimating the testing effort based on metrics of former or
similar projects or based on typical values
The expert-based approach - Estimating the tasks based on estimates made by the owner
of the tasks or by experts
Once the test effort is estimated, resources can be identified and a schedule can be created.
The testing effort may depend on a number of factors that can be organized into three main groups.
Characteristics of the product
This includes the quality of the specification and other information used for test models (i.e. the test
basis), the size of the product, the complexity of the problem domain, the requirements for
reliability and security and the requirements for documentation
Characteristics of the development process
This includes the stability of the organization, tools used, test process, skills of the people involved
and time pressure
The outcome of testing
This includes the number of defects and the amount of rework required. Used on ongoing projects
which requires re-scheduling.
The selected approach depends on the context and may consider risks, hazards and safety, available
resources and skills, the technology, the nature of the system, test objectives and regulations. It
should be noted that it is possible to combine different approaches.
Classifying test approaches or strategies is based on the point in time at which the bulk of the test
design work is begun:
We can base our testing strategy on a variety of factors - risks, standards and methodologies. They
will be discussed in the following pages.
Percentage of work done in test case preparation (or percentage of planned test cases
prepared)
Test coverage of requirements, risks or code
Percentage of work done in test environment preparation
Test case execution (e.g. number of test cases run/not run, and test cases passed/failed)
Defect information (e.g. defect density, defects found and fixed, failure rate, and re-test
results)
Subjective confidence of testers in the product
Dates of test milestones
Testing costs, including the cost compared to the benefit of finding the next defect or to
run the next test
What happened during a period of testing, such as dates when exit criteria were met
A test summary report should contain metrics collected during and at the end of a test level in order
to assess:
Test Control
Test control describes any guiding or corrective action taken as a result of information and metrics
gathered and reported. Actions may cover any test activity and may affect any other software life
cycle activity or task.
Examples of test control actions are:
Project Risks
Project risks are the those that surround the project's capability to deliver its objectives. These can
be organizational, technical or related to external parties, such as suppliers.
When analyzing, managing and mitigating these risks, the test manager shall follow wellestablished project management priciples. In IEEE Std 829 the test plan outline requires risks and
contingencies to be stated.
Organizational factors
Technical issues
Problems in defining the right requirements
The extent to which requirements cannot be met given existing constraints
Test environment not ready on time
Late data conversion, migration planning and development, and testing tools to support
this
Low quality of the design, code, configuration data, test data and tests
Supplier issues
Failure of third party
Contractual issues
Product Risks
Potential failure areas in the software or system are known as product risks, as they are a risk to the
quality of the product. Products risks are a special type of risk to the success of a project.
Testing as a risk-control activity provides feedback about residual risk by measuring the
effectiveness of critical defect removal and contingency plans.
Risks are used to decide where to start testing and where to test more, i.e. test is used to reduce the
risk of an adverse effect occurring or to reduce the impact of the adverse effect.
Example of potential failure areas could be:
Failure-prone software delivered
The potential that the software/hardware could cause harm to an individual or company
Poor software characteristics, .e.g. reliability, usability and performance
Poor data integrity and quality, e.g. migration issues, conversion problems and violation
of data standards
Software that does not perform its intended functions
A risk-based approach to testing provides proactive opportunities to reduce the levels of product
risk, starting in the initial stages of a project. It involves the identification of product risks and their
use in guiding test planning and control, specification, preparation and execution of tests. In a riskbased approach the risks identified may be used to:
Risk-based testing draws on the collective knowledge and insight of the project stakeholders to
determine the risks and the levels of testing required to address those risks.
To ensure that the chance of a product failure is minimized, risk management activities provide a
disciplined approach to:
In addition, testing may support the identification of new risks, may help to determine what risks
should be reduced, and may lower uncertainty about risks.
Automation Testing
Automation testing, which is also known as Test Automation, is when the tester writes scripts and
uses another software to test the product. This process involves automation of a manual process.
Automation Testing is used to re-run the test scenarios that were performed manually, quickly, and
repeatedly.
Apart from regression testing, automation testing is also used to test the application from load,
performance, and stress point of view. It increases the test coverage, improves accuracy, and saves
time and money in comparison to manual testing.
What is Automate?
It is not possible to automate everything in a software. The areas at which a user can make
transactions such as the login form or registration forms, any area where large number of users can
access the software simultaneously should be automated.
Furthermore, all GUI items, connections with databases, field validations, etc. can be efficiently
tested by automating the manual process.
When to Automate?
Test Automation should be used by considering the following aspects of a software:
Large and critical projects
Projects that require testing the same areas frequently
Requirements not changing frequently
Accessing the application for load and performance with many virtual users
Stable software with respect to manual testing
Availability of time
How to Automate?
Automation is done by using a supportive computer language like VB scripting and an automated
software application. There are many tools available that can be used to write automation scripts.
Before mentioning the tools, let us identify the process that can be used to automate the testing
process:
However, actually building automated tests for web applications can be challenging because the
user interface of your application might change regularly, because of incompatibilities between
browsers and because you usually need to support various server or client platforms. The following
tools make it easier to build and execute automated tests for your web application.
Selenium
Selenium is a popular automated web testing tool and helps you automate web browsers across
different platforms. Selenium has the support of some of the largest browser vendors who have
taken steps to make Selenium a native part of their browser.
Watir
Watir is a set of Ruby libraries for automating web browsers and allows you to write tests that are
easy to read and maintain. Watir drives browsers the same way people do (it clicks links, fills in
forms, presses buttons etc.) and also checks results such as whether expected text appears on the
page.
Windmill
Windmill is a web testing tool designed to help testers automate and debug web applications. It
comes with a cross-browser test recorder, JavaScript integration and an interactive shell to automate
web browsers.
Ranorex
Ranorex allows you to automate your web application testing (among other things) and both record
user interactions and play them back to execute your tests. Ranorex is one of the more popular
commercial tools to build and run automated web and GUI tests.
SoapUI
SoapUI is a cross-platform functional testing tool. It has been specifically designed to help
automatically test APIs such as SOAP and REST interfaces to ensure the interoperability of
different applications.
Sahi
Sahi is a tool for automation of web application testing. Sahi is available as a free open source
edition as well as a commercial Pro edition.
Tellurium
Tellurium is a web automation tool that allows you to design and write your automated tests using
UFT(QTP)
HPE Unified Functional Testing (UFT) software, formerly known as HP QuickTest Professional
(QTP),provides functional and regression test automation for software applications and
environments. HPE Unified Functional Testing can be used for enterprise quality assurance.
Cost: Commercial , Start at 8000 US Dollar These licenses are normally sold to organizations and
not to individuals.
TestComplete Platform
Telerik Test Studio is a Windows-based software testing tool for web and desktop, it support is an
innovative and easy-to-use automated web, WPF and load testing solution. Test Studio tests support
essential technologies like ASP.NET AJAX, Silverlight, PHP and MVC.
Cost: 1000-3500 Dollars
6.5.3. Selenium IDE
6.5.3.1. Introduction to Selenium IDE
The Selenium-IDE (Integrated Development Environment) is the tool you use to develop your
Selenium test cases. Its an easy-to-use Firefox plug-in and is generally the most efficient way to
develop test cases. It also contains a context menu that allows you to first select a UI element from
the browsers currently displayed page and then select from a list of Selenium commands with
parameters pre-defined according to the context of the selected UI element. This is not only a timesaver, but also an excellent way of learning Selenium script syntax.
Menu Bar
It is located at the top most portion of the IDE. The most commonly used menus are the File, Edit,
and Options menus.
File menu
It contains options to create, open, save, and close tests.
Tests are saved in HTML format.
The most useful option is "Export" because it allows you to turn your Selenium IDE test
cases into file formats that can run on Selenium Remote Control and WebDriver
"Export Test Case As..." will export only the currently opened test case.
"Export Test Suite As..." will export all the test cases in the currently opened
test suite.
Edit Menu
It contains usual options like Undo, Redo, Cut, Copy, Paste, Delete, and Select All.
The two most important options are the "Insert New Command" and "Insert New
Comment".
The newly inserted command or comment will be placed on top of the currently selected
line.
It has a dropdown menu that remembers all previous values for easy access.
The Selenese command "open" will take you to the URL that you specified in the Base
URL.
In this tutorial series, we will be using http://newtours.demoaut.com as our Base URL. It is
the site for Mercury Tours, a web application maintained by HP for web testing purposes.
We shall be using this application because it contains a complete set of elements that we
need for the succeeding topics.
The Base URL is very useful in accessing relative URLs. Suppose that your Base URL is
set to http://newtours.demoaut.com. When you execute the command "open" with the target
value "signup", Selenium IDE will direct the browser to the sign-up page. See the
illustration below.
In Selenium IDE, you can open more than one test case at a time.
The test case pane shows you the list of currently opened test cases.
When you open a test suite, the test case pane will automatically list all the test cases
contained in it.
The test case written in bold font is the currently selected test case
After playback, each test case is color-coded to represent if it passed or failed.
Green color means "Passed."
Red color means "Failed."
At the bottom portion is a summary of the number of test cases that were run and failed.
Editor
You can think of the editor as the place where all the action happens. It is available in two views:
Table and Source.
Table View
Most of the time, you will work on Selenium IDE using the Table View.
This is where you create and modify Selenese commands.
After playback, each step is color-coded.
To create steps, type the name of the command in the "Command" text box.
It displays a dropdown list of commands that match with the entry that you are
currently typing.
Target is any parameter (like username, password) for a command and Value is the input
value (like tom, 123pass) for those Targets.
Log Pane
The Log Pane displays runtime messages during execution. It provides real-time updates as to
what Selenium IDE is doing.
Logs are categorized into four types:
Debug - By default, Debug messages are not displayed in the log panel. They show up only
when you filter them. They provide technical information about what Selenium IDE is doing
behind the scenes. It may display messages such as a specific module has done loading, a
certain function is called, or an external JavaScript file was loaded as an extension.
Info - It says which command Selenium IDE is currently executing.
Warn - These are warning messages that are encountered in special situations.
Error - These are error messages generated when Selenium IDE fails to execute a command,
or if a condition specified by "verify" or "assert" command is not met.
Logs can be filtered by type. For example, if you choose to select the "Error" option from the
dropdown list, the Log Pane will show error messages only.
Reference Pane
The Reference Pane shows a concise description of the currently selected Selenese command
in the Editor. It also shows the description about the locator and value to be used on that
command.
Step 2
In Firefox, navigate to http://newtours.demoaut.com/. Firefox should take you to the page similar to
the one shown below.
Step 3
Right-click on any blank space within the page, like on the Mercury Tours logo on the
upper left corner. This will bring up the Selenium IDE context menu. Note: Do not click on any
hyperlinked objects or images
Then, select "assertTitle exact: Welcome: Mercury Tours". This is a command that
makes sure that the page title is correct.
Step 4
In the "User Name" text box of Mercury Tours, type an invalid username, "invalidUN".
In the "Password" text box, type an invalid password, "invalidPW".
Step 5
Click on the "Sign-In" button. Firefox should take you to this page.
Step 6
Toggle the record button off to stop recording. Your script should now look like the one shown
below.
Step 7
Now that we are done with our test script, we shall save it in a test case. In the File menu, select
"Save Test Case". Alternatively, you can simply press Ctrl+S.
Step 8
Choose your desired location, and then name the test case as "Invalid_login".
Click the "Save" button.
Step 9.
Notice that the file was saved as HTML.
Step 10.
Go back to Selenium IDE and click the Playback button to execute the whole script. Selenium IDE
should be able to replicate everything flawlessly.
6.5.3.3
Selenese commands can have up to a maximum of two parameters: target and value.
Parameters are not required all the time. It depends on how many the command will need.
A command tells Selenium what to do. Selenium commands come in three flavors: Actions,
Accessors, and Assertions.
Actions are commands that generally manipulate the state of the application. They do things
like click this link and select that option. If an Action fails, or has an error, the execution
of the current test is stopped.
Many Actions can be called with the AndWait suffix, e.g. clickAndWait. This suffix tells
Selenium that the action will cause the browser to make a call to the server, and that Selenium
Common Commands
Command
Number of Parameters
Description
open
0-2
click/clickAndWait
type/typeKeys
verifyTitle/assertTitle
verifyTextPresent
verifyElementPresent
verifyTable
waitForPageToLoad
waitForElementPresent
verifyTextPresent - returns TRUE if the specified text string was FOUND somewhere in
the page; FALSE if otherwise
verifyTextNotPresent - returns TRUE if the specified text string was NOT FOUND
anywhere in the page; FALSE if it was found
Remember that these commands are case-sensitive.
In the scenario above, "Atlanta to Las Vegas" was treated differently from "atlanta to Las Vegas"
because the letter "A" of "Atlanta" was in uppercase on the first one while lowercase on the other.
When the verifyTextPresent command was used on each of them, one passed while the other failed.
Selenium IDE indicates the position of an element by measuring (in pixels) how far it is from the
left or top edge of the browser window.
verifyElementPositionLeft - verifies if the specified number of pixels match the distance of
the element from the left edge of the page. This will return FALSE if the value specified
does not match the distance from the left edge.
verifyElementPositionTop - verifies if the specified number of pixels match the distance of
the element from the top edge of the page. This will return FALSE if the value specified
does not match the distance from the top edge.
Wait commands
andWait commands
These are commands that will wait for a new page to load before moving onto the next command.
Examples are
clickAndWait
typeAndWait
selectAndWait
waitFor commands
These are commands that wait for a specified condition to become true before proceeding to the
next command (irrespective of loading of a new page). These commands are more appropriate to be
used on AJAX-based dynamic websites that change values and elements without reloading the
whole page. Examples include:
waitForTitle
waitForTextPresent
waitForAlert
Consider the Facebook scenario below.
We can use a combination of "click" and "waitForTextPresent" to verify the presence of the text
"Providing your birthday".
We cannot use clickAndWait because no page was loaded upon clicking on the "Why do I need to
provide my birthday?" link. If we do, the test will fail
To access the variable, simply enclose it in a ${ ... } symbol. For example, to enter the value of
"myVariable" onto the "userName" textbox of Mercury Tours, enter ${myVariable} in the Value
field.
StoreElementPresent
This command stores either "true" or "false" depending on the presence of the specified element.
The script below stores the Boolean value "true" to "var1" and "false" to "var2". To verify, we will
use the "echo" command to display the values of var1 and var2. The Base URL for the illustration
below was set to Mercury Tours homepage.
StoreText
This command is used to store the inner text of an element onto a variable. The illustration below
stores the inner text of the tag in Facebook onto a variable named 'textVar'.
Since it is the only element in the page, it is safe to use 'css=h1' as our target. The image below
shows that Selenium IDE was able to save the string "Sign Up" in the 'textVar' variable by printing
its value correctly.
Now, we shall recreate the same test case manually, by typing in the commands. This time, we will
need to use Firebug.
Step 1
Open Firefox and Selenium IDE.
Type the base URL (http://newtours.demoaut.com/).
The record button should be OFF.
Step 2
Click on the topmost blank line in the Editor.
Step 3
Navigate Firefox to our base URL and activate Firebug
In the Selenium IDE Editor pane, select the second line (the line below the "open"
command) and create the second command by typing "assertTitle" on the Command box.
Feel free to use the autocomplete feature.
Step 4
In Firebug, expand the <head> tag to display the <title> tag.
Click on the value of the <title> tag (which is "Welcome: Mercury Tours") and paste it onto
the Target field in the Editor.
Step 5
To create the third command, click on the third blank line in the Editor and key-in "type" on
the Command text box.
In Firebug, click on the "Inspect" button.
Click on the User Name text box. Notice that Firebug automatically shows you the HTML code for
that element.
Step 6
Notice that the User Name text box does not have an ID, but it has a NAME attribute. We shall,
therefore, use its NAME as the locator. Copy the NAME value and paste it onto the Target field in
Selenium IDE.
Still in the Target text box, prefix "userName" with "name=", indicating that Selenium IDE should
target an element whose NAME attribute is "userName."
Type "invalidUN" in the Value text box of Selenium IDE. Your test script should now look like the
image below. We are done with the third command. Note: Instead of invalidUN, you may enter any
other text string. But Selenium IDE is case sensitive and you type values/attributes exactly like in
the application.
Step 7
To create the fourth command, key-in "type" on the Command text box.
Again, use Firebug's "Inspect" button to get the locator for the "Password" text box.
Paste the NAME attribute ("password") onto the Target field and prefix it with "name="
Type "invalidPW" in the Value field in Selenium IDE. Your test script should now look like
the image below.
Step 8
For the fifth command, type "clickAndWait" on the Command text box in Selenium IDE.
Use Firebug's "Inspect" button to get the locator for the "Sign In" button.
Paste the value of the NAME attribute ("login") onto the Target text box and prefix it with
"name=".
Your test script should now look like the image below.
Step 9
Save the test case in the same way as we did in the previous section.
Tag and ID
Inner text
DOM (Document Object Model)
getElementById
getElementsByName
XPath
dom:name
dom: index
There are commands that do not need a locator (such as the "open" command). However, most of
them do need Locators.
The choice of locator depends largely on your Application Under Test. In this tutorial, we will
toggle between facebook, new tours.demoaut on the basis of locators that these applications
support. Likewise in your testing project you will select any of the above listed locators based on
your application support.
Locating by ID
This is the most common way of locating elements since ID's are supposed to be unique for each
element.
Target Format: id=id of the element
For this example, we will use Facebook as our test app because Mercury Tours does not use ID
attributes.
Step 1. Navigate to http://www.facebook.com. Inspect the "Email or Phone" text box using Firebug
and take note of its ID. In this case, the ID is "email".
Step 2. Launch Selenium IDE and enter "id=email" in the Target box. Click the Find button and
notice that the "Email or Phone" text box becomes highlighted with yellow and bordered with
green, meaning, Selenium IDE was able to locate that element correctly.
Locating by Name
Locating elements by name are very similar to locating by ID, except that we use the "name="
prefix instead.
Target Format: name=name of the element
In the following demonstration, we will now use Mercury Tours because all significant elements
have names.
Step 1. Navigate to http://newtours.demoaut.com/ and use Firebug to inspect the "User Name" text
box. Take note of its name attribute.
Filters can be used when multiple elements have the same name. Filters are additional attributes
used to distinguish elements with the same name.
Target Format: name=name_of_the_element filter=value_of_filter
Let's see an example Step 1. Log on to Mercury Tours using "tutorial" as the username and password. It should take you
to the Flight Finder page shown below.
Step 2. Using Firebug, notice that the Round Trip and One Way radio buttons have the same name
"tripType." However, they have different VALUE attributes so we can use each of them as our filter.
Step 3.
We are going to access the One Way radio button first. Click the first line on the Editor.
In the Command box of Selenium IDE, enter the command "click".
In the Target box, enter "name=tripType value=oneway". The "value=oneway" portion is
our filter.
Step 4. Click the Find button and notice that Selenium IDE is able to highlight the One Way radio
button with green - meaning that we are able to access the element successfully using its VALUE
attribute.
Step 5. Press the "X" key in your keyboard to execute this click command. Notice that the One Way
radio button became selected.
You can do the exact same thing with the Round Trip radio button, this time, using "name=tripType
value=roundtrip" as your target.
This type of locator applies only to hyperlink texts. We access the link by prefixing our target with
"link=" and then followed by the hyperlink text.
Target Format: link=link_text
In this example, we shall access the "REGISTER" link found in the Mercury Tours homepage.
Step 1.
First, make sure that you are logged off from Mercury Tours.
Go to Mercury Tours homepage.
Step 2.
Using Firebug, inspect the "REGISTER" link. The link text is found between and tags.
In this case, our link text is "REGISTER". Copy the link text.
Step 3. Copy the link text in Firebug and paste it onto Selenium IDE's Target box. Prefix it with
"link=".
Step 4. Click on the Find button and notice that Selenium IDE was able to highlight the REGISTER
link correctly.
Step 5. To verify further, enter "clickAndWait" in the Command box and execute it. Selenium IDE
should be able to click on that REGISTER link successfully and take you to the Registration page
shown below.
CSS Selectors are string patterns used to identify an element based on a combination of HTML tag,
id, class, and attributes. Locating by CSS Selector is more complicated than the previous methods,
but it is the most common locating strategy of advanced Selenium users because it can access even
those elements that have no ID or name.
CSS Selectors have many formats, but we will only focus on the most common ones.
Tag and ID
Tag and class
Tag and attribute
Tag, class, and attribute
Inner text
When using this strategy, we always prefix the Target box with "css=" as will be shown on the
following examples.
# = the hash sign. This should always be present when using a CSS Selector with ID
id = the ID of the element being accessed
Step 2. Enter "css=input#email" into the Target box of Selenium IDE and click the Find button.
Selenium IDE should be able to highlight that element.
Syntax
css=tag.class
Step 2. In Selenium IDE, enter "css=input.inputtext" in the Target box and click Find. Selenium
IDE should be able to recognize the Email or Phone text box.
Take note that when multiple elements have the same HTML tag and name, only the first
element in source code will be recognized. Using Firebug, inspect the Password text box in
Facebook and notice that it has the same name as the Email or Phone text box.
The reason why only the Email or Phone text box was highlighted in the previous illustration is that
it comes first in Facebook's page source.
Syntax
css=tag[attribute=value]
tag = the HTML tag of the element being accessed
[ and ] = square brackets within which a specific attribute and its corresponding value will
be placed
attribute = the attribute to be used. It is advisable to use an attribute that is unique to the
element such as a name or ID.
value = the corresponding value of the chosen attribute.
Step 2. In Selenium IDE, enter "css=input[name=lastName]" in the Target box and click Find.
Selenium IDE should be able to access the Last Name box successfully.
When multiple elements have the same HTML tag and attribute, only the first one will be
recognized. This behavior is similar to locating elements using CSS selectors with the same tag and
class.
Step 1. Navigate to www.facebook.com and use Firebug to inspect the 'Email or Phone' and
'Password' input boxes. Take note of their HTML tag, class, and attributes. For this example, we
will select their 'tabindex' attributes.
Step 2. We will access the 'Email or Phone' text box first, thus, we will use a tabindex value of 1.
Enter "css=input.inputtext[tabindex=1]" in Selenium IDE's Target box and click Find. The 'Email or
Phone' input box should be highlighted.
Step 3. To access the Password input box, simply replace the value of the tabindex attribute. Enter
"css=input.inputtext[tabindex=2]" in the Target box and click on the Find button. Selenium IDE
must be able to identify the Password text box successfully.
Syntax
css=tag:contains("inner text")
tag = the HTML tag of the element being accessed
inner text = the inner text of the element
investigate the "Password" label. Take note of its HTML tag (which is "font" in this case) and notice
that it has no class, id, or name attributes.
Step 2. Type css=font:contains("Password:") into Selenium IDE's Target box and click Find.
Selenium IDE should be able to access the Password label as shown on the image below.
Step 3. This time, replace the inner text with "Boston" so that your Target will now become
"css=font:contains("Boston")". Click Find. You should notice that the "Boston to San Francisco"
label becomes highlighted. This shows you that Selenium IDE can access a long label even if you
just indicated the first word of its inner text.
Locating by XPath
XPath is the language used when locating XML (Extensible Markup Language) nodes. Since
HTML can be thought of as an implementation of XML, we can also use XPath in locating HTML
elements.
Advantage: It can access almost any element, even those without class, name, or id attributes.
Disadvantage: It is the most complicated method of identifying elements because of too many
different rules and considerations.
Fortunately, Firebug can automatically generate XPath locators. In the following example, we will
access an image that cannot possibly be accessed through the methods we discussed earlier.
Step 1. Navigate to Mercury Tours Homepage and use Firebug to inspect the orange rectangle to the
right of the yellow "Links" box. Refer to the image below.
Step 2. Right click on the element's HTML code and then select the "Copy XPath" option.
Step 3. In Selenium IDE, type one forward slash "/" in the Target box then paste the XPath that we
copied in the previous step. The entry in your Target box should now begin with two forward
slashes "//".
Step 4. Click on the Find button. Selenium IDE should be able to highlight the orange box as
shown below.
This type of error may indicate a timing problem, i.e., the element specified by a locator in your
command wasnt fully loaded when the command was executed. Try putting a pause 5000 before
the command to determine whether the problem is indeed related to timing. If so, investigate using
an appropriate waitFor* or *AndWait command before the failing command.
________________________________________________________________________________
Whenever your attempt to use variable substitution fails as is the case for the open command above,
it indicates that you havent actually created the variable whose value youre trying to access. This
is sometimes due to putting the variable in the Value field when it should be in the Target field or
vice versa. In the example above, the two parameters for the store command have been erroneously
placed in the reverse order of what is required. For any Selenese command, the first required
parameter must go in the Target field, and the second required parameter (if one exists) must go in
the Value field.
________________________________________________________________________________
error loading test case: [Exception... Component returned failure code: 0x80520012
(NS_ERROR_FILE_NOT_FOUND)
[nsIFileInputStream.init]
nresult:
0x80520012
(NS_ERROR_FILE_NOT_FOUND) location: JS frame :: chrome://selenium-ide/content/fileutils.js :: anonymous :: line 48 data: no]
One of the test cases in your test suite cannot be found. Make sure that the test case is indeed
located where the test suite indicates it is located. Also, make sure that your actual test case files
have the .html extension both in their filenames, and in the test suite file where they are referenced.
________________________________________________________________________________
Your extension files contents have not been read by Selenium-IDE. Be sure you have specified the
proper pathname to the extensions file via Options=>Options=>General in the Selenium Core
extensions field. Also, Selenium-IDE must be restarted after any change to either an extensions file
or to the contents of the Selenium Core extensions field.