Qtp 简明教程

QTP - Quick Guide

QTP - Introduction

QTP 表示 Q*uick*T*est *P*rofessional, a product of *H*ewlett *P*ackard *(HP) 。该工具可帮助测试人员在完成脚本开发后,无缝执行自动化功能测试,而无需监控。

QTP stands for Q*uick*T*est *P*rofessional, a product of *H*ewlett *P*ackard *(HP). This tool helps testers to perform an automated functional testing seamlessly, without monitoring, once script development is complete.

HP QTP 使用 Visual Basic Scripting (VBScript) 来自动化应用程序。无需专门安装脚本引擎,因为它作为 Windows 操作系统的一部分提供。VBScript 的当前版本是 5.8,可作为 Win 7 的一部分提供。VBScript 不是面向对象语言,而是基于对象的语言。

HP QTP uses Visual Basic Scripting (VBScript) for automating the applications. The Scripting Engine need not be installed exclusively, as it is available as a part of the Windows OS. The Current version of VBScript is 5.8, which is available as a part of Win 7. VBScript is NOT an object-oriented language but an object-based language.

Testing Tools

从软件测试上下文来看,工具可以定义为支持从规划、要求、创建构建、测试执行、缺陷记录和测试分析等一项或多项测试活动的产品。

Tools from a software testing context, can be defined as a product that supports one or more test activities right from planning, requirements, creating a build, test execution, defect logging and test analysis.

Classification of Tools

可基于几个参数对工具进行分类。其中包括-

Tools can be classified based on several parameters. It includes −

  1. The purpose of the tool

  2. The activities that are supported within the tool

  3. The type/level of testing it supports.

  4. The kind of licensing (open source, freeware, commercial)

  5. The technology used

Types of Tools

Sr.No.

Tool Type

Used for

Used by

1

Test Management Tool

Test Managing, scheduling, defect logging, tracking and analysis.

Testers

2

Configuration management tool

For Implementation, execution, tracking changes

All Team members

3

Static Analysis Tools

Static Testing

Developers

4

Test data Preperation Tools

Analysis and Design, Test data generation

Testers

5

Test Execution Tools

Implementation, Execution

Testers

6

Test Comparators

Comparing expected and actual results

All Team members

7

Coverage measurement tools

Provides structural coverage

Developers

8

Performance Testing tools

Monitoring the performance, response time

Testers

9

Project planning and Tracking Tools

For Planning

Project Managers

10

Incident Management Tools

For managing the tests

Testers

Where QTP Fits in?

QTP 是一款功能测试工具,非常适合测试应用程序的回归测试。QTP 是 HP 拥有的一款授权/商业工具,是市场上最流行的工具之一。它比较实际结果和预期结果,并在执行摘要中报告结果。

QTP is a Functional testing tool, which is best suited for regression testing of the applications. QTP is a licensed/commercial tool owned by HP, which is one of the most popular tools available in the market. It compares the actual and the expected result and reports the results in the execution summary.

QTP – History and Evolution

惠普快速测试专业版最初由 Mercury Interactive 拥有,后来被 HP 收购。它最初的名称是 Astra Quick Test,后来命名为 Quick Test Professional,但最新版本称为 Unified Functional Tester (UFT)。

HP Quick Test Professional was originally owned by Mercury Interactive and it was acquired by HP. Its original name was Astra Quick Test and later named as Quick Test Professional but the latest version is known as Unified Functional Tester (UFT).

Version History

现在让我们来看一下 QTP 的版本历史。

Now let us take a look at the version history of QTP.

Versions

Timelines

Astra Quick Test v1.0 to v5.5 - Mercury Interactive

May 1998 to Aug 2001

QuickTest Professional v6.5 to v9.0 - Mercury Interactive

Sep 2003 to Apr 2006

Hp-QuickTest Professional v9.1 to v11.0 - Acquired and Released by HP

Feb 2007 to Sep 2010

Hp-Unified Functional Testing v11.5 to v11.53

2012 to Nov 2013

Advantages

  1. Developing automated tests using VBScript does not require a highly skilled coder and is relatively easy when compared to other object oriented programming languages.

  2. Easy to use, ease of navigation, results validation, and Report generation.

  3. Readily Integrated with Test Management Tool (Hp-Quality Center) which enables easy scheduling and monitoring.

  4. Can also be used for Mobile Application Testing.

  5. Since it is an HP product, full support is provided by HP and by its forums for addressing technical issues.

Disadvantages

  1. Unlike Selenium, QTP works in Windows operating system only.

  2. Not all versions of Browsers are supported and the testers need to wait for the patch to be released for each one of the major versions.

  3. Having said, that it is a commercial tool, the licensing cost is very high.

  4. Even though scripting time is less, the execution time is relatively higher as it puts load on the CPU & RAM.

QTP - Automated Testing Process

对于任何自动工具实现,以下是其阶段/步骤。每个阶段都对应于一个特定的活动,每个阶段都有一个明确的结果。

For any automated tool implementation, the following are the phases/stages of it. Each one of the stages corresponds to a particular activity and each phase has a definite outcome.

automation testing process
  1. Test Automation Feasibility Analysis − First step is to check if the application can be automated or not. Not all applications can be automated due to its limitations.

  2. Appropriate Tool Selection − The next most important step is the selection of tools. It depends on the technology in which the application is built, its features and usage.

  3. Evaluate the suitable framework − Upon selecting the tool, the next activity is to select a suitable framework. There are various kinds of frameworks and each framework has its own significance. We will deal with frameworks in detail later in this tutorial.

  4. Build Proof of Concept − Proof of Concept (POC) is developed with an end-to-end scenario to evaluate if the tool can support the automation of the application. It is performed with an end-to-end scenario, which ensures that the major functionalities can be automated.

  5. Develop Automation Framework − After building the POC, framework development is carried out, which is a crucial step for the success of any test automation project. Framework should be built after diligent analysis of the technology used by the application and also its key features.

  6. Develop Test Script, Execute, and Analyze − Once Script development is completed, the scripts are executed, results are analyzed and defects are logged, if any. The Test Scripts are usually version controlled.

QTP - Environment SetUp

QTP 是一个商业工具,您可以直接从惠普网站下载试用版。只有当前版本 Unified Functional Testing(11.5x)可以下载。以下是下载试用版的网址。

QTP is a commercial tool and the trial version can be downloaded from HP site directly. Only the current version, which is Unified functional testing (11.5x) is available for download. Following is the URL from where the trial version can be downloaded.

下载 URL − QTP

The Download URL − QTP

Installation Procedure

Step 1 − 单击“试用版和演示版”链接,然后选择“HP Unified Functional Testing 11.50 CC English SW E-Media Evaluation”,如下所示:

Step 1 − Click the "Trials and Demos" link and select "HP Unified Functional Testing 11.50 CC English SW E-Media Evaluation" as shown below −

download Install step1

Step 2 − 选择“HP Unified Functional Testing 11.50”后,将打开下载向导。填写个人详细信息,然后单击“下一步”。

Step 2 − After Selecting "HP Unified Functional Testing 11.50", the download wizard opens. Fill in the Personal details and click Next.

download Install step2

Step 3 -阅读“使用条款”,然后点击“下一步”。

Step 3 − Read the ‘Terms of Use’ and click "NEXT".

download Install step3

Step 4 -下载窗口打开。现在,点击“下载”按钮。

Step 4 − The Download window opens. Now, click the "Download" button.

download Install step4

Step 5 -下载的文件格式为.RAR。现在,您需要解压该存档文件,文件夹内容将如下图所示,执行 Setup.exe。

Step 5 − The downloaded file will be of the format .RAR. Now you need to unzip the archive and the folder contents would be as shown below and execute the Setup.exe.

download Install step5

Step 6 -执行安装文件后,为了安装,从列表中选取“统一功能测试设置”,如下图所示。

Step 6 − Upon Executing the Setup File, in order to install, select "Unified Functional Testing Set up" from the list as shown below −

download Install step6

Step 7 -然后点击“下一步”以继续。

Step 7 − Then click Next to continue.

download Install step7

Step 8 -在定制设置窗口中,选取自动化所需的插件,即您应该根据测试应用程序的技术选取插件。例如,如果您的应用程序基于.NET,那么您应该确保选取.NET。

Step 8 − In the Custom Set up Window, select the plugins that are required for your automation i.e. you should select the plugins based on the technology of your application under test. For Example, if your application is based on .NET then you should ensure that you select .NET.

download Install step8

Step 9 -选取安装所需的插件后,点击“下一步”。安装完成后,您会看到一个“完成”按钮窗口。

Step 9 − After selecting the required plugins for installation, click Next. After the completion of installation, you will end up with a Finish button Window.

download Install step10

Step 10 -安装完成后,“其他安装要求”对话框框打开。除“运行许可证安装向导”外,选取列表中的所有内容,然后点击“运行”。我们无须选取“运行许可证安装向导”,因为我们安装的是试用版,它默认提供 30 天许可证。

Step 10 − Once you complete your installation, the "Additional Installation Requirements" Dialog box opens. Select everything in the list other than "Run License Installation Wizard" and click "RUN". We Need NOT select "Run License Installation Wizard" because we are installing the trial version, which, by default, gives a license for 30 days.

download Install step11

Step 11 -在其他安装要求完成后,会显示一个对勾标记,这说明组件已成功安装。现在,点击“关闭”。

Step 11 − After the completion of Additional Installation Requirements, a tick mark is shown, which in turn states that the components are installed successfully. Now, click Close.

download Install step12

Launching UFT and Add ins Page

Step 1 -安装后,可以从开始菜单启动应用程序,如下图所示。

Step 1 − After Installation, application can be launched from the Start Menu as shown in the figure.

download Install step13

Step 2 -许可证页面出现。我们可以点击“继续”,因为我们已经安装了试用许可证。

Step 2 − The license page appears. You can click Continue as we have installed the trial license.

download Install step14

Step 3 -出现加载项对话框框,供用户选取所需的加载项。

Step 3 − The Add-ins dialog box opens for the user to select the required add-ins.

Note -不要加载所有加载项,仅加载所需的加载项,然后点击“确定”。

Note − Do not load all the add-ins but just the required add-ins and click OK.

download Install step15

Step 4 -加载所需加载项后,UFT 11.5 工具对用户打开,UFT 的第一眼印象如下所示:

Step 4 − After loading the required add-ins, the UFT 11.5 tool opens for the user and the first glimpse of the UFT looks, as shown below −

download Install step16

QTP - Record and Playback

记录测试相当于记录被测应用程序的用户操作,以便 UFT 自动生成可以播放的脚本。如果初始设置完成正确,则记录和回放可以让我们初步了解该工具,以及它是否能支持该技术。

Recording a test corresponds to recording the user actions of the application under test so that UFT automatically generates the scripts that can be played back. Record and Playback can give us the first impression of the tool, whether it can support the technology or not, if the initial settings are done correctly.

记录和回放的步骤如下 -

Steps for Record and Playback are as follows −

Step 1 − 如下所示,从主页中单击“新建”测试 -

Step 1 − Click "New" test from the Start Page as shown below −

qtp record and run settings step1

Step 2 − 单击“新建”链接时,将打开一个新的测试窗口,并且用户需要选择测试类型。选择“GUI 测试”,为测试命名,并选择需要保存它的位置。

Step 2 − Clicking "New" Link, a new test window opens and the user needs to select the test type. Select "GUI Test", give a name for the test and the location where it needs to be saved.

qtp record and run settings step2

Step 3 − 创建新测试后,将打开新的测试屏幕,如下所示。现在,单击默认创建有 1 个操作的“Action1”选项卡。

Step 3 − Once a New test is created, the new test screen opens as shown below. Now, click the "Action1" tab, which is created with 1 action by default.

qtp record and run settings step3

Step 4 − 单击“录制”菜单,然后选择“录制和运行设置”,如下所示 -

Step 4 − Click the "Record" Menu and select "Record and Run Settings" as shown below −

qtp record and run settings step4

Step 5 − 将打开录制和运行设置对话框,并且根据应用程序的类型,可以选择 Web、Java 或 Windows 应用程序。例如,此处,我们将录制一个基于 Web 的应用程序 ([role="bare"] [role="bare"]http://easycalculation.com/ )。

Step 5 − The Record and Run Settings dialog box opens and based on the type of application, one can select Web, Java, or Windows Applications. For Example, here, we will record a Web Based Application ([role="bare"]http://easycalculation.com/).

qtp record and run settings step5

Step 6 − 单击录制。Internet Explorer 会根据设置自动打开 Web 地址 https://www.easycalculation.com/ 。单击“代数”下的“数字”链接,并且输入一个数字并点击“计算”。完成该操作后,单击录制面板中的“停止”按钮。您将注意到生成以下脚本:-

Step 6 − Click Record. The Internet Explorer opens automatically with the web address https://www.easycalculation.com/ as per the settings. Click the "Numbers" link under "Algebra" and key in a number and hit "Calculate". After completion of the action, click the "Stop" button in the record panel. You will notice that the script is generated as shown below −

qtp record and run settings step6

Step 7 − 现在,通过单击回放按钮回放脚本。脚本回放,并且结果显示出来。

Step 7 − Now playback the script by clicking the playback button. The Script replays and the result is displayed.

qtp record and run settings step7

Step 8 − 结果窗口默认打开,它准确显示执行、通过和失败步骤的时间戳。

Step 8 − The result window is opened, by default, which exactly shows the timestamp of execution, pass and failed steps.

qtp record and run settings step8

Significance of Record and Playback

  1. It is used as the preliminary investigation method to verify if UFT can support the technology/application.

  2. Used to create a test a basic functionality of an application or feature that does not require long-term maintenance.

  3. It can be used for recording both mouse movements and keyboard inputs.

Modes of Recording

  1. Normal Recording − This is the default Recording mode that records the objects and the operations performed on the application under test.

  2. Analog Recording − This records not only the keyboard actions but also the mouse movements relative to the screen or the application window.

  3. Low-Level Recording − This records the exact co-ordinates of the objects independent of the fact whether UFT recognizes the object or NOT. It just records the co-ordinates, hence does NOT record mouse movements.

  4. Insight Recording − UFT records operations, based on its appearance and not based on its native properties.

How to Choose Recording Modes

在单击录制按钮后,一旦录制开始,用户便可以在屏幕上出现的录制窗格中选择录制模式。可以从上述讨论过的模式中进行选择。

After clicking the Recording button, the user can choose the recording mode from the recording pane that appears on the screen, once the recording starts. The selection can be made from any of the ones that has been discussed above.

qtp choosing recording modes

您将会看到,以下场景记录在所有模式中,并且同一样例记录在各种情况下。

You will see that the following scenario is recorded in all the modes and the same action has been recorded under various circumstances.

  1. Launch IE - https://www.easycalculation.com/

  2. Click "Numbers" under "Algebra"

  3. Click "Square Root" link

  4. Enter a value to calculate the square root. Let us say 10

  5. Hit Calculate

在默认、模拟和低级记录模式下记录的脚本如下 −

Script Recorded under Default, Analog and Low Level recording mode is given below −

' DEFAULT RECORDING MODE
Browser("Free Online Math Calculator").Page("Free Online Math
Calculator").Link("Numbers").Click

Browser("Free Online Math Calculator").Page("Numbers Calculator -
Math").Link("Square Root").Click

Browser("Free Online Math Calculator").Page("Square Root
Calculator").WebEdit("n").Set "10"

Browser("Free Online Math Calculator").Page("Square Root
Calculator").WebButton("calculate").Click

' ANALOG RECORDING MODE
Desktop.RunAnalog "Track1"

' LOW LEVEL RECORDING MODE
Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Click
235,395

Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Click
509,391

Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Click
780,631

Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Type
"10"

Window("Windows Internet Explorer").WinObject("Internet Explorer_Server").Click
757,666

使用 Insight 记录模式的记录如下 −

The recordings using insight recording mode will be as shown below −

recording mode comparison

QTP - Object Repository

Object Repository

对象存储库是对象和属性的集合,QTP 可以识别这些对象并作用于它们。当用户记录测试时,会默认捕获对象及其属性。如果不了解对象及其属性,QTP 将无法回放脚本。

Object Repository is a collection of object and properties with which QTP will be able to recognize the objects and act on it. When a user records a test, the objects and its properties are captured by default. Without understanding objects and its properties, QTP will NOT be able to play back the scripts.

单击以下每个主题,以详细了解对象存储库及其相关功能。

Click on each one of the following topics to know more about Object Repository and its associated features.

Sr.No.

Topic & Description

1

Object Spy and its FeaturesTo understand the usage of object spy and its associated functionalities.

2

Working with Object RepositoryAdding, editing, deleting objects from an Object Repository and its associated functionalities.

3

Types of Object RepositoryDeals with shared Object and local Object Repository and their context with respect to scripting.

4

User-defined ObjectsDeals with the circumstances to use the User-Defined Objects.

5

Object Repository in XMLDeals with converting OR’s to XML and using the object Repository as XML.

6

Comparing and Merging OROperations such as Compare OR', Merge OR’s to effectively work with Object Repository.

7

Ordinal IdentifiersCircumstances where the ordinal identifiers are used and its advantages.

8

Child ObjectsUsing Child Objects for effective scripting

QTP - Actions

操作可帮助测试员将脚本划分为 QTP 语句组。操作类似于 VBScript 中的函数,但是有一些不同点。默认情况下,QTP 使用一个操作创建测试。

Actions helps testers to divide scripts into groups of QTP statements. Actions are similar to functions in VBScript; however, there are a few differences. By default, QTP creates a test with one action.

Actions

Functions

Action is an in-built feature of QTP.

VBScript Functions are supported by both VBScript and QTP.

Actions parameters are passed by value only.

Function parameters are passed either by by value or by ref.

Actions have extension .mts

Functions are saved as .vbs or .qfl

Actions may or may not be reusable.

Functions are always reusable.

可以通过右键单击脚本编辑器窗口并选择“属性”,访问操作的属性。

The properties of the action can be accessed by right clicking on the Script Editor Window and selecting "Properties".

qtp actions 1

操作属性包括以下信息-

Action properties contains the following information −

  1. Action Name

  2. Location

  3. Reusable Flag

  4. Input Parameters

  5. Output Parameters

Types of Actions

共有三种类型的操作-

There are three types of actions −

  1. Non-reusable action − An action that can be called only in that specific test in which it has been designed and can be called only once.

  2. Reusable action − An action that can be called multiple times, any test in which it resides, and can also be used by any other tests.

  3. External Reusable action − It is a reusable action stored in another test. External actions are read-only in the calling test, but it can be used locally with the editable copy of the Data Table information for the external action.

Working with Actions

有三种方法来插入操作。单击其中任何一个了解更多有关所选操作类型的信息。

There are three options to insert an action. Click on each one of those to know more about the selected type of action.

Sr.No.

Action Type & Description

1

Insert Call to New ActionInserts a New Action from the existing action

2

Insert Call to Copy of ActionInserts a copy of an existing action

3

Insert Call to Existing ActionInserts a call to existing re-usable action

QTP - Datatables

数据表(类似于 Microsoft Excel)帮助测试者创建可以用于多次运行操作的数据驱动测试用例。有两种数据表 −

A DataTable, similar to Microsoft Excel, helps the testers to create data-driven test cases that can be used to run an Action multiple times. There are two types of Datatables −

  1. Local DataTable − Each action has its own private datatable, also known as local datatable, which is can also be accessed across actions.

  2. Global DataTable − Each test has one global data sheet that is accessible across actions.

数据表可以从 QTP 的“数据”选项卡中访问,如下所示 −

The data sheet can be accessed from the "Data" Tab of QTP as shown below −

qtp datasheet 1

要对指定的迭代次数执行一个测试用例,可以在测试设置对话框中设置全局数据表的迭代,可以通过文件→设置→运行(选项卡)访问,如下所示 -

To execute a test case for some specified number of iterations, one can set the iterations of global datatable in the Test Settings dialog, that can be accessed using File → Settings → Run(Tab) as shown below −

qtp datasheet 3

Example

例如,如果用户希望对可以通过 http://easycalculation.com/compound-interest.php 访问的“复合利息” http://easycalculation.com/ 进行参数化。可以创建参数,如下所示。数据表中也可以使用 Excel 的大多数功能。

For example, if a user wants to parameterize "compound Interest" of http://easycalculation.com/ that can be accessed using http://easycalculation.com/compound-interest.php. The Parameters can be created as shown below. Most of the functionalities of Excel can be used in Data table as well.

qtp datasheet 2

DataTable Operations

有三种类型的对象可以访问 DataTable。DataTable 操作可以通过遍历以下内容来很好地理解 -

There are three types of objects to access DataTable. DataTable operations can be well understood by traversing through the following −

Sr.No.

Object Type & Description

1

Data Table MethodsGives detailed information about the data table methods.

2

DTParameter Object MethodsGives detailed information about the DTParameter methods.

3

DTSheet Object MethodsGives detailed information about the DTSheet methods.

QTP - CheckPoints

如名称所述,检查点是指将当前值指定属性或对象的当前状态与预期值相比较的验证点,可以插入到脚本中的任何时间点。

Checkpoints, as the name says it all, refer to a validation point that compares the current value of specified properties or current state of an object with the expected value, which can be inserted at any point of time in the script.

Types of Checkpoints

Sr.No.

Type & Description

1

Standard Checkpoint Verifies the property values of an object in application under test and supported by all add-in environments.

2

Bitmap Checkpoint Verifies an area of your application as a bitmap

3

File Content Checkpoint Verifies the text in a dynamically generated or accessed file such as .txt,.pdf

4

Table Checkpoint Verifies the information within a table. Not all environments are supported.

5

Text Checkpoint Verify if the text that is displayed within a defined area in a Windows-based application, according to specified criteria.

6

Text Area Checkpoint Verifies if the text string is displayed within a defined area in a Windows-based application, according to specified criteria.

7

Accessibility Checkpoint Verifies the page and reports the areas of the Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines

8

Page Checkpoint Verifies the characteristics of a Web page. It can also check for broken links.

9

Database Checkpoint Verifies the contents of a database accessed by the application under test.

10

XML Checkpoint Verifies the content of the .xml documents or .xml documents in Web pages and frames.

Inserting CheckPoint

当用户想要插入一个检查点时,必须确保在录制期间仅支持大多数检查点。一旦用户停止录制,检查点将不可用。

When the user wants to insert a checkpoint, one has to ensure that most of the checkpoints are supported during the recording sessions only. Once the user stops recording, checkpoints are not enabled.

以下是在非录制模式下,检查点菜单。

Given below is the checkpoint menu, when the user is NOT in the recording mode.

qtp checkpoint before recording

以下是在录制模式下,检查点菜单。

Given below is the checkpoint menu, when the user is in the recording mode.

qtp checkpoint after recording 1

Example

可为测试应用程序添加检查点 — “http://easycalculation.com/”

The checkpoints are added for the application under test - "http://easycalculation.com/"

' 1. Inserted Standard Checkpoint
Status = Browser("Math Calculator").Page("Math
   Calculator").Link("Numbers").Check CheckPoint("Numbers")

If Status Then
   print "Checkpoint Passed"
Else
   Print "Checkpoint Failed"
End if

' 2. Inserted BitMap Checkpoint
imgchkpoint = Browser("Math Calculator").Page("Math
   Calculator").Image("French").Check CheckPoint("French")

If imgchkpoint Then
   print "Checkpoint Passed"
Else
   Print "Checkpoint Failed"
End if

Viewing Checkpoint Properties

插入后,如果测试人员想要更改值,可以通过右键单击脚本中的关键字“检查点”并导航到“检查点属性”以进行更改,如下所示 −

After inserting, in case a tester want to change the values, we can do so by right clicking on the keyword 'checkpoint' of the script and navigating to "Checkpoint Properties" as shown below −

qtp checkpoint after recording 2

您还可以在对象储存库中找到相同的检查点,如下所示。它准确显示了使用哪种类型的检查点、期望值和超时值。

You can locate the same checkpoints in object repository, as well, as shown below. It exactly shows what type of checkpoint is used and what are the expected values, and time out values.

qtp checkpoint after recording 3

QTP - Synchronization

同步点是待测试工具和应用程序之间的时序接口。同步点是一项用于指定测试脚本的两个步骤之间延迟时间的特性。

Synchronization point is the time interface between Tool and Application under test. Synchronization point is a feature to specify the delay time between two steps of the test script.

例如,单击一个链接可能在 1 秒内加载页面,有时候需要 5 秒,甚至可能需要 10 秒才能完全加载。这取决于各种因素,例如应用程序服务器响应时间、网络带宽和客户端系统功能。

For example, clicking on a link may load the page is 1 second, sometimes 5 seconds or even it may take 10 seconds to load it completely. It depends on various factors such as the application-server response time, network bandwidth, and client system capabilities.

如果时间不一致,则脚本将失败,除非测试人员智能地处理这些时间差异。

If the time is varying then the script will fail, unless the tester handles these time differences intelligently.

Ways to Insert Sync Point

  1. WaitProperty

  2. Exist

  3. Wait

  4. Sync(only for web based apps)

  5. Inserting QTP Inbuilt Synchronization points.

假设我们在 “@{}” 中单击“数字”链接和单击“简单利息”计算器之间需要插入一个同步点。对于上述场景,我们将研究插入同步点的五种方式。

Let us say, we need to insert a sync point between clicking on "numbers" link and clicking on "simple Interest" calculator in "www.easycalculation.com". We will now take a look at all the five ways to insert sync point for the above scenario.

Method 1 − WaitProperty

WaitProperty 是一种方法,将属性名称、值和超时值作为输入以执行同步。它是一个动态等待,因此建议使用此选项。

WaitProperty is a method that takes the property name, Value and Timeout value as input to perform the sync. It is a dynamic wait and hence, this option is encouraged.

' Method 1 - WaitProperty with 25 seconds
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click

obj.Link("Simple Interest").WaitProperty "text", "Simple Interest",25000
obj.Link("Simple Interest").Click

Method 2 − Exist

Exist 是一种方法,将超时值作为输入以执行同步。它也是一个动态等待,因此建议使用此选项。

Exist is a method that takes the Timeout value as input to perform the sync. Again, it is a dynamic wait and hence this option is encouraged.

' Method 2 : Exist Timeout - 30 Seconds
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click

If obj.Link("Simple Interest").Exist(30) Then
   obj.Link("Simple Interest").Click

Else
   Print "Link NOT Available"
End IF

Method 3 − Wait

Wait 是一个硬编码的同步点,与事件是否发生无关的等待。因此,不建议使用 Wait,并且仅可用于较短的等待时间,如 1 秒或 2 秒。

Wait is a hardcoded sync point, which waits independent of the event happened or NOT. Hence, usage of Wait is discouraged and can be used for shorter wait time such as 1 or 2 seconds.

' Method 3 : Wait Timeout - 30 Seconds
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click
wait(30)
Browser("Math Calculator").Page("Math Calculator").Link("Simple Interest").Click

Method 4 − Sync Method

同步方法仅可用于页面加载之间始终存在延迟的 Web 应用程序。

Sync Method can be used only for web applications where there is always a lag between page loads.

' Method 4 :
Dim obj
Set obj = Browser("Math Calculator").Page("Math Calculator")
obj.Link("Numbers").Click

Browser("Math Calculator").Sync
Browser("Math Calculator").Page("Math Calculator").Link("Simple Interest").Click

Method 5 − Inserting QTP Inbuilt Synchronization points

@{}− 进入记录模式。如果用户不在记录模式内,此选项将被禁用。

Step 1 − Get into Recording Mode. This option would be disabled if the user is NOT in Recording Mode.

@{}− 转到“设计”→“同步点”。

Step 2 − Go to "Design" → "Synchronization Point".

@{}− 我们需要选择要作为同步点的对象。在选择该对象后,会像下面所示打开一个对象窗口 −

Step 3 − We need to select the object, which we want to be the Sync Point. After selecting the object, object window opens as shown below −

qtp sync point 1

@{}− 单击“确定”,将打开“添加同步窗口”。选择“属性”、“值”和“超时”值,然后单击“确定”,如以下所示 −

Step 4 − Click OK; the "Add Synchronization Window" opens. Select the Property, Value and Time out value and click OK as shown below −

qtp sync point 2

@{}− 会生成如下图所示的脚本,它与我们之前讨论过的 WaitProperty(方法 1)相同 −

Step 5 − The script would be generated as shown below, which is the same as that of the WaitProperty(Method 1) that we had already discussed −

Browser("Math Calculator").Page("Math Calculator").Link("Numbers").Click

Browser("Math Calculator").Page("Math Calculator").Link("Simple
   Interest").WaitProperty "text", "Simple Interest", 10000

Default Synchronization

当用户未对上述任何一种同步方法使用任何方法时,QTP 仍可使用用户可以调整的固有的对象同步超时。

When the user has not used any of the above sync methods, still QTP has an in-built Object synchronization timeout which can be adjusted by the user.

导航至“文件”>> “设置”>> “运行”选项卡 >> “对象同步超时”,如以下所示。

Navigate to "File" >> "Settings" >> Run Tab >> Object Synchronization Time out as shown below.

qtp sync point 3

QTP - Smart Identification

有时,QTP 无法找到与识别的对象描述相匹配的任何对象,或者它可能会找到多个适合该描述的对象,然后 QTP 将忽略识别的描述并使用智能识别机制识别对象。

Sometimes, QTP is unable to find any object that matches the recognized object description or it may find more than one object that fits the description, then QTP ignores the recognized description and uses the Smart Identification mechanism to recognize the object.

QTP 的智能识别使用两种类型的属性 -

QTP’s Smart Identification uses two types of properties −

  1. Base Filter Properties − The basic properties of a particular test object class whose values cannot be changed without changing the essence of the original object.

  2. Optional Filter Properties − Other properties also assist in identifying the objects of a particular class whose properties are unlikely to change often but can be ignored if they are no longer applicable.

Enabling Smart Identification for an Object

Step 1 - 导航到“工具”→“对象识别”。对象识别对话框打开。

Step 1 − Navigate to "Tools" → "Object Identification". Object Identification dialog opens.

Step 2 - 选择环境、对象类并打开“启用智能识别”,如下所示 -

Step 2 − Choose the Environment, Object Class and Turn ON "Enable Smart Identification" as shown below −

qtp smart identification

Step 3 - 单击“配置”并选择基础和可选筛选器属性。

Step 3 − Click Configure and choose the base and Optional Filter Properties.

qtp smart identification 1

Step 4 - 在基础属性中添加除默认属性之外的属性,还可以添加/删除可选筛选器属性。请注意,相同的属性不能同时属于强制属性和辅助属性,然后单击“确定”。

Step 4 − Add Properties in Base Properties apart from the default one and also add/remove Optional Filter Properties. Please note that same properties cannot be a part of both Mandatory and Assistive Properties and click "OK".

qtp smart identification 2

Step 5 - 在对象存储库中添加该类型对象后,验证是否启用智能识别。智能识别已设置为 TRUE。在不需要启用智能识别的情况下,也可以将其设置为 False。

Step 5 − Verify if the Smart Identification is enabled after adding object of that type in the Object Repository. Smart Identification is set to TRUE. We can also make it False in case we do not want to enable Smart Identification.

qtp smart identification 3

Step 6 - 甚至可以通过在“文件”菜单的“设置”下应用测试脚本级别来禁用测试级别,如下所示:

Step 6 − We can even disable a test Level by applying at test script level under "Settings" of "File" Menu as shown below −

qtp smart identification 4

Step 7 - 如果根据步骤 6 禁用智能识别,它将在脚本执行期间不会对任何对象应用智能识别。

Step 7 − If the Smart Identification is disabled as per Step# 6 then it will not apply smart identification for any object during the script execution.

Step 8 - 如果使用关闭状态添加对象,则 QTP 将不会使用智能识别来进行识别,即使我们稍后已将其启用。

Step 8 − In case the objects are added with Smart Identification as Off, QTP will not use Smart Identification for recognizing in future, even though we have enabled it later.

QTP - Debugging

在自动化测试环境中,调试是对自动化脚本中的编码问题进行识别和修复的一个系统性过程,以便脚本更加稳健,并可以在应用程序中识别缺陷。

Debugging, in automation testing context, is a systematic process of spotting and fixing the coding issues in the automation script so that the script will be more robust and can spot the defects in the application.

使用 QTP 中的断点有各种执行调试的方法。只需按“F9”或使用菜单选项“运行”→“插入/删除断点”即可插入断点。

There are various ways to perform debugging using break points in QTP. Break points can be inserted just by pressing "F9" or by using the Menu option "Run" → "Inserting/Removing Break Point".

插入断点后,“红色”点和行将突出显示为红色,如下所示 −

After Inserting the Break point, the "Red Colored" Dot and the line will be highlighted in RED as shown below −

qtp debugging

Method

ShortCut

Description

Step Into

F11

Used to execute each and every Step. Steps into the Function/Action and executes line by line. It pauses on each line after execution.

Step Over

F10

Used to Step over the Function. Step Over runs only the current step in the active document.

Step Out

Shift+F11

After Step Into the function, you can use the Step Out command. Step Out continues the run to the end of the function and then pauses the run session at the next line.

Options in Break Point

可以通过导航“运行”菜单访问断点中的各种选项。

Various Options in Break Point can be accessed by Navigating through the 'Run' Menu.

Sr.No.

ShortCut & Description

1

F9 Insert/Remove BreakPoint

2

Ctrl+F9 Enable/Disable BreakPoint

3

Ctrl+Shift+F9 Clear All BreakPoint

4

Use Only Menu Enable/Disable All BreakPoints

Debugging Pane

调试窗口中的窗格如下 −

The following are the panes in the debugging window −

qtp debugging 3
  1. Output − This Tab displays all the Output of the Print Statements.

  2. Watch − This Tab displays the Boolean output of the Given Expression.

  3. LocalVariables − This Tab displays the Output of the Local Variables.

Example

监视窗格显示输出表达式,如下所示 −

The Watch Pane shows the output expression as shown below −

qtp debugging 2

本地变量窗格显示本地变量保存的值,如下所示 −

The Local Variables Pane shows the values held by the local variables as shown below −

qtp debugging 4

QTP - Error Handling

在 QTP 中处理错误有多种方法。在使用 QTP 时,可能遇到三种可能的错误类型:

There are various ways of handling errors in QTP. There are three possible types of errors, one would encounter, while working with QTP. They are −

  1. Syntax Errors

  2. Logical Errors

  3. Run Time Errors

Error Types

Syntax Errors

语法错误是与 VBScript 语言语法不符的错误或代码片段。语法错误发生在代码编译时,在这些错误得到修复之前无法执行。

Syntax errors are the typos or a piece of the code that does not confirm with the VBscripting language grammar. Syntax errors occur at the time of compilation of code and cannot be executed until the errors are fixed.

若要验证语法,可以使用键盘快捷键 Ctrl+F7,结果显示在下边。如果窗口未显示,则可以导航至“视图”→“错误”。

To verify the syntax, use the keyboard shortcut Ctrl+F7 and the result is displayed as shown below. If the window is not displayed one can navigate to "View" → "Errors".

qtp error handling 1

Logical Errors

如果脚本的语法正确,但是生成了意外的结果,则称为逻辑错误。逻辑错误通常不会中断执行,但是会生成错误的结果。逻辑错误可能由于各种原因导致,例如:错误的假设或需求错误理解,有时还会产生错误的程序逻辑(使用 do-while 代替 do-Until)或无限循环。

If the script is syntactically correct but it produces unexpected results, then it is known as a Logical error. Logical error usually does not interrupt the execution but produces incorrect results. Logical errors could occur due to variety of reasons, viz- wrong assumptions or misunderstandings of the requirement and sometimes incorrect program logics (using do-while instead of do-Until) or Infinite Loops.

检测逻辑错误的一种方法是进行同行评审,还要验证 QTP 输出文件/结果文件,以确保该工具按预期方式执行。

One of the ways to detect a logical error is to perform peer reviews and also verify the QTP output file/result file to ensure that the tool has performed the way it was supposed to do.

RunTime Errors

顾名思义,此类错误发生在运行时。此类错误的原因是脚本尝试执行某项操作但无法执行,而且脚本通常停止执行,因为它无法继续执行。运行时错误的经典示例是:

As the name states, this kind of error happens during Run Time. The reason for such kind of errors is that the script trying to perform something is unable to do so and the script usually stops, as it is unable to continue with the execution. Classic examples for Run Time Errors are −

  1. File NOT found but the script trying to read the file

  2. Object NOT found but the script is trying to act on that particular object

  3. Dividing a number by Zero

  4. Array Index out of bounds while accessing array elements

Handling Run-Time Errors

处理代码中错误有多种方法。

There are various ways to handle errors in the code.

1. Using Test Settings - 可以通过导航至“文件”>>“设置”>>“运行”选项卡来在测试设置中定义错误处置,如下所示。我们可以选择任何指定设置,然后单击“确定”。

1. Using Test Settings − Error handling can be defined the Test Settings by Navigating to "File" >> "Settings" >> "Run" Tab as shown below. We can select any of the specified settings and click "OK".

qtp error handling 2

2. Using On Error Statement - 测试者可以将“On Error”语句用于通知 VBScript 引擎其打算处理运行时错误,而不是允许 VBScript 引擎显示用户不友好的错误消息。

2. Using On Error Statement − The ‘On Error’ statement is used to notify the VBScript engine of intentions to handle the run-time errors by a tester, rather than allowing the VBScript engine to display error messages that are not user-friendly.

  1. On Error Resume Next − On Error Resume Next informs the VBScript engine to process executing the next line of code when an error is encountered.

  2. On error Goto 0 − This helps the testers to turn off the error handling.

3. Using Err Object - 错误对象是 VBScript 内的一个内置对象,可以捕获我们能够方便调试代码的运行时错误编号和错误描述。

3. Using Err Object − Error object is an in-built object within VBScript that captures the run-time error number and error description with which we are able to debug the code easily.

  1. Err.Number − The Number property returns or sets a numeric value specifying an error. If Err.Number value is 0 then No error has occurred.

  2. Err.Description − The Description property returns or sets a brief description about an error.

  3. Err.Clear − The Clear method resets the Err object and clears all the previous values associated with it.

Example

'Call  the function to Add two Numbers Call Addition(num1,num2)

Function Addition(a,b)
   On error resume next
      If NOT IsNumeric(a) or IsNumeric(b) Then
         Print "Error number is  " &  err.number & " and description is :
            " &  err.description
         Err.Clear
         Exit Function
      End If
   Addition = a+b

   'disables error handling
   On Error Goto 0
End function

4. Using Exit Statement − Exit 语句可以与 Err 对象结合使用,以基于 Err.Number 值退出测试、操作或迭代。让我们详细了解每个 Exit 语句。

4. Using Exit Statement − Exit Statements can be used along with Err object to exit from a test or action or iteration based on the Err.Number value. Let us see each one of those Exit statements in detail.

  1. ExitTest − Exits from the entire QTP test, no matter what the run-time iteration settings are.

  2. ExitAction − Exits the current action.

  3. ExitActionIteration − Exits the current iteration of the action.

  4. ExitTestIteration − Exits the current iteration of the QTP test and proceeds to the next iteration.

5. Recovery Scenarios − 遇到错误时,基于特定条件触发恢复场景,并在单独的章节中详细介绍。

5. Recovery Scenarios − Upon encountering an error, recovery scenarios are triggered based on certain conditions and it is dealt in detail in a separate chapter.

6. Reporter Object − Reporter 对象帮助我们将事件报告给运行结果。它帮助我们识别相关的操作/步骤是通过/失败。

6. Reporter Object − Reporter Object helps us to report an event to the run results. It helps us to identify if the concerned action/step is pass/fail.

'Syntax: Reporter.ReportEventEventStatus, ReportStepName, Details,
[ImageFilePath]

'Example
Reporter.ReportEvent micFail, "Login", "User is unable to Login."

QTP - Recovery Scenarios

Recovery Scenarios

在执行 QTP 脚本时,我们可能会遇到一些意外错误。为了恢复测试并继续执行其余脚本,我们可使用以下意外错误进行恢复方案。可以通过导航到“资源”→恢复方案管理器进行访问恢复方案管理器,如下所示 −

While executing the QTP scripts, we might get some unexpected errors. In order to recover the tests and continue executing the rest of the script from these unexpected errors, Recovery Scenarios are used. The Recovery Scenario Manager can be accessed by Navigating to "Resources" → Recovery Scenario Manager as shown below −

qtp recovery scenario 1

Steps to Create Recovery Scenario

Step 1 − 单击“新建”恢复方案按钮;恢复方案向导将按如下所示打开 −

Step 1 − Click "New" Recovery Scenario button; the Recovery Scenario Wizard opens as shown below −

qtp recovery scenario 2

Step 2 − 选择触发器事件。它对应于可能在以下四种事件中发生的事件 −

Step 2 − Choose the Trigger Event. It corresponds to event, which can arise in any of the following four events −

  1. Pop-Up Window

  2. Object State

  3. Test Run Error

  4. Application Crash

Step 3 − 恢复操作窗口打开。恢复操作可以执行以下任何操作,如下面的屏幕截图所示 −

Step 3 − The Recovery Operations Window opens. Recovery Operation can perform any of the following Operation as shown in the screenshot below −

qtp recovery scenario 4

Step 4 − 指定适当的恢复操作后,我们还需要指定后恢复操作,如下所示 −

Step 4 − After specifying the appropriate Recovery Operation, we need to specify the Post Recovery Operation as well, as shown below −

qtp recovery scenario 5

Step 5 − 指定后恢复操作后,应命名恢复方案并将其添加到测试中,以便激活它。

Step 5 − After specifying the Post Recovery Operation, the recovery scenario should be named and added to the Test so that it can be activated.

qtp recovery scenario 6

Step 6 − 恢复方案的创建已完成,需要通过选中“将方案添加到当前测试”选项并单击“完成”将其映射到当前测试。

Step 6 − The Recovery Scenario creation is complete and needs to be mapped to the current Test by checking the option "Add Scenario to the current Test" and click "Finish".

qtp recovery scenario 7

Step 7 − 添加的恢复方案将如下所示,单击“关闭”按钮以继续。

Step 7 − The Added Recovery Scenario will be as shown below and click the "Close" Button to continue.

qtp recovery scenario 8

Step 8 − 单击关闭按钮后,QTP 会提示用户保存创建的恢复方案。它将使用扩展名 .qrs 保存,向导将关闭。

Step 8 − After clicking the Close button, QTP would prompt the user to save the created Recovery scenario. It will be saved with the extension .qrs and the wizard would close.

qtp recovery scenario 9

Verification

创建的恢复方案现在应当成为测试的一部分,可以通过导航到“文件”→“设置”→“恢复”选项卡来验证此方案。

The Created Recovery Scenario should be a part of the test now and can be verified by navigating to "File" → "Settings" → "Recovery" Tab.

qtp recovery scenario 9

QTP - Environment Variables

QTP 环境变量是可由所有操作、函数库和恢复场景访问的特殊类型的变量。Windows 中有内置的环境变量,可供在该特定系统上运行的所有应用程序使用,但 QTP 环境变量在运行时仅可供该特定测试脚本使用。

QTP environment variables are special types of variables that can be accessed by all actions, function libraries, and recovery scenarios. There are in-built environment variables for Windows that are available to all the applications running on that particular system, but QTP environment variables are only available to that particular test script during run-time.

Types of Environment Variables

Built-in Environment Variables −提供一系列环境参数,这些参数可提供诸如测试名称、操作名称、测试路径、本地主机名、操作系统名称、类型及其版本之类的信息。可以通过导航到“文件”→“测试设置”→“环境”选项卡来访问环境变量名称。

Built-in Environment Variables − provides a range of environment parameters that can provide information such as test name, action name, the test path, local host name, the operating system name, type and its version. The Environment Variable names can be accessed by navigating to "File" → "Test Settings" → "Environment" Tab.

qtp environment 1

User defined Internal − 在“环境”选项卡窗口中选择“用户定义”可以保存用户定义变量。单击“+”按钮可输入“Parameter Name”(参数名称)和“Value”(值),如下所示:

User defined Internal − User defined variables can be saved by selecting "User Defined" in the Environment Tab Window. The "+" button is clicked to enter Parameter Name and Value as shown below −

qtp environment 2

User Defined External − 用户定义变量可以作为一个 .xml 文件存储在外部文件中,并且可以加载到测试中,如下面的图片所示。在运行时,它也可以动态地加载,如在下面的示例之一中所解释的。

User Defined External − User Defined Variables can be stored in an external file as a .xml file and can be loaded into the test as shown in the figure given below. It can also be loaded dynamically during run-time as explained below in one of the examples.

qtp environment 3

Environment Variables – Supported Methods

1. ExternalFileName Property − 返回“测试设置”对话框“环境”选项卡中指定的已加载外部环境变量文件的名称。如果没有加载外部环境变量文件,此属性将返回一个空字符串。

1. ExternalFileName Property − Returns the name of the loaded external environment variable file specified in the Environment tab of the Test Settings dialog box. If no external environment variable file is loaded, this property returns an empty string.

x = Environment.ExternalFileName
print x
qtp environment 4

2. LoadFromFile Method − 在运行时动态加载指定的(.xml)环境变量文件。使用此方法时,无需手动将环境变量添加到“环境”选项卡中。

2. LoadFromFile Method − Loads the specified environment variable file (.xml) dynamically during run time. When using this method, the environment variables need not be added manually into the Environment Tab.

Environment.LoadFromFile "D:\config.xml"
b = Environment.Value("Browser")
print b
qtp environment 5

3. Value Property − 检索环境变量的值。我们还可以使用此属性设置用户定义内部环境变量的值。

3. Value Property − Retrieves the value of environment variables. We can also set the value of user-defined internal environment variables using this property.

' Get the Value of the InBuilt Environment Variables
a = Environment.Value("OS")
print a
b = Environment.Value("ActionName")
print b

'Loaded from External File
Environment.LoadFromFile "D:\config.xml"
c = Environment.Value("Browser")
print c
qtp environment 6

QTP - Library Files

为了将脚本模块化,已将库文件添加到 QTP 脚本中。它包括变量声明、函数、类等。它们实现了可重用,可在测试脚本之间共享。它们通过扩展名 .vbs 或 .qfl 保存。

In order to modularize the script, library files are added to the QTP Script. It contains variable declaration, Functions, Classes etc. They enable reusability that can be shared across test scripts. They are saved with an extenstion .vbs or .qfl

可以通过导航至“文件”>>“函数库”来创建一个新的库文件。

A new Library file can be created by navigating to "File" >> "Function Library".

Associating Function Libraries

@{}− 通过使用“文件”>“设置”>“资源”>“关联函数库”选项。单击“+”按钮以添加函数库文件并使用实际路径或相对路径添加它,如以下所示 −

Method 1 − By using "File" > "Settings" > Resources > Associate Function Library option. Click the "+" button to add Function Library file and add it using the actual path or relative path as shown below −

qtp library 1

@{}− 使用 ExecuteFile 方法。

Method 2 − Using ExecuteFile method.

'Syntax : ExecuteFile(Filepath)
ExecuteFile "C:\lib1.vbs"
ExecuteFile "C:\lib2.vbs"

@{}− 使用 LoadFunctionLibrary 方法。

Method 3 − Using LoadFunctionLibrary Method.

'Syntax : LoadFunctionLibrary(Filepath)
LoadFunctionLibrary "C:\lib1.vbs"
LoadFunctionLibrary "C:\lib2.vbs"

Method 4 − 自动化对象模型(AOM) - 这是一个用于控制 QTP 外部各种 QTP 操作的机制。通过 AOM,我们可以启动 QTP,打开测试,关联函数库等。应使用扩展名 .vbs 保存以下 VbScript,并在执行它时,QTP 将启动并开始执行测试。将在后一章节详细讨论 AOM。

Method 4 − Automation Object Model(AOM) - It is a mechanism, using which, we can control various QTP operations outside QTP. Using AOM, we can launch QTP, Open the Test, Associate Function Libraries etc. The following VbScript should be saved with Extension .vbs and upon executing the same, QTP will be launched and test would start executing. AOM will be discussed in detail in the later chapters.

'Launch QTP
Set objQTP = CreateObject("QuickTest.Application")
objQTP.Launch
objQTP.Visible = True

'Open the test
objQTP.Open "D:\GUITest2", False, False
Set objLib = objQTP.Test.Settings.Resources.Libraries

'Associate Function Library if NOT associated already.
If objLib.Find("C:\lib1.vbs") = -1 Then
  objLib.Add "C:\lib1.vbs", 1
End

QTP - Automated Testing Results

Test Results

测试结果窗口为我们提供了足够的信息来显示传递、失败等步骤。测试执行后,结果窗口会自动打开(根据默认设置)。显示以下信息:

The Test Results Window gives us sufficient information to show the steps passed, failed etc. Results window opens automatically after the execution of the test (as per default settings). The following information is displayed −

  1. Steps Passed

  2. Steps Failed

  3. Environment Parameters

  4. Graphical Statistics

qtp test results 1

Operations performed in Test Results

Converting Results to HTML

在结果查看器窗口中,导航到“文件”→“导出到文件”。导出运行结果对话框打开,如下所示:

In the Results Viewer window, navigate to "File" → "Export to File". Export Run Results dialog box opens as shown below −

qtp test results 2

我们可以选择要导出的报告类型。它可以是简要结果、详细结果,甚至可以选择节点。选择文件名并导出后,文件将保存为 .HTML 文件

We can choose what type of report is to be exported. It can be short results, detailed results or even, we can select nodes. After selecting the File Name and exporting it, the file is saved as .HTML File

Filtering the Results

可以根据状态、节点类型和迭代次数筛选结果。可以通过“测试结果窗口”中的“筛选器”按钮进行访问。

Results can be filtered based on Status, Node Type, and Iterations. It can be accessed by using the Filter button in the "Test Results Window".

qtp test results 3

Raising Defects

可以通过访问“工具”→“添加缺陷”直接从测试结果窗口窗格将缺陷记录到 QC,该窗格会打开与 ALM 的连接,如下所示:

Defects can be logged into QC directly from the Test Results Window pane by accessing "Tools" → "Add Defect" which open’s the connection to ALM as shown below −

qtp test results 4

Test Results

可以在“工具”→“选项”→“运行会话”选项卡下配置自动测试结果窗口。如果需要,我们可以将其关闭,还可以打开“会话结束时自动导出结果”。

The Automatic Test Results Window can be configured under "Tools" → "Options" → "Run Sessions" Tab. We can turn it OFF, if required, and also, we can switch ON "Automatically Export Results when session Ends".

qtp test results 5

可以根据设置录制屏幕截图或影片。可以在“工具”→“选项”→“屏幕捕获”选项卡下配置相同内容。我们可以根据以下三个条件保存屏幕截图或影片:

The screenshot or the movie can be recorded based on the settings. The same can be configured under "Tools" → "Options" → "Screen Capture" Tab. We can save the screenshot or movies based on the following three conditions −

  1. For Errors

  2. Always

  3. For Errors and Warnings

qtp test results 6

QTP - Working with GUI Objects

在脚本执行期间,QTP 将与多个 GUI 对象交互。因此,了解使用它能让我们有效地处理它的基本方法很重要。

There are various GUI objects, with which QTP interacts, during the script execution. Hence, it is important to know the basic methods for the key GUI objects using which we will be able to work on it effectively.

Working with Text Box

以下是我们在运行时访问文本框的方法 -

Following are the methods using which we access text box during Run Time −

  1. Set − Helps the tester to Set Values into the Text Box

  2. Click − Clicks on the Text Box

  3. SetSecure − Used to set the text in the password boxes securely

  4. WaitProperty − Waits Till the Property value becomes true

  5. Exist − Checks for the existence of the Text Box

  6. GetROProperty("text") − Gets the Value of the Text Box

  7. GetROProperty("Visible") − Returns a Boolean value if visible

Example

Browser("Math Calculator").Sync
Set Obj = Browser("Math Calculator").Page("SQR Calc").WebEdit("n")

'Clicks on the Text Box
Obj.Click

'Verify if the Object Exist - Returns Boolean value
a = obj.Exist
print a

'Set the value
obj.Set "10000" : wait(2)

'Get the Runtime Object Property - Value of the Text Box
val = obj.GetROProperty("value")
print val

'Get the Run Time Object Property - Visiblility - Returns Boolean Value
x = Obj.GetROProperty("visible")
print x

Working with Check Box

以下是可以用复选框工作的一些关键方法 -

Following are some of the key methods with which one can work with Check Box −

  1. Set − Helps the tester to Set the checkbox value "ON" or "OFF"

  2. Click − Clicks on the check Box. Even checks ON or OFF but user will not be sure about the status

  3. WaitProperty − Waits Till the Property value becomes true

  4. Exist − Checks for the existence of the Check Box

  5. GetROProperty("name") − Gets the Name of the check Box

  6. GetROProperty("Visible") − Returns a Boolean value if visible

Example

'To Check the Check Box
Set Obj = Browser("Calculator").Page("Gmail").WebCheckBox("PersistentCookie")
Obj.Set "ON"

'To UnCheck the Check Box
Obj.Set "OFF"

'Verifies the Existance of the Check box and returns Boolean Value
val = Obj.Exist
print val

'Fetches the Name of the CheckBox
a = Obj.GetROProperty("name")
print a

'Verifies the visible property and returns the boolean value.
x = Obj.GetROProperty("visible")
print x

Working with Radio Button

以下是一些关键方法,使用这些方法可以操作单选按钮——

Following are some of the key methods with which one can work with Radio Button −

  1. Select(RadioButtonName) − Helps the tester to Set the Radio Box "ON"

  2. Click − Clicks on the Radio Button. Even Radio Button ON or OFF but tester cannot get the status

  3. WaitProperty − Waits Till the Property value becomes true

  4. Exist − Checks for the existence of the Radio Button

  5. GetROProperty("name") − Gets the Name of the Radio Button

  6. GetROProperty("Visible") − Returns a Boolean value if visible

Example

'Select the Radio Button by name "YES"
Set Obj = Browser("Calculator").Page("Forms").WebRadioGroup("group1")
Obj.Select("Yes")

'Verifies the Existance of the Radio Button and returns Boolean Value
val = Obj.Exist
print val

'Returns the Outerhtml of the Radio Button
txt = Obj.GetROProperty("outerhtml")
print text

'Returns the boolean value if Radio button is Visible.
vis = Obj.GetROProperty("visible")
print vis

Working with Combo Box

以下是一些关键方法,使用这些方法可以操作组合框——

Following are some of the key methods with which one can work with Combo Box −

  1. Select(Value) − Helps the tester to Select the value from the ComboBox

  2. Click − Clicks on the object

  3. WaitProperty − Waits Till the Property value becomes true

  4. Exist − Checks for the existence of the Combo Box

  5. GetROProperty("Text") − Gets the Selected Value of the Combo Box

  6. GetROProperty("all items") − Returns all the items in the combo Box

  7. GetROProperty("items count") − Returns the number of items in the combo Box

Example

'Get the List of all the Items from the ComboBox
Set ObjList = Browser("Math Calculator").Page("Statistics").WebList("class")
x = ObjList.GetROProperty("all items")
print x

'Get the Number of Items from the Combo Box
y = ObjList.GetROProperty("items count")
print y

'Get the text value of the Selected Item
z = ObjList.GetROProperty("text")
print z

Working with Buttons

以下是一些关键方法,使用这些方法可以操作按钮——

Following are some of the key methods with which one can work with Buttons −

  1. Click − Clicks on the Button

  2. WaitProperty − Waits Till the Property value becomes true

  3. Exist − Checks for the existence of the Button

  4. GetROProperty("Name") − Gets the Name of the Button

  5. GetROProperty("Disabled") − Returns a Boolean value if enabled/disabled

Example

'To Perform a Click on the Button
Set obj_Button = Browser("Math Calculator").Page("SQR").WebButton("Calc")
obj_Button.Click

'To Perform a Middle Click on the Button
obj_Button.MiddleClick

'To check if the button is enabled or disabled.Returns Boolean Value
x = obj_Button.GetROProperty("disabled")
print x

'To fetch the Name of the Button
y = obj_Button.GetROProperty("name")
print y

Working with webTables

在当今基于 Web 的应用程序中,Web 表格已变得非常普遍,测试人员需要了解 Web 表格的工作原理以及如何对 Web 表格执行操作。本主题将帮助您高效地使用 Web 表格。

In Today’s web based application, webTables have become very common and testers need to understand how WebTables work and how to perform an action on webTables. This topic will help you to work with the webTables effectively.

Sr.No.

Statement & Description

1

if statement An if statement consists of a boolean expression followed by one or more statements.

2

if…​else statement An if else statement consists of a boolean expression followed by one or more statements. If the condition is True. The statements under if statements are execued. If the condition is false. Else part of the script is Executed

3

if..elseif…​else statement An if statement followed by one or more Elseif statements, that consists of boolean expressions and then followed by an optional else statement, which executes when all the condition becomes false.

4

nested if statements An if or elseif statement inside another if or elseif statement(s).

5

switch statement A switch statement allows a variable to be tested for equally aganist a list of values.

  1. html id − If the table has an id tag then it is best to make use of this property.

  2. innerText − Heading of the Table.

  3. sourceIndex − Fetches the Source Index of the Table

  4. ChildItemCount − Gets the number of ChildItems present in specified Row

  5. RowCount − Gets the number of Rows in the Table

  6. ColumnCount − Gets the number of Columns in the Table

  7. GetcellData − Gets the Value of the Cell based on the column and Row Index

Example

Browser("Tutorials Point").Sync
' WebTable
Obj = Browser("Tutorials Point").Page("VBScript Decisions").WebTable("Statement")
' Fetch RowCount
x = Obj.RowCount
print x

' Fetch ColumnCount
y = Obj.ColumnCount(1)
print y

' Print the Cell Data of the Table
For i = 1 To x Step 1

   For j = 1 To y Step 1
      z = Obj.GetCellData(i,j)
      print "Row ID : " & i & " Column ID : " & j & " Value : " & z
   Next
Next

'Fetch the Child Item count of Type Link in a particular Cell
z = Obj.ChildItemCount(2,1,"Link")
print z

QTP - Virtual Objects

What are Virtual Objects?

有时,被测应用程序可能包含标准窗口对象,但未被 QTP 识别。在这种情况下,对象可以定义为按钮、链接等类型的虚拟对象 (VO),以便在执行期间可以在虚拟对象上模拟用户操作。

Sometimes, an application under test may contain standard window object but are not recognized by QTP. Under these circumstances, objects can be defined as virtual object(VO) of type button, link etc. so that user actions can be simulated on the virtual objects during execution.

Example

假设我们在 Microsoft Word 中自动化场景。我激活了 MS Word 应用程序,并单击功能区中的任何图标。例如,在功能区中单击“插入”选项卡,然后单击“图片”按钮。按钮被识别为 WinObject;因此,虚拟对象的重要性变得明显。

Let us say we are automating a scenario in Microsoft Word. I activated MS word application and I click on any icon in the ribbon. For example, on the Ribbon, Insert tab is clicked and then the user clicks the "Picture" button. A button is recognized as WinObject; hence, importance of virtual objects is pronounced.

Window("Microsoft Word").WinObject("Ribbon").Click 145,45
Window("Microsoft Word").WinObject("Ribbon").WinObject("Picture...").Click
170,104

Creating a Virtual Object

Step 1 − 在这种情况下,使用虚拟对象管理器或“工具”>>“虚拟对象”>>“新建虚拟对象”中的新建虚拟对象创建虚拟对象,然后单击“下一步”按钮。

Step 1 − In such scenarios, virtual Objects are created using Virtual Object Manager or New Virtual Object from "Tools" >> "Virtual Object" >> "New Virtual Object" and click the "Next" button.

qtp virtual objects 1

Step 2 − 将对象与类类型映射,然后单击“下一步”。

Step 2 − Map the Object against the Class Type and click "Next".

qtp virtual objects 2

Step 3 − 单击“标记对象”按钮。将出现十字光标,标记您要映射的对象,然后单击“下一步”。

Step 3 − Click "Mark Object" Button. A cross hair cursor would appear and mark the object that you would like to map and click "Next".

qtp virtual objects 3

Step 4 − 选择虚拟对象的父级,然后单击“下一步”。

Step 4 − Select the parent of the Virtual object and click "Next".

qtp virtual objects 4

Step 5 − 命名要存储虚拟对象的集合,然后单击“完成”。

Step 5 − Name the collection in which you would like to store the virtual object and click "Finish".

qtp virtual objects 5

Virtual Object Manager

虚拟对象管理器管理虚拟对象的集合。测试人员可以从虚拟对象管理器中添加或删除虚拟对象。

Virtual object Manager manages the collections of Virtual objects. Testers can add or Delete the Virtual Objects from the Virtual Object manager.

导航到虚拟对象管理器:“工具”>>“虚拟对象管理器”,如下所示 −

Navigation to Virtual object Manager : "Tools" >> "Virtual Object Manager" as shown below −

qtp virtual objects 6

Using Virtual Objects

创建虚拟对象后,可以使用创建的对象,如下所示 −

After creating the Virtual Objects, the created object can be used as shown below −

Window("Microsoft Word").WinObject("Ribbon").VirtualButton("button").Click

Virtual Object Limitations

  1. QTP does not support virtual objects for analog or low-level recording.

  2. Checkpoints cannot be added on Virtual Objects.

  3. Virtual Objects are not controlled by Object Repository.

  4. Though we map an object to a particular class (button or List), all the methods of the native objects are not supported by Virtual objects.

  5. Object Spy cannot be used on Virtual Object.

  6. The test execution will fail if the screen resolution changes as the co-ordinates change.

  7. Application Window should be of same screen size so that Virtual objects are captured correctly.

QTP - Accessing Databases

QTP 本身不提供连接到数据库的任何内置支持,但使用 VBScript 测试人员将能够使用 ADODB 对象连接到数据库并与之交互。

As such, QTP does not provide any built-in support to connect to database, however using VBScript testers will be able to connect and interact with databases using ADODB objects.

ADODB 有 4 个属性或方法,我们可以用它们来处理数据库。它们是:

ADODB has 4 properties or methods with which we will be able to work with the databases. They are −

  1. ADODB.Connection − Used to establish a connection to the Database

  2. ADODB.Command − Used to execute a SQL command(Queries or Stored Procedures)

  3. ADODB.Fields − Used to fetch a particular column from a record set after executing a query/stored proc

  4. ADODB.Recordset − Used to fetch data from a database

How to connect to Database?

数据库可以使用连接字符串进行连接。连接到各个数据库的方式有所不同。但是,可以在 www.connectionstrings.com 的帮助下构建连接字符串

Databases can be connected using Connection strings. Each database differs in the way we connect to them. However, the connection strings can be built with the help of www.connectionstrings.com

让我们看看如何使用以下参数连接到数据库−

Let us see how to connect to the database with the following parameters −

  1. Database Type − MSSQL SERVER

  2. Server Name − SQLEXPRESS

  3. Database Name − Trial

  4. User Id − sa

  5. password − Password123

查询的输出显示在 SQL Server Management Studio 中,如下所示:

The output of the Query is shown in the SQL Server Management Studio as follows −

qtp accessing db1
Dim objConnection
'Set Adodb Connection Object
Set objConnection = CreateObject("ADODB.Connection")
Dim objRecordSet

'Create RecordSet Object
Set objRecordSet = CreateObject("ADODB.Recordset")

Dim DBQuery 'Query to be Executed
DBQuery = "Select NAME from dbo.EMPLOYEE where AGE = 29"

'Connecting using SQL OLEDB Driver
objConnection.Open "Provider = sqloledb.1;Server =.\SQLEXPRESS;
User Id = sa;Password=Password123;Database = Trial"

'Execute the Query
objRecordSet.Open DBQuery,objConnection

'Return the Result Set
Value = objRecordSet.fields.item(0)
msgbox Value

' Release the Resources
objRecordSet.Close
objConnection.Close

Set objConnection = Nothing
Set objRecordSet = Nothing

Result

执行上述脚本后,输出显示在消息框中,如下所示:

On executing the above script, the output is shown in the message box as shown below −

qtp accessing db2

QTP Working with XML

XML 是一种标记语言,设计用于将数据存储为人类和机器都可以读取的格式。使用 XML 还可以轻松地在计算机和数据库系统之间交换数据。

XML is a markup language designed to store data in a format that can be both readable by human and machine. Using XML, data can also be easily exchanged between computer and database systems.

示例 XML 及其关键元素如下所示 −

Sample XML and their key elements are represented below −

qtp xml 1

Accessing XML

Const XMLDataFile = "C:\TestData.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load(XMLDataFile)

' Getting the number of Nodes (books)
Set nodes = xmlDoc.SelectNodes("/bookstore/book")
Print "Total books: " & nodes.Length    ' Displays 2

' get all titles
Set nodes = xmlDoc.SelectNodes("/Booklib/book/value/text()")

' get their values
For i = 0 To (nodes.Length - 1)
   Title = nodes(i).NodeValue
   Print "Title is" & (i + 1) & ": " & Title
Next

Comparing XML

我们可以比较给定的两个 XML −

We can compare two given XMLs −

Dim xmlDoc1
Dim xmlDoc2

' Load the XML Files
Set xmlDoc1 = XMLUtil.CreateXMLFromFile ("C:\File1.xml")
Set xmlDoc2 = XMLUtil.CreateXMLFromFile ("C:\File2.xml")

'Use the compare method of the XML to check if they are equivalent
Comp = xmlDoc1.Compare (xmlDoc1, xmlDoc2)

'Returns 1 if the two files are the same
If Comp = 1 Then
   Msgbox "XML Files are the Same"
Else
   Msgbox "XML Files are Different"
End if

QTP - Descriptive Programming

当对象存在于对象存储库中时,QTP 脚本才能执行。对象描述使用说明性编程创建:

QTP scripts can execute only if the objects are present in the Object Repository. The descriptions of the Objects are created using Descriptive programming −

  1. When the testers want to perform an operation on an object that is not present in the object repository

  2. When objects in the application are very dynamic in nature.

  3. When the Object Repository grows big, it results in poor Performance as the size of the Object Repository increases.

  4. When the framework is built, such that it has been decided not to use Object Repository at all.

  5. When testers want to perform an action on the application at run-time without having the knowledge of object’s unique properties.

Syntax

使用描述性编程技术编写脚本有两种方法。它们是 -

There are two ways to scripting using Descriptive Programming technique. They are −

  1. Description Objects

  2. Description Strings

Description Objects

脚本使用依赖于所用属性及其相应值的对象描述来开发。然后,这些描述用于构建脚本。

Script is developed using Description Objects that depend upon the properties used and their corresponding values. Then, these descriptions are used to build the script.

'Creating a description object
Set btncalc = Description.Create()

'Add descriptions and properties
btncalc("type").value = "Button"
btncalc("name").value = "calculate"
btncalc("html tag").value = "INPUT"

' Use the same to script it
Browser("Math Calc").Page("Num Calculator").WebButton(btncalc).Click

Description Strings

对象的描述使用属性和值(如字符串)来开发,如下所示。

The description of the objects is developed using the properties and values as strings as shown below.

Browser("Math Calc").Page("Num Calculator").WebButton("html
tag:=INPUT","type:=Button","name:=calculate").Click

Child Objects

QTP 提供 ChildObjects 方法,它使我们能够创建对象集合。父对象位于 ChildObjects 之前。

QTP provides the ChildObjects method, which enables us to create a collection of objects. The parent objects precedes ChildObjects.

Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "Link"

'Find all the Links
Set obj = Browser("Math Calc").Page("Math Calc").ChildObjects(oDesc)

Dim i
'obj.Count value has the number of links in the page

For i = 0 to obj.Count - 1
   'get the name of all the links in the page
   x = obj(i).GetROProperty("innerhtml")
   print x
Next

Ordinal Identifiers

描述性编程用于基于序数标识符编写脚本,当两个或多个对象具有相同属性时,这将使 QTP 对这些对象采取行动。

Descriptive programming is used to write the script based on ordinal identifiers, which will enable QTP to act on those objects when two or more objects have the same properties.

' Using Location
Dim Obj
Set Obj = Browser("title:=.*google.*").Page("micclass:=Page")
Obj.WebEdit("name:=Test","location:=0").Set "ABC"
Obj.WebEdit("name:=Test","location:=1").Set "123"

' Index
Obj.WebEdit("name:=Test","index:=0").Set "1123"
Obj.WebEdit("name:=Test","index:=1").Set "2222"

' Creation Time
Browser("creationtime:=0").Sync
Browser("creationtime:=1").Sync
Browser("creationtime:=2").Sync

QTP - Automation Object Model

QTP 本身可以使用由惠普 QTP 提供的 COM 接口进行自动化。自动化对象模型是一组对象、方法和属性,可帮助测试人员控制配置设置并使用 QTP 界面执行脚本。列出可以控制的关键配置/操作(但不限于):

QTP itself can be automated using the COM interface that is provided by HP-QTP. Automation object model is a set of objects, methods, and properties that helps the testers to control the configuration settings and execute the scripts using the QTP interface. The Key Configurations/actions that can be controlled (but not limited to) are listed below −

  1. Loads all the required add-ins for a test

  2. Makes QTP visible while execution

  3. Opens the Test using the specified location

  4. Associates Function Libraries

  5. Specifies the Common Object Sync Time out

  6. Start and End Iteration

  7. Enable/Disable Smart Identification

  8. On Error Settings

  9. Data Table Path

  10. Recovery Scenario Settings

  11. Log Tracking Settings

QTP 11.5x 提供了自动化对象模型的独家文档,可通过导航到“开始”>>“所有程序”>>“惠普软件”>>“惠普统一功能测试”>>“文档”>>“统一功能测试自动化参考”来引用。

QTP 11.5x provides an exclusive documentation on Automation Object model that can be referred by navigating to "Start" >> "All Programs" >> "HP Software" >> "HP Unified Functional Testing" >> "Documentation" >> "Unified Functional Testing Automation Reference".

Generate AOM Script

测试人员可以使用“生成脚本”选项从 QTP 本身生成 AOM 脚本。导航到“运行”>>“设置”>>“属性”选项卡 >>“生成脚本”,如下所示:

A tester can generate AOM script from QTP itself, using the "Generate Script" option. Navigate to "Run" >> "Settings" >> "Properties" Tab >> "Generate Script" as shown below −

qtp aom 1

Example

' A Sample Script to Demostrate AOM
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True

App.Test.Settings.Launchers("Web").Active = False
App.Test.Settings.Launchers("Web").Browser = "IE"
App.Test.Settings.Launchers("Web").Address = "http://easycalculation.com/"
App.Test.Settings.Launchers("Web").CloseOnExit = True

App.Test.Settings.Launchers("Windows Applications").Active = False
App.Test.Settings.Launchers("Windows Applications").Applications.RemoveAll
App.Test.Settings.Launchers("Windows Applications").RecordOnQTDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnExplorerDescendants = False
App.Test.Settings.Launchers("Windows Applications").RecordOnSpecifiedApplications = True

App.Test.Settings.Run.IterationMode = "rngAll"
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Run.ObjectSyncTimeOut = 20000
App.Test.Settings.Run.DisableSmartIdentification = False
App.Test.Settings.Run.OnError = "Dialog"

App.Test.Settings.Resources.DataTablePath = "<Default>"
App.Test.Settings.Resources.Libraries.RemoveAll

App.Test.Settings.Web.BrowserNavigationTimeout = 60000
App.Test.Settings.Web.ActiveScreenAccess.UserName = ""
App.Test.Settings.Web.ActiveScreenAccess.Password = ""

App.Test.Settings.Recovery.Enabled = True
App.Test.Settings.Recovery.SetActivationMode "OnError"
App.Test.Settings.Recovery.Add "D:\GUITest2\recover_app_crash.qrs",
   "Recover_Application_Crash", 1
App.Test.Settings.Recovery.Item(1).Enabled = True

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' System Local Monitoring settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
App.Test.Settings.LocalSystemMonitor.Enable = false
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Log Tracking settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With App.Test.Settings.LogTracking
   .IncludeInResults = False
   .Port = 18081
   .IP = "127.0.0.1"
   .MinTriggerLevel = "ERROR"
   .EnableAutoConfig = False
   .RecoverConfigAfterRun = False
   .ConfigFile = ""
   .MinConfigLevel = "WARN"
End With

QTP - Frameworks

框架定义了一套准则/最佳实践来执行一组标准,这让最终用户易于使用。有不同类型的自动化框架,最常见的类型如下:

A Framework defines a set of guidelines/best practices that enforces a set of standards, which makes it easy to use for the end users to work with. There are different types of automation frameworks and the most common ones are listed below −

  1. Keyword-Driven Framework

  2. Data-Driven Framework

  3. Hybrid Framework

Keyword-Driven Framework

关键字驱动测试是一种类型的功能自动测试框架,也称为表格驱动测试或动作词驱动测试。

Keyword driven testing is a type of functional automation testing framework which is also known as table-driven testing or action word based testing.

在关键字驱动测试中,我们使用表格格式(通常是电子表格)来针对我们要执行的每个功能定义关键词或动作词。

In Keyword-driven testing, we use a table format, usually a spreadsheet, to define keywords or action words for each function that we would like to execute.

qtp keyword driven testing

Advantages

  1. It is best suited for novice or a non-technical tester.

  2. Enables writing tests in a more abstract manner using this approach.

  3. Keyword driven testing allows automation to be started earlier in the SDLC even before a stable build is delivered for testing.

  4. There is a high degree of reusability.

Disadvantages

  1. Initial investment in developing the keywords and its related functionalities might take longer.

  2. It might act as a restriction to the technically abled testers.

Data Driven Framework

数据驱动测试是创建测试脚本的地方,其中每次运行测试时,测试数据和/或输出值从数据文件读取,而不是使用相同的硬编码值。通过这种方式,测试人员可以有效地测试应用程序如何处理各种输入。它可以是以下任何数据文件:

Data-driven testing is creation of test scripts where test data and/or output values are read from data files instead of using the same hard-coded values each time the test runs. This way, the testers can test how the application handles various inputs effectively. It can be any of the following data files −

  1. datapools

  2. Excel files

  3. ADO objects

  4. CSV files

  5. ODBC sources

Flow Diagram

数据驱动测试可以通过以下图表得到最好的理解:

Data Driven Testing can be best understood by the following diagram −

qtp data driven testing

Advantages

  1. Data driven framework results in less amount of code

  2. Offers greater flexibility for maintaining and fixing the scripting issues

  3. Test Data can be developed

Disadvantages

  1. Each script needs to be different to understand different sets of data.

Hybrid Framework

混合框架是关键字驱动和数据驱动框架的结合,下图是对它的最佳描述。

Hybrid Framework is a combination of Keyword driven and data Driven framework that can be best described using the following flow diagram.

qtp hybrid framework

Affecting Factors

以下是开发框架时应该考虑的参数。影响因素如下所示 -

Following are the parameters one should take into account while developing the framework. The affects factors are listed below −

  1. Framework files should support versioning controlling software such as SVN, CVS, MS Source Control

  2. Framework should support executing the scripts in different environments viz- QA, SAT, DEV

  3. Upon Object changes, scripts should execute with minimal changes.

  4. Framework should configure itself and take care of prerequisite such as creating folders/databases.

  5. Framework should have robust reporting structure so that issues in the script/application can be easily spotted

  6. Framework should have greater flexibility so that it should be easy to use

  7. Framework should follow coding standards so that files, functions, and history of changes are maintained correctly.

在下一章,我们将学习如何设计一个简单的框架。

In the next chapter, we will learn how to design a simple framework.

QTP - Designing Framework

让我们通过一个示例应用程序来设计一个简单的框架。我们将在受测应用程序中自动执行几个场景并编写可重用函数。

Let us design a simple framework by taking a sample application. We will automate a few scenarios of the application under test and write reusable functions.

受测示例应用程序为 "Calculator" ,它是作为 Windows 一部分可用的一款默认应用程序。现在让我们创建框架的不同组件。在这里,我们将开发一个混合框架,并使用对象存储库,因为它是一个相当简单的应用程序。但是,该框架也可以扩展以支持复杂应用程序。

The sample application under test is "Calculator", a default application that is available as a part of Windows. Let us now create different components of a framework. Here, we will develop a hybrid framework and use Object Repository as it is fairly a simple application. However, this framework can be scaled to support a complex application as well.

框架的文件夹结构如下所示:

The folder structure of the Framework is as shown below −

qtp framework folder structure

文件夹结构的说明 −

Explanation of the folder structure −

  1. Master Driver Script − The Script that drives the entire execution. It performs prerequisite and initial settings that are required for the execution.

  2. Library Files − The Associated Functions that forms the Function Library.

  3. Data Table − The Test Data that is required for the Execution.

  4. Object Repository − The Objects and its properties that enable QTP to recognize the objects seamlessly.

  5. Execution Logs − The Folder contains the execution log file with user functions and function execution history.

Master Driver Script

'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
' MASTER DRIVER SCRIPT NAME    : Calculator
' DESCRIPTION                  : Drivers Script to Execute Automated Test for
   the Calculator
' AUTHOR                       : Tutorials Point
' DATE CREATED                 : 30-Dec-2013
' OBJECT REPOSITORY ASSOCIATED : Calc.tsr
' LIBRARY FILES ASSOCIATED     : calculator.qfl, Common.qfl
' MODIFICATION LOG

' ----------------------------------------------------
' First Version       Tutorials point
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Option Explicit

Public ExecDrive

' Get the Root folder of the Test  so that we can make use of relative paths.
Dim x : x = Instr(Environment.Value("TestDir"),"Driver")-2
ExecDrive = mid(Environment.Value("TestDir"),1,x)

' Get the path of Libraries using relative to the current Drive
Dim LibPath : LibPath = ExecDrive+"\Libraries\"

' Dynamically Load the Function Libraries
LoadFunctionLibrary LibPath + "Calculator.qfl", LibPath + "common_utils.qfl"

' Capturing the Start Time
' clscommon is the class object created in common.qfl library file
clscommon.StartTime = Time()

' Launching the Application
SystemUtil.Run "C:\Windows\System32\Calc.exe" : wait (2)

' Initialize the Data Table Path
Dim FileName : FileName  = ExecDrive+"\TestData\Calculator.xls"
Dim SheetSource : SheetSource  = "Calc_test"
Dim SheetDest : SheetDest = "Global"

' Import the DataTable into the QTP Script
DataTable.ImportSheet  FileName , SheetSource , SheetDest

' Object Repository Path
Dim RepPath : RepPath = ExecDrive+"\Object_Repository\Calc.tsr"
RepositoriesCollection.RemoveAll()
RepositoriesCollection.Add(RepPath)

' To Keep a Count on iteration
Dim InttestIteration
Dim InttestRows : InttestRows = datatable.GetRowCount

'  Fetching Date-TimeStamp which will be unique for Naming the Execution Log File
clscommon.StrDateFormatted = day(date()) & "_" &  MonthName(Month(date()),true) &
 "_" & YEAR(date())& "_"&hour(now)&"_"&minute(now)

 ' Name the LogFile
clscommon.StrLogFile = ExecDrive & "\Execution Logs\" &
clscommon.StrDateFormatted & ".txt"

' Create the Execution LogFile which captures the result
clscommon.Fn_FileCreate(clscommon.StrLogFile)

' Iniitialize the Parameters and all the relevant Test Details
Call Fn_InitializeLogFile()

' Kill all the previous calculator process
Call fn_Kill_Process("calc.exe")

For InttestIteration = 1 to InttestRows
   datatable.SetCurrentRow InttestIteration
   Dim StrExecute : StrExecute = Ucase(Trim(datatable.Value("Run","Global")))
   If StrExecute = "Y" Then
      clscommon.Number1 = Trim(datatable.Value("Number_1","Global"))
      clscommon.Number2 = Trim(datatable.Value("Number_2","Global"))
      clscommon.Number3 = Trim(datatable.Value("Number_3","Global"))

      clscommon.Number4 = Trim(datatable.Value("Number_4","Global"))
      clscommon.Number5 = Trim(datatable.Value("Number_5","Global"))
      clscommon.Number6 = Trim(datatable.Value("Number_6","Global"))

      clscommon.Test_Case_ID  =
         Trim(datatable.Value("Test_Case_ID","Global"))'
            : clscommon.LogWrite "The Test Case Data is Located at :: " & tcDataPath
      clscommon.tcScenario =
         Trim(datatable.Value("Scenario","Global"))'
            : clscommon.LogWrite "The Test Case Data is Located at :: " & tcDataPath
      Dim  Expected_Val :  Expected_Val =
         Trim(datatable.Value("Expected_Val","Global"))'
            :  clscommon.LogWrite "The Test Case Data is Located at :: " & tcDataPath

      Select case clscommon.tcScenario
         Case "Add"
            clscommon.LogWrite "=== Inside the Test Set :: " &
               clscommon.tcScenario & " ==="
                  Call fnCalculate("+",Expected_Val)

         Case "Subtract"
            clscommon.LogWrite "=== Inside the Test Set :: " &
               clscommon.tcScenario & " ==="
                  Call fnCalculate("-",Expected_Val)

         Case "Multiply"
            clscommon.LogWrite "=== Inside the Test Set :: " &
               clscommon.tcScenario & " ==="
                  Call fnCalculate("*",Expected_Val)

         Case "Divide"
            clscommon.LogWrite "=== Inside the Test Set :: " &
               clscommon.tcScenario & " ==="
                  Call fnCalculate("/",Expected_Val)

         Case "Sqrt"
            clscommon.LogWrite "=== Inside the Test Set :: " &
               clscommon.tcScenario & " ==="
                  Call fnCalculate("sqt",Expected_Val)
      End Select
   End If
Next

' Calling the End Test to Add the result Footer in exec log file.
Call fn_End_test()

'  =====================  End of Master Driver Script =====================

Library Files

计算器函数是用单独的函数文件编写的,该文件使用扩展名 .qfl 或 .vbs 保存。这些函数在所有操作中均可重用。

The Calculator Functions are written in a separate function file saved with the extension .qfl or .vbs. These functions are reusable across actions.

'  Calculator. Qfl File :: Associated Function Library for Calculator Master Driver

'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
' FUNCTION NAME     : Fn_InitializeLogFile
' DESCRIPTION       : Function to Write the Initial Values in the Log File
' INPUT PARAMETERS  : varExecDrive,StrDB,StrUId,Strpwd,StrNewDB
' OUTPUT PARAMETERS : NIL
' RETURN VALUE      : Pass or Fail message
' DATE CREATED      : 30-Dec-2013
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Public Function Fn_InitializeLogFile()
   clscommon.LogWrite "********************************************"
   clscommon.LogWrite "Calc Automation Started"
End Function
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
' FUNCTION NAME     : fnCalculate
' DESCRIPTION       : Function to perform Arithmetic Calculations
' INPUT PARAMETERS  : operator,Expected_Val
' OUTPUT PARAMETERS : NIL
' RETURN VALUE      : Pass or Fail message
' DATE CREATED      : 30-Dec-2013
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Function fnCalculate(operator,Expected_Val)
   clscommon.LogWrite "Executing the Function 'fnCalculate' "

   Window("Calculator").Activate

   If Trim(clscommon.Number1) <> ""  Then
      Window("Calculator").WinButton(clscommon.Number1).Click
   If Trim(clscommon.Number2) <> ""  Then
      Window("Calculator").WinButton(clscommon.Number2).Click
   If Trim(clscommon.Number3) <> ""  Then
      Window("Calculator").WinButton(clscommon.Number3).Click

   Window("Calculator").WinButton(operator).Click
   If Trim(clscommon.Number4) <> ""  Then
      Window("Calculator").WinButton(clscommon.Number4).Click
   If Trim(clscommon.Number5) <> ""  Then
      Window("Calculator").WinButton(clscommon.Number5).Click
   If Trim(clscommon.Number6) <> ""  Then
      Window("Calculator").WinButton(clscommon.Number6).Click

   Window("Calculator").WinButton("=").Click
   Dim ActualVal : ActualVal  =
      Window("Calculator").WinEdit("Edit").GetROProperty("text")
   clscommon.LogWrite "The Actual Value after the Math Operation is "& ActualVal

   If Trim(ActualVal) = Trim(Expected_Val) Then
      clscommon.WriteResult "Pass",  clscommon.Test_Case_ID ,
         clscommon.tcScenario , " Expected Value matches with Actual Value :: "
            & ActualVal

   Else
      clscommon.WriteResult "Fail",  clscommon.Test_Case_ID ,
         clscommon.tcScenario , " Expected Value - " & Expected_Val & " Does NOT matches
            with Actual Value :: " & ActualVal
   End If

   Window("Calculator").WinButton("C").Click

   If Err.Number <> 0  Then
      clscommon.LogWrite  "Execution Error : The Error Number is ::  " &
         Err.Number & " The Error Description is " & Err.Description
      Err.Clear
   End If

   clscommon.LogWrite "Exiting the Function 'fnCalculate' "
End Function

'= = = = = = = = = = = = = = = = = = = = = = = = = = =
' FUNCTION NAME     : fn_Kill_Process
' DESCRIPTION       : Function to Kill the process by name
' INPUT PARAMETERS  : Application name to be killed
' OUTPUT PARAMETERS : NIL
' RETURN VALUE      : NIL
' DATE CREATED      : 30-Dec-2013
'= = = = = = = = = = = = = = = = = = = = = = = = = = =
Function fn_Kill_Process(process)
   Dim strComputer ,  strProcessToKill , objWMIService , colProcessstrComputer = "."
   strProcessToKill = process

   Set objWMIService = GetObject("winmgmts:" _&
      "{impersonationLevel=impersonate}!\\" _& strComputer & "\root\cimv2")

   Set colProcess = objWMIService.ExecQuery _("Select * from Win32_Process
      Where Name = '" & strProcessToKill & "'")

   count = 0
   For Each objProcess in colProcess
      objProcess.Terminate()
      count = count + 1
   Next
End Function

'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
' FUNCTION NAME     : fn_End_test
' DESCRIPTION       : Function to finish the test Execution process
' INPUT PARAMETERS  : Application name to be killed
' OUTPUT PARAMETERS : NIL
' RETURN VALUE      : NIL
' DATE CREATED      : 20/Dec/2013
'= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Function fn_End_test()
   clscommon.LogWrite "Status Message - Executing the Function 'fn_End_test' "

   Window("Calculator").Close
   On Error Resume Next

   clscommon.StopTime = Time()
   clscommon.ElapsedTime = DateDiff("n",clscommon.StartTime,clscommon.StopTime)
   Dim Totaltests
   Totaltests = clscommon.gintPassCount+ clscommon.gintFailCount
   clscommon.LogWrite "## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
   clscommon.LogWrite "##  The Execution Start Time  ::  " & clscommon.StartTime
   clscommon.LogWrite "##  The Execution End Time   ::  " & clscommon.StopTime
   clscommon.LogWrite "##  The Time Elapsed ::   " & clscommon.ElapsedTime & " Minutes "
   clscommon.LogWrite "##  The OS ::  " & Environment.Value("OS")
   clscommon.LogWrite "##  The Total No of Test Cases Executed  ::  " & Totaltests
   clscommon.LogWrite "##  The No. of Test Case Passed ::  " & clscommon.gintPassCount
   clscommon.LogWrite "##  The No. of Test Case Failed ::  " & clscommon.gintFailCount
   clscommon.LogWrite "## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
   SystemUtil.CloseDescendentProcesses
End Function
'  ===============   End of Calculator. Qfl   ============================= '

另一个库文件’common_utils.qfl’包含这些函数使我们能够将输出写入到文本文件。

The other library file, which is 'common_utils.qfl' that contains the functions, which enables us to write the output to a text file.

Set clscommon = New OS_clsUtils

'Creating a class file to handle global variables.
Class OS_clsUtils
   Dim StrLogFile
   Dim StrDateFormatted
   Dim Result

   Dim  Number1, Number2 , Number3
   Dim  Number4, Number5 , Number6
   Dim Test_Case_ID , tcScenario
   Dim StartTime, StopTime, ElapsedTime

   Dim gintPassCount , gintFailCount , gintWarningCount ,  gintdoneCount,
      gintinfoCount

   Function Fn_FileCreate(strFileName)
      Dim objFSO:  Set objFSO = CreateObject("Scripting.FileSystemObject")
      On Error Resume Next

      Dim objTextFile : Set objTextFile = objFSO.CreateTextFile(strFileName)
      objTextFile.Close

      Set objTextFile = Nothing
      Set objFSO = Nothing
   End Function

   Function LogWrite(sMsg)
      Const ForAppending = 8

      Dim objFSO : Set objFSO = CreateObject("scripting.FileSystemObject")

      Dim objTextFile : Set objTextFile = objFSO.OpenTextFile
         (clscommon.StrLogFile, ForAppending, True)

      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & sMsg
      objTextFile.Close

      Set objTextFile = Nothing
      Set objFSO = Nothing
   End Function

   Function WriteResult(strStatus,functionName,functionDescription,Result)
      Const ForAppending = 8
      Dim objFSO : Set objFSO = CreateObject("scripting.FileSystemObject")
      Dim objTextFile : Set objTextFile = objFSO.OpenTextFile
         (clscommon.StrLogFile, ForAppending, True)

      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & "
            * * * * * * Test Case Exec Details  * * * * * "

      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & " Test staus :: " & strStatus
      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & " Tese ID ::  " & functionName
      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & " Test Description :: "
            & functionDescription
      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & " Test Result Details :: " & Result
      objTextFile.WriteLine day(date()) & "/" &  MonthName(Month(date()),true)
         &  "/" & YEAR(date()) & " " & time & ": " & "
            * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * * * "
      objTextFile.Close

      Set objTextFile = Nothing
      Set objFSO = Nothing

      Select Case Lcase(strStatus)
         Case "pass"
            gintPassCount = gintPassCount + 1

         Case "fail"
            gintFailCount = gintFailCount+1
      End Select
   End Function
End Class
'   =====================   End of common_Utils.qfl =====================

Object Repository

对象存储库具有用户将作用于其的所有对象。以下图像显示以名称 calc.tsr 添加到存储库的所有对象的列表。

Object Repository has got all the objects that the user would be acting upon. The image given below shows the list of all objects added into the repository with the name calc.tsr

qtp object repository calc

Data Table

数据表包含关键词,它驱动测试,并测试数据,QTP 将使用这些数据对对象进行操作。

DataTable contains the keywords, which drive the tests and also Test the data with which QTP will act on the objects.

qtp designing framework datatable

The Execution Log

执行日志文件或输出文件包含用户操作和函数日志,将使测试员能够在脚本故障时进行调试。

The Execution log file or output file contains user actions and function log, which will enable the testers to debug upon script failures.

qtp designing framework execution log
8/Jan/2014 5:09:16 PM: *************************************************
8/Jan/2014 5:09:16 PM: Calc Automation Started
8/Jan/2014 5:09:16 PM: === Inside the Test Set  ::   Add  ===
8/Jan/2014 5:09:16 PM: Executing the Function 'fnCalculate'
8/Jan/2014 5:09:17 PM: The Actual Value after the Math Operation is 949.
8/Jan/2014 5:09:17 PM:  * * * * * * Test Case Exec Details  * * * * *
8/Jan/2014 5:09:17 PM: Test staus :: Pass
8/Jan/2014 5:09:17 PM: Tese ID ::  TC_001
8/Jan/2014 5:09:17 PM: Test Description :: Add
8/Jan/2014 5:09:17 PM: Test Result Details ::  Expected Value matches with Actual
   Value :: 949.
8/Jan/2014 5:09:17 PM: * * * * * * * * * * * * * * * * * * * * * * * *  * *
* * * * * * * * *

8/Jan/2014 5:09:17 PM: Exiting the Function 'fnCalculate'
8/Jan/2014 5:09:17 PM: === Inside the Test Set  ::   Subtract  ===
8/Jan/2014 5:09:17 PM: Executing the Function 'fnCalculate'
8/Jan/2014 5:09:17 PM: The Actual Value after the Math Operation is 415.
8/Jan/2014 5:09:17 PM: * * * * * * Test Case Exec Details  * * * * *
8/Jan/2014 5:09:17 PM: Test staus :: Pass
8/Jan/2014 5:09:17 PM: Tese ID ::  TC_002
8/Jan/2014 5:09:17 PM: Test Description :: Subtract
8/Jan/2014 5:09:17 PM: Test Result Details ::  Expected Value matches with Actual
   Value :: 415.
8/Jan/2014 5:09:17 PM: * * * * * * * * * * * * * * * * * * * * * * * *  * * *
* * * * * * * *

8/Jan/2014 5:09:17 PM: Exiting the Function 'fnCalculate'
8/Jan/2014 5:09:17 PM: === Inside the Test Set  ::   Multiply  ===
8/Jan/2014 5:09:17 PM: Executing the Function 'fnCalculate'
8/Jan/2014 5:09:18 PM: The Actual Value after the Math Operation is 278883.
8/Jan/2014 5:09:18 PM: * * * * * * Test Case Exec Details  * * * * *
8/Jan/2014 5:09:18 PM: Test staus :: Pass
8/Jan/2014 5:09:18 PM: Tese ID ::  TC_003
8/Jan/2014 5:09:18 PM: Test Description :: Multiply
8/Jan/2014 5:09:18 PM:  Test Result Details ::  Expected Value matches with
   Actual Value :: 278883.
8/Jan/2014 5:09:18 PM: * * * * * * * * * * * * * * * * * * * * * * * *  * * *
* * * * * * * *

8/Jan/2014 5:09:18 PM: Exiting the Function 'fnCalculate'
8/Jan/2014 5:09:18 PM: === Inside the Test Set  ::   Divide  ===
8/Jan/2014 5:09:18 PM: Executing the Function 'fnCalculate'
8/Jan/2014 5:09:19 PM: The Actual Value after the Math Operation is 3.
8/Jan/2014 5:09:19 PM: * * * * * * Test Case Exec Details  * * * * *
8/Jan/2014 5:09:19 PM: Test staus :: Pass
8/Jan/2014 5:09:19 PM: Tese ID ::  TC_004
8/Jan/2014 5:09:19 PM: Test Description :: Divide
8/Jan/2014 5:09:19 PM: Test Result Details ::  Expected Value matches with Actual
   Value :: 3.
8/Jan/2014 5:09:19 PM: * * * * * * * * * * * * * * * * * * * * * * * *  * * *
* * * * * * * *

8/Jan/2014 5:09:19 PM: Exiting the Function 'fnCalculate'
8/Jan/2014 5:09:19 PM: === Inside the Test Set  ::   Sqrt  ===
8/Jan/2014 5:09:19 PM: Executing the Function 'fnCalculate'
8/Jan/2014 5:09:20 PM: The Actual Value after the Math Operation is 10.
8/Jan/2014 5:09:20 PM: * * * * * * Test Case Exec Details  * * * * *
8/Jan/2014 5:09:20 PM: Test staus :: Pass
8/Jan/2014 5:09:20 PM: Tese ID ::  TC_005
8/Jan/2014 5:09:20 PM: Test Description :: Sqrt
8/Jan/2014 5:09:20 PM: Test Result Details ::  Expected Value matches with Actual
   Value :: 10.
8/Jan/2014 5:09:20 PM: * * * * * * * * * * * * * * * * * * * * * * * *  * * * *
* * * * * * *

8/Jan/2014 5:09:20 PM: Exiting the Function 'fnCalculate'
8/Jan/2014 5:09:20 PM: Status Message - Executing the Function 'fn_Finish_test'
8/Jan/2014 5:09:20 PM: ## # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # #
8/Jan/2014 5:09:20 PM: ##  The Execution Start Time  ::  5:09:14 PM
8/Jan/2014 5:09:20 PM: ##  The Execution End Time   ::  5:09:20 PM
8/Jan/2014 5:09:20 PM: ##  The Time Elapsed ::   0 Minutes
8/Jan/2014 5:09:20 PM: ##  The OS ::  Microsoft Windows Vista Server
8/Jan/2014 5:09:20 PM: ##  The Total No of Test Cases Executed  ::  25
8/Jan/2014 5:09:20 PM: ##  The No. of Test Case Passed ::  25
8/Jan/2014 5:09:20 PM: ##  The No. of Test Case Failed ::
8/Jan/2014 5:09:20 PM: ## # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # #