Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 52

SilkTest – Introduction to Automation

DS Hendler, Anna Medeiros , December 2000


What is SilkTest ?
SilkTest is

• A powerful tool for running automated test cases on the front end
• A tool for testing Web based applications across different browsers
• Very very stupid – you have to tell it everything in its own language
(4test)
• Inflexible when it comes to interpreting your commands
 It cannot guess at what you mean
 It requires a certain syntax with certain words
• This can be quite maddening

Question.com Confidential
What can you do with it ?
Mostly anything you can do in a Web browser, you can do with SilkTest.

 Enter text in text fields


 Click buttons
 Check boxes
 Get files
 Clear your cache
 etc.

Question.com Confidential
Using a browser
Though SilkTest is its own product, you still have to use a browser to
access your application

You have to tell SilkTest what kind of browser you are going to use for
your testing so that it knows what it is looking at.

Our version of SilkTest supports Netscape 4, IE 4 and IE 5.


Silk already knows what these browsers can do from a set of browser
extensions, so you can run your automated cases in Netscape or IE

However, you can only run SilkTest on one instance of a browser at a time
-- One IE browser going at a time

Question.com Confidential
Browser extensions
You choose your browser extensions in 2 places: once on the computers
where you are going to run SilkTest, and then in the program itself.

On the computer side, the extension chooser is called the Extension


Enabler.
On the program side, the chooser is called the Extensions Manager

Question.com Confidential
Extension Enabler

The Extension Enabler tells SilkTest what browsers you are going to
use on your computer.
It is found under Start Menu / Programs/ SilkTest

• Choose all the browsers


you will use

• This will not affect your


performance

IE has 2 extensions, but we are


only using the Virtual Object extension

Question.com Confidential
Extensions Manager
The Extensions Manager is part of SilkTest.

Through it, you tell SilkTest what browser you are using.

The Extensions Manager is located in the menu under Options / Extensions

Question.com Confidential
Extensions Manager

You should only


choose one
browser at a time

Choosing more than


one browser here will
decrease IE 5 is chosen here
your performance!

Question.com Confidential
Extensions Manager
When you choose a browser in the
Manager, SilkTest tells itself
what that browser can do.
It has the browser’s abilities pre-
programmed in.
When you choose a browser,
you make it your default browser.

Question.com Confidential
Runtime Options

Runtime Options tell SilkTest


where your files are and what
browser you are using

This window is located under the


menu Options / Runtime

Question.com Confidential
Runtime Options

“Use Path” – This is where your


files are located

“Use Files” – This is where your


frame file and browser
extensions are located
• Use the “Add” button to locate
your file • The browser extensions were
added here automatically when
we used the Extensions Manager

Question.com Confidential
Types of files – Include files
SilkTest uses 3 kinds of files:

• Include files (*.inc)


• Test files (*.t)
• Plan files (*.pln)
 (SilkTest creates a 4th type, the results file (*.res), to display the outcome of a test
case, but you do not create this file directly)

The include extension (*.inc) means that the file is included in running a
SilkTest process, but is not involved directly in running the process.
There are 3 types of include files:
• Frames
• Functions
• Tags
(Tags will be covered in a later class)

Question.com Confidential
File Types – Frame files
• The frame file tells SilkTest what the Web application looks like
• You will use the frame file already made for our application.
• You point to a frame file through Runtime Options / Use Files

Question.com Confidential
File Types – Test Case files
Test case files (*.t), or script files, tell SilkTest what you want it to do
All your test case files should be in the same file folder
• You pointed to this folder through your Runtime Options / Use Path

Test case files

Test case files reference frame files


and make reading your case easier

Question.com Confidential
File Types – Function files
Functions are a special kind of include file (*.inc)
Functions act like a frame file, but look like a test case
• They are single-purpose, often-used test case procedures that you store
as an include file
• They must exist in the same folder as your cases

Saved as an
include file (*.inc) Written like a test case
like a frame • Functions reference the
frame file, like the test
case files do

Question.com Confidential
File Types – Coming Together
Frame, function and test cases come together in the test case file
• You call functions in the test case by referencing them by their name

Function Test case file


file

More than one function


Frame file can be called by a test case

Question.com Confidential
File Types – Plan files
Can can combine multiple test case files in a plan file (*.pln)
A plan file is a collection of test cases
You can choose to run one, a few, or all of the cases in your plan

Lists script(s) to be used


