Showing posts with label Automation. Show all posts
Showing posts with label Automation. Show all posts

Wednesday, November 19, 2008

Automation - QTP - II

Session 2.
Introduction To QTP

• Recap.
• Features of QTP.
• Descriptive Programming.
• Objects and Their Identification.
• Areas That Can be automated:
• Highly redundant tasks or scenarios.
• Repetitive tasks that are boring or tend to cause human error
• Well-developed and well-understood use cases or scenarios first
• Relatively stable areas of the application over volatile ones must be automated.
• Type of Tests that can be automated.
• Functional -testing that operations perform as expected.
• Regression -testing that the behavior of the system has not changed.
• Exception or Negative -forcing error conditions in the system.
• Performance -providing assurance that the performance of the system will be adequate for both batch runs and online transactions in relation to business projections and requirements.

Features Of QTP
Active Screen: Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.
Keyword View: The Keyword View enables you to create and view the steps of your test or component in a keyword-driven, modular, table format. Each step in your test or component is a row in the Keyword View, comprised of individual parts which you can easily modify.
Expert View: In the Expert View, QuickTest displays each operation performed on your application in the form of a script,
comprised of VBScript statements. The Expert View is a script editor with many script editing capabilities
Data Table—Assists you in parameterizing your test or component. For a test, the Data Table contains the Global tab and a tab for each action. For a component, the Data Table contains single tab.

Checkpoints
• A checkpointis a verification point that compares a current value for a specified property with the expected value for that property.
• This enables you to identify whether your Web site or application is functioning correctly.

Types of Checkpoints
• Standard Checkpoint checks the property value of an object in your application or Web page. The standard checkpoint checks a variety of objects such as buttons, radio buttons, combo boxes, lists, etc. For example, you can check that a radio button is activated after it is selected or you can check the value
of an edit field.
• Image Checkpoint checks the value of an image in your application or Web page. Image checkpoints are supported for the Web environment
• Table Checkpoint checks information within a table.
For example, suppose your application or Web site contains a table listing all available flights from New York to San Francisco. You can add a table checkpoint to check that the time of the first flight in the table is correct.
• Text Checkpoint checks that a text string is displayed in the appropriate place in your application or on a Web page
• Page Checkpoint checks the characteristics of a Web page.
For example, you can check how long a Web page takes to load or whether a Web page contains broken links.
• Database Checkpoint checks the contents of a database accessed by your application.
• XML Checkpoint checks the data content of XML documents in XML files or XML documents in Web pages and frames

Synchronization
• We can handle the anticipated timing problems by synchronizing the test or component to ensure that QuickTest waits until the application is ready before performing a step.

Ways to Synchronize
1. Synchronization point. By Inserting a synchronization point. This will ensure that QuickTest will pause the test or component until the object property achieves the value.
2. By inserting Exist or Wait statements that instruct QuickTest to wait until an object exists or to wait a specified amount of time before continuing the test or component
3. By modify the default amount of time that QuickTest waits for a Web page to load.
4. Writing your own Synchronization Function.

Quality Center
• Quality center is a central repository of manual and automated tests, Build test cycles, Run tests and components, and report and track defects.
• Quality Center can also be used for creating reports and graphs, for review of test planning, test runs and defect tracking.


Object Repository
• QuickTest stores the object data in the object repository. This data is a set of properties of the objects.


Recovery Scenario Manager
• Recovery scenario manager helps to create recovery scenarios which will handle any interruptions that might occur during a test execution.

Example
• A save confirmation dialog pops up during execution.

Understanding the Recovery Scenario Wizard
• The Recovery Scenario Wizard leads you, step-by-step, through the process of creating a recovery scenario. The Recovery Scenario Wizard contains five main steps:
1. Defining the trigger event that interrupts the run session
2. Specifying the recovery operation(s) required to continue
3. Choosing a post-recovery test run operation
4. Specifying a name and description for the recovery scenario
5. Specifying whether to associate the recovery scenario to the current test and/or to all new tests

Objects & Their Identification
• QTP is an object based programming environment.
• There are various objects within the windows environment. Browsers, Desktop Icons, files etc to quote a few.

Objects And QTP
1. What are the objects that we can interact with?
2. How can we uniquely identify an object.
3. What operations can we do to an object.

What are the objects that we can interact with?
• We can interact with all the GUI objects in the windows environment.

How can we uniquely Identify an Object?
• There are many GUI objects active in windows at any given time.
• We can uniquely identify the objects through its properties.
• We need to find out the set of properties which will uniquely identify an object.

Properties can be found out through.
• Probing.
• There is a tool in QTP known as an Object Spy which can be used to find out the set of properties of an objects
• Heuristics (previous knowledge and experience)

