QTP的那些事 -– Visual Relation Identifier Feature: How to use in the real world
2012-02-11 16:03
597 查看
原文地址:
http://www.joecolantonio.com/2012/02/03/qtp-visual-relation-identifier/
y JOE COLANTONIO
Tweet My real-world example My team often runs into problems when running automated scripts against our unique testing environments. One of them is that some of our application screens contain proprietary custom controls that don't have any real unique values except for Windows ID, which works about 99% of the time. Another issue we face is due to the fact that we run against shared test environments, which means that anyone can make system-wide setting changes without our knowledge. Some of those changes cause a custom screen to appear rather than the expected screen. As you can imagine, these two issues in particular can throw up myriad roadblocks to running our test automation scripts reliably. Custom screen issue
Below is an example of an expected screen being replaced with a custom screen. (Notice that both the screen name label and field's location changes.) Since we use Window ID as an identifier, the expected MRN field is Window ID 516 for screen one, and 519 for screen two. Possible Screen One
Possible Screen Two
There are a few ways we can handle this, but for this example I'm going to use QTP's "Visual Relation Identifier" feature. Visual Relation Identifier
Visual Relation Identifiers allow you to identify fields in your application based on other objects that are always near them. In my example, the MRN label text always appears to the left of the MRN field. How to add a Visual Relation Identifier to an object repository
In the QTP object repository click to on the visual identifier setting's click to add
On the Visual Relation Identifier screen click on the + plus sign under the previewbutton:
Point to the object you want to use to help QTP identify the field you need to recognize
I'll point to the MRN text that's adjacent to the MRN field that I want to enable QTP to find:
Three Visual Relation Identifier detail options:
When you bring up the Visual Relation Identifier you'll have three main categories (under Relation Details) to choose from: Horizontal, Vertical and Distance and Hierarchy. Hortizontal – Enables you to tell QTP to id objects according to their hortizontal location in relation to the field to be indentified. You'll have two options (Left and Right)and an In line (horizontal) checkbox option. In my example, I want to tell QTP that the text "MRN" is to the left of my MRN textbox and that it is in line horizontal. Vertical – Enables QTP to find related objects based on their vertical location relative to the object you want to identify. It also has two options (Above and Below) and a In Line (vertical) checkbox option. Distance and Hierarchy – Enables QTP to find related objects based on their distance to the location of the object you want to identify. It has four options: Closest on the X-axis, Closest o n the Y-axis, Closest on both axes and Contains. (For my example, I needed to use "Closest to the Y-Axis" to make the field identification unique.)
Preview –does QTP see it now?
If I hit the preview button I can see that QTP is now able to identify the MRN textbox using the MRN text as its visual identifier. Now my script can identify the MRN field on the custom screen:
And on the expected screen:
Excellent!
The preceding is a real-world example of automation awesomeness using QTP's new Visual Relation Identifier feature. Let me know what your experience has been with the Visual Identifier by leaving a comment below with your thoughts.
http://www.joecolantonio.com/2012/02/03/qtp-visual-relation-identifier/
y JOE COLANTONIO
Tweet My real-world example My team often runs into problems when running automated scripts against our unique testing environments. One of them is that some of our application screens contain proprietary custom controls that don't have any real unique values except for Windows ID, which works about 99% of the time. Another issue we face is due to the fact that we run against shared test environments, which means that anyone can make system-wide setting changes without our knowledge. Some of those changes cause a custom screen to appear rather than the expected screen. As you can imagine, these two issues in particular can throw up myriad roadblocks to running our test automation scripts reliably. Custom screen issue
Below is an example of an expected screen being replaced with a custom screen. (Notice that both the screen name label and field's location changes.) Since we use Window ID as an identifier, the expected MRN field is Window ID 516 for screen one, and 519 for screen two. Possible Screen One
Possible Screen Two
There are a few ways we can handle this, but for this example I'm going to use QTP's "Visual Relation Identifier" feature. Visual Relation Identifier
Visual Relation Identifiers allow you to identify fields in your application based on other objects that are always near them. In my example, the MRN label text always appears to the left of the MRN field. How to add a Visual Relation Identifier to an object repository
In the QTP object repository click to on the visual identifier setting's click to add
On the Visual Relation Identifier screen click on the + plus sign under the previewbutton:
Point to the object you want to use to help QTP identify the field you need to recognize
I'll point to the MRN text that's adjacent to the MRN field that I want to enable QTP to find:
Three Visual Relation Identifier detail options:
When you bring up the Visual Relation Identifier you'll have three main categories (under Relation Details) to choose from: Horizontal, Vertical and Distance and Hierarchy. Hortizontal – Enables you to tell QTP to id objects according to their hortizontal location in relation to the field to be indentified. You'll have two options (Left and Right)and an In line (horizontal) checkbox option. In my example, I want to tell QTP that the text "MRN" is to the left of my MRN textbox and that it is in line horizontal. Vertical – Enables QTP to find related objects based on their vertical location relative to the object you want to identify. It also has two options (Above and Below) and a In Line (vertical) checkbox option. Distance and Hierarchy – Enables QTP to find related objects based on their distance to the location of the object you want to identify. It has four options: Closest on the X-axis, Closest o n the Y-axis, Closest on both axes and Contains. (For my example, I needed to use "Closest to the Y-Axis" to make the field identification unique.)
Preview –does QTP see it now?
If I hit the preview button I can see that QTP is now able to identify the MRN textbox using the MRN text as its visual identifier. Now my script can identify the MRN field on the custom screen:
And on the expected screen:
Excellent!
The preceding is a real-world example of automation awesomeness using QTP's new Visual Relation Identifier feature. Let me know what your experience has been with the Visual Identifier by leaving a comment below with your thoughts.
相关文章推荐
- How to use the System Restore API to save and to restore system data in Visual C++
- How To Use the ODBC .NET Managed Provider in Visual C# .NET and Connection Strings
- How to load a raster dataset to the raster field in a feature class
- [Ubuntu] 如何在VirtualBox OSE中使用share folders -- How to use the share folders in VirtualBox OSE
- How can I force Python's file.write() to use the same newline format in Windows as in Linux (“\r\n”
- HOWTO make ns-3 interact with the real world
- How To Set Dark Theme in Visual Studio 2010
- How to face the changeable real world?
- 《How to Use the TimeDistributed Layer for Long Short-Term Memory Networks in Python》学习笔记
- how to use a SQLite database in a standalone program with an HTML interface and VBScript as the programming language
- How to use the pointer of function in a class?
- Notes on how to use Webots, especially how to make a robot fly in the air
- "How to use QThread in the right way (Part 1)"
- How to use an external dll file in VisualStudio project
- HOWTO Use Python in the web — Python v3.0.1 documentation
- How to use "man" effectively in the development of Linux
- How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET(利用Ado.net导出到Excel)
- How to use an external dll file in VisualStudio project
- How to use the Install from Media feature to promote Windows Server 2003-based domain controllers
- How To Use the Spreadsheet Web Component with Visual Basic