Echoes Runtime Options
information

Lists the cases and what


they do in plain language

Question.com Confidential
File Types – Recap
SilkTest uses 3 types of files: include, test case and plan files

• The frame file tells SilkTest what the application looks like
• The test case file refers to the frame file and tells the browser what to
do
• A function is a procedure that is used in many different cases
 It is written like a test case, but saved like a frame file
• A plan will help you organize many cases

Question.com Confidential
Window Identifiers
Now that we have an idea what SilkTest needs to run a script, let’s get a
view into how SilkTest views the application.

In order to see how Silk views the application, we use the Window
Identifiers tool
 It is found in the tool bar under the Record / Windows Identifiers…

Question.com Confidential
Window Identifiers
Choosing the Window Identifiers launches the Record Window Identifiers
tool:

Notifies you how SilkTest


views what you have your “Keep on top” is
cursor pointed at the default option
• Here, the cursor is on a
blank area of the Browse
page

The Paste to Editor and


To freeze your selection,
Copy to Clipboard buttons
click Ctrl + Alt at same time
become active
The Resume Tracking button
also becomes active

Question.com Confidential
Window Identifiers -- Use
How to use the Window Identifiers tool:
Hover your pointer over the object you want to view:

Here, we are looking at the


HtmlPushButton called
“Search”

Question.com Confidential
Window Identifiers -- Use
With the information the Window Identifiers gives us, we know how the
program views our application.

An HtmlPushButton, like all Html objects, has certain


properties and functions you can perform on it

• To find out what SilkTest will allow you do with this


object, we use the Library Browser

Question.com Confidential
Library Browser
The Library Browser gives you a list of all the object classes SilkTest
recognizes as well as all the actions (called Methods) you can perform
on those objects

 It is found in the menu under Help / Library Browser:

Methods

Objects

How to script a specific Method


Question.com Confidential
Library Browser / Help Topics
While the Library Browser gives
you the proper Syntax for a
given Method, it is very
abstract.

An example, as well as a more


detailed explanation, of the
Method is given under the Help
topics

Although you often have to do


some digging to find the proper
help topic.
It usually contains the word
“Method” in the Help topic

Question.com Confidential
Help Topics
The Help Topics give a more
extensive explanation of the
syntax of a Method, what it
does, and important usage
notes.

One of the more useful aspects


of the Help Topics is the
Example, which shows how
you can use the Method in a
script
• (This example clicks an item
[labeled ‘3’] in a list)

Question.com Confidential
SilkTest Tools -- Recap
• Use the Window Identifiers to see how SilkTest views a given object

• Use the Library Browser to see what Methods you can perform on an
object

• Use the Help Topics to find Real Life examples, important notes on
Methods, and detailed explanations of Syntax

Question.com Confidential
Writing a Test Case
Remember that Test case files (*.t), or script files, tell SilkTest what you
want it to do

SilkTest requires the syntax you find in the Library Browser and Help
Topic files in order to perform the tasks you want it to do.

Question.com Confidential
Creating a Test Case

• Choose File/ New to create a new test case


• This window will open:

• Choose 4Test Script as the File Type and click the OK button

Question.com Confidential
Writing the Test Case
• Test cases are referenced by name
• To create a test case called “Search”, type “testcase Search ()”
on the first line.

Question.com Confidential
Fonts and Colors
• As you type, you will notice that the color of your text changes,
according to its function in the 4test language

• The default colors for the 4test language are


• Black – code
• Purple – numbers (i = 5)
• Brown – strings (“This is a string”)
• Blue – keywords (testcase Login)
• Green – Comments ( // this is a comment )

Question.com Confidential
Viewing the Frame
Remember:
• The frame file tells SilkTest what the Web application looks like
• You will use the frame file already made for our application.
• You point to your frame file through Options /Runtime/ Use Files
selection from the menu

Question.com Confidential
Using the Frame
The frame tells you what items you
have to work with in our
application
You will be using a frame that has
Defined objects
already been defined
you can use
in your scripts
It is broken up into styles of pages
such as “Home”, “Expert” and
“Admin”

This is the declaration


for “Home” style pages

Question.com Confidential
Using the frame
• When you write your test cases, refer to the
frame file to determine what window identifiers
to use.
• Remember: Methods such as ‘Click’ and
‘SetText’ can be found through the Library
Browser.

Question.com Confidential
Running the Test Case
• To run the Test Case, click on the Green arrow or select Run/Testcase
from the menu. A results file will appear once the test is complete.

Question.com Confidential
Creating a Test Plan

• Choose File/New to create a test plan.

• Choose Testplan as the File Type and click the OK button

Question.com Confidential
Adding a Test Case to a Test Plan
• Right click on the plan and choose ‘Test Detail…’ from the menu.

Question.com Confidential
Adding to a Plan (con’t)
• You may choose a script to add to the testplan. In this case I’ve added
the script created earlier.
• To add a test case, click on the Testcases button and a list of test cases
available in that script displays.

Question.com Confidential
Adding to a Plan (con’t)
Once you have your test cases set in the plan, you will need to separate
them
Doing this process allows you to call only certain test cases you wish to
run, as well as allowing yourself a more human description of your
case

• To do this, type your descriptive name


above your case name & press the Enter key
• Put your cursor on your test case line
• Click the Right Arrow button in the toolbar to
indent your case

Question.com Confidential
Adding to a Plan (con’t)
• Now that you have the Script and case information in your plan, you
will have to add Header information.
• This is the text that echoes what is written in the Runtime Options
window.

Question.com Confidential
Running Test Cases from the Test Plans
• You can select certain cases to run by “Marking” them in the yellow bar
in the Plan
• To Mark the entire test plan, go to Testplan/Mark All from the menu
• To Mark an individual test case, put your cursor by the test case you want
to mark and go to Testplan/Mark from the menu. Or click on the Mark
icon (the yellow square with the + beside it)
• The yellow box icons shown below (circled in red) allow you to mark
and unmark test cases as well as find marked sections in your plan.
• The green arrow icons shown below (circled in blue) allow you to run the
entire test plan, test script or just a test case.

Question.com Confidential
Verification
• There are a variety of methods that can be used to get
information on objects you are trying to verify.
• To determine what these methods are, go to the Library
Browser and choose the object’s class you are trying to verify.

In this example I
chose to find the
methods available
for an HtmlLink

Question.com Confidential
The Verify Function
• The Verify Function is a simple way to check the information
returned by a method.
• Syntax:
Verify (Actual Value, Expected Value, Error Message [optional])
• Example:
Verify (Home.Browse.GetText (), “Browse”, “Incorrect Text”)
(*Browse is an HtmlLink in our application. GetText () is one method available for HtmlLinks,
as shown on the previous slide.)

• The text returned by the GetText method is our actual value. I’m
expecting the word “Browse” to be returned. If it is not returned,
the error “Incorrect Text” will be displayed in my results file.

Question.com Confidential
The Verify Function
This is the Help Topics entry
for the Verify function

Question.com Confidential
Walkthrough – Add a new user
1. Create a new test script.

2. Name the test case: Type ‘testcase AddUser ()’ on first line.

Question.com Confidential
Walkthrough – Add a new user (con’t)
3. Using the frame in your handout we will write a test case to signup
a new user. For example:

[ ] // Test case to Add a new user


[-] testcase AddUser ()
[ ] Home.Login.Click ()
[ ] Home.SignUp.Click ()
[ ] Home.YourName.SetText ("Bob10")

(To write comments, use the “//” to comment your code. You can also go to
Outline/(Un)comment Block from the menu to comment or uncomment sections of code.)

4. Add a verify function to confirm the user is logged in once it is


created. (I’ve also included the example Browse Verify function
from our previous slide)
Question.com Confidential
Completed Test Case

Complete sample test case.

Question.com Confidential
Walkthrough – Add test case to a plan
1. Create a new test plan.

2. Add the test script and test case using the Test Detail option.

Question.com Confidential
Walkthrough – Add test case a plan (con’t)
3. Edit the test plan.
• Add the heading information.
• Separate the testcases so they can be marked separately.
4. Mark your test case and run it.

Question.com Confidential
Completed Test Plan with results file

Question.com Confidential
Exercise

• Write a test case to login a


user using this frame &
verify that the user is logged
in.

• You will find a more


complete frame in your
handout

Question.com Confidential
Exercise
• Write a test case to login a user using the previously given frame & verify
that the user is logged in
• Results:

Question.com Confidential
SilkTest Automation Recap
We have learned:

 What SilkTest is and what its basic component parts are


 How to get SilkTest to view a Web application
 How to use a Frame
 How to write a Test Case

Question.com Confidential

You might also like