What Operations Can we do on an object?
• Read a property, Known as a Get operation.
• Set a property, Known as a Set operation.
• Trigger an Event. E.g. Click.

Example
Aim:
1. Set value in the username field on the login screen.
2. Read the value in the username field from the login screen.

Interacting with an Object-Steps
1. Object identification.
2. Specify the Operation.
For identifying the username field.
• Specify the Browser.
• Specify the Page.
• Specify the Object. i.e. the text box.

Browser is encapsulated within the Browser object. Hence it can be identified as
• Browser()
• Browser(“micClass:=Browser”)

The page is contained within the browser
• hence a page can be identified as.
• Browser(“micClass:=Browser”).Page(“micClass:=Page”)
• The username text box is listed in the page, it can be identified as.
• Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:= j_username”)

For setting the value in a WebEdit use the Set method.
• The Complete syntax is
• Browser(“micClass:=Browser”)Page(“micClass:=Page”).WebEdit(“name:=j_username”).Set “Abhilash”

Reading a Value
• sVariable=Browser(“micClass:=Browser”)Page(“micClass:=Page”).WebEdit(“name:= j_username”).GetRoProperty(“value”)

Escape Characters.
All special characters need to be stuffed with a backslash character \
• Example:
• processClassIDs[0] to be stuffed as
• processClassIDs\[0\]

Automation - QTP - I

Automation -QTP
Abhilash Gopi
Mail to : abhilash_gopi@yahoo.com
Mob : 9846 321334
Website : http://abuabba.googlepages.com


Automation Tools

Session 1.
Introduction To Automation


• Automation is not a replacement of
Manual testing.
• Automation supplements manual
testing.


Pros of Automation
• Enables to execute tests repetitively.
• Useful in Regression Testing.
• Much faster, As tests can be run
simultaneously in different machines.

Cons
• Costs more. Initial cost for automation
is more than running the tests
manually.
• Not all scenarios can be automated.

Automation Planning
• Planning for Time
• Planning for Resources
• Planning of Test Coverage

• There are two sets of questions to determine whether automation is right for your test case:
I) Is this test scenario automatable?
1. Yes, and it will cost a little
2. Yes, but it will cost a lot
3. No, it is no possible to automate

II) How important is this test scenario?
1. I must absolutely test this scenario whenever possible
2. I need to test this scenario regularly
3. I only need to test this scenario once in a while

Where to automate?
• Where there is repetition.
• If the requirements are mapped to test cases.
• For performance testing.
• If you have the time and money.
• If there is a permanent automation team.


Common Features of Testing Tools

• Record and Play Back.
• Scripting.
• Check Points/Verification Points.
• Test Execution.
• Data Tables.
• Test Execution Results. Test Logs.

Record And Playback.
• You can record testing actions and play them back to run a test.
• Its not used extensively in automation since
• Data and Commands are recorded together
• Very difficult to maintain.
• Difficult to generalize scripts.

Checkpoints
• Checkpoints are tools provided with the testing tool to test the state of an object in the AUT at a given point of time.
• Types of checkpoints
• Text Checkpoint
• Bitmap Checkpoint
• Database Checkpoint

Scripting
• Automation is programming.
• In QTP/Rational Robot, VB Script is used.
• Scripts can be written in the script editor.
• Recording actions will generate scripts.

Data Tables
• Data tables are tables where you can place the data needed for testing.
• You can access the data in the datatable through the script.
• In QTP the data tables can be loaded from an excel sheet.

Test Logs
• Test logs are the results of a test run
• Test logs are to be interpreted for actual test results.

Tuesday, October 28, 2008

VBScript - Launch QTP

VBScript - Launch QTP

An update to our QTP knowledge. What I have below is a script that will enable the user to automatically open QTP and run the desired QTP function that could be coded within a vbs script.

Here is the script.
You can use this script to launch QTP automatically and run the scripts anytime from any place. No need to copy the scripts into your machine at all.

' This is a base function to launch QTP automatically and run the desired functions.
Dim qtApp ‘ defines the object to invoke the application through late binding technique
' To set the QTP late binding object. This object will be used to invoke the application QTP and associate a late binding connection to it.

Set qtApp = CreateObject("QuickTest.Application")

' Launching QTP. Invokes QTP through the connection defined earlier
qtApp.Launch

' Ensuring that QTP is visible and available. It is an additional check to determine that the launch was successful.

qtApp.Visible = True

' Error if QTP is not launched. In case of QTP not being able to launch, the connection thread should be closed down and the reference to the application removed.

if err.number <> 0 then
msgbox "QTP could not be started"
qtApp.quit
end if

'Run the function which contains the QTP script which is available within a vbs file

Set objFSO = CreateObject("Scripting.FileSystemObject") ‘ This is the file system object object to set a late binding connection to the system files

Set objFile = objFSO.OpenTextFile("abhilash.vbs", ForReading) ‘ Opens a text file “abhilash.vbs” for reading. This file contains the QTP scripts i.e. functions

Execute objFile.ReadAll() ‘ to read the contents of the vbs file.

' here abhilash.vbs contains the normal QTP scripts

'QTP_Script1 will be a function name in the vbs which in turn contains the QTP SCRIPTS.

call QTP_script1() ‘This is a function within the vbs script abhilash.vbs

'set qtp object as nothing.

set qtApp = nothing ‘ Once the function is executed, close QTP. Now another user can use the connection.

This are the contents of abhilash.vbs

function QTP_script1()
msgbox "abhilash"
End function

Wednesday, October 15, 2008

Technical - Automation

Automation – QTP related tips.

Sureshot things you should remember

• Browser(“micClass:=Browser”) Used to refer to the Browser object • Page(“micClas:=Page”)

Used to refer to the Page

Object • WebEdit(“name:=txtAssertion”) Used to refer to a textfield • Eg Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”) Is used to refer to the textfield “newDescription” on the current page within the current browser. • To check the existence of the textfield Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).exist

To set the value of the textfield to “Abhilash”
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).Set “Abhilash”

• To check for buttons
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebElement(“innerte xt:=Save”, “html tag :=A”,”index:=1”).exist

• To click the Save button.
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebElement(“innerte xt:=Save”, “html tag :=A”,”index:=1”).Click

• To select an option from the dropdown
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=sel ectedEnumName”).select “Abhilash”

• To read the value of the textfield and store it in the variable
X X= Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).GetROProperty(“value”) (Any property can be used to access the value and store the same). • To select an option button. Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebCheckBox(“name =cmbCard”,”index:=2”).Set “ON”

• To derive the value from a datatable
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).Set datatable(“ControlDescription”, globalsheet)
Where ControlDescription is the name of the column and globalsheet refers to the global sheet.

• Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=ne wDescription”).Set datatable(“ControlDescription”, Sheet2)

Will read the data from Sheet2 under ControlDescription column

• Code for synchronization
Environment.Value(“Class”) :=”creationtime:=1”
Set X = Browser(Environment.Value(“Class”)).Object
While (X.Busy = True OR X.ReadyStatus <> 4)
Set X = Browser(Environment.Value(“Class”)).ObjectWait 1
Wend

4 indicates Completed (hence checks for Not Completed to ensurecorrectness).

Setting value to a listbox

Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=selectedGroup”).Select “Abhilash”

Getting value from a listbox

X=Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=selectedGroup”).GetROProperty(“selection”)

Clicking a link
Browser(“micClass:=Browser”).Page(“micClass:=Page”).Link(“name:=Clickhere”,”index:=0”).Click

Clicking a Webbutton
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebButton(“name:=Login”).Click
Or
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebElements(“name:=Save”).Click
Reading from a datatableBrowser(“micClass:=Browser”).Page(“micClass:=Page”).WebEdit(“name:=txtName”).Set Datatable(“FirstNames”,GlobalSheet)

Populating the WebList with the datatable contents
Browser(“micClass:=Browser”).Page(“micClass:=Page”).WebList(“name:=txtName”).Select Datatable(“FirstNames”,GlobalSheet)

Writing to datatable
Datatable(“FirstNames”,GlobalSheet) = “Abhilash”

To get the rowcount
intRow = DataTable.GetRowCount

To set the current row to 5
Datatable.GlobalSheet.SetCurrentRow(5)

Importing data from an Excel sheet
Datatable.ImportSheet , ,
Where is the Name or Index of the sheet is the name or index of the datatable.
Eg Datatable.ImportSheet “C:\Abhi\Abc.XLS”, 4,”Global”OrDatatable.ImportSheet “C:\Abhi\Abc.XLS”, “MYSheet”,”Global”


Environment Variables in QTP
ActionIteration : The action iteration currently running.
ControllerHostName : The name of the controller’s computer. This variable is relevant only when running as a GUI VUser from the LoadRunner controller.
GroupName : The name of the group in the running scenario. This variable is
relevant only when running as a GUI VUser from the LoadRunner controller.
LocalHostName: The local host name.
OS :The operating system.
OSVersion :The operating system version.
ProductDir :The folder path where the product is installed.
ProductName: The product name.
ProductVer :The product version.
ResultDir :The path of the folder in which the current test results are located.
ScenarioId: The identification number of the scenario.

Calorie Calculator

Calculate how much you expend in 1 hour of your favorite exercise. Health Tips.
Powered By Blogger

Followers

Images - Decision tables

Images - Decision tables
Important image details for the Decision tables

Risk Management

Risk Management
Risk Management