Krishna Logo
qa training in canada now
Divied
Call: Anusha @ 1 (877) 864-8462

 

Latest News
Home Navigation Divied
OTHERS Navigation Divied QUICK TEST PROFESSIONAL
Showing 81 - 90 of 114 Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next
QUICK TEST PROFESSIONAL
Subcategories
 
81

Problem Description: How to use regular expressions


Solution: Using regular expressions

A regular expression is a string that specifies a complex search phrase. In most cases the string is preceded by an exclamation point (!). By using special characters such as a period (.), asterisk (*), caret (^), and brackets ([ ]), you define the conditions of the search.

Note:
In descriptions or arguments of functions where a string is expected, such as the match function, the exclamation point is not required.

Regular expression syntax
Regular expressions must begin with an exclamation point (!), when defined in a physical description. It is not used with GUI checkpoint properties, a text checkpoint, or a match, obj_find_text, or win_find_text statement. All characters in a regular expression are searched for literally, except for a period (.), asterisk (*), caret (^), and brackets ([ ]). When one of these special characters is preceded by a backslash (), WinRunner searches for the literal character.

For information on how to use the regular expression characters, please refer to Problem ID 15102 - What options are available for use in regular expressions.

A regular expression should be used when a property of a GUI object can change each time you replay your script.

Example:
In the application, you create an order. A few screens later, the order number is appended to the window's title. During replay, a new order will be created generating a different order number. Using the old order number when referring to the window will cause the script to fail since WinRunner cannot find the window. You can use the regular expression to instruct WinRunner to ignore the varying part of the window title.

Regular expressions can be used in the following cases:

  • Within the physical description of a window or object in the GUI Map
  • Within a GUI checkpoint, when verifying the contents of an edit field or static text object.
  • Within TSL functions that search for text, such as win_find_text and obj_find_text.

Using a regular expression in an object or window's physical description
You can use a regular expression in the physical description of an object in the GUI map, so that WinRunner can ignore variations in the value of a property, such as label. Regular expressions are typically used with the properties that reference the object's label or title, though they are not restricted to those properties. Any attribute that refers to a text property and not a physical property (x, y, width, height, etc.) is a candidate for regular expression use.

Note:
Being a candidate for regular expression use does not mean that WinRunner will be able to find the object or window once you include the regular expression. You may have to use trial and error to determine if the problematic attribute will accept a regular expression. If a regular expression cannot be used for the varying property, use GUI Map Configuration to instruct WinRunner to use a different set of properties when learning the object. For more information on GUI Map Configuration, please refer to Problem ID 1330 - How to use basic GUI Map Configuration.

The attached document demonstrates how to use a regular expression with the label property of a window.

Using a regular expression in a GUI checkpoint.
You can use a regular expression in a GUI checkpoint, when evaluating the contents of an edit object or a static text object with a varying name. You define the regular expression by creating a GUI checkpoint on the object in which you specify the checks.

Note:
Some objects, such as edit fields, have regular expression property checks build in as options by default. If the object you are checking does not have a default regular expression property check, you can create a custom property check for use. For more information, refer to the Customizing GUI Checks section in the WinRunner Customization Guide. You can also refer to Problem ID 469 - How to add regular expressions for HTML links in a GUI check as an example on how to create a custom property check functions.

1. Go to Create -> GUI Checkpoint -> For Object/Window.
2. Double click on the object (very fast).
3. When the Check GUI window appears, select the RegularExpression property check.

Note:
If you are created your own custom regular expression property check, select the appropriate property check.

4. With the property check highlighted, click the specify arguments button. This is the second button in the group at the right side of the window.
5. In the Check Arguments dialog, enter the regular expression and click .

Note:
When a regular expression is used to perform a check in a GUI checkpoint, it should not be preceded by an exclamation point.

6. Select any additional property checks as desired.
7. Click to close the dialog and insert a checkpoint statement into your script.

Using a regular expression when searching for text
You can use a regular expression to locate a varying text string with the win_find_text and obj_find_text functions.

Example:
obj_find_text("Edit", "Order No.*", coord_array);

or

win_find_text("Edit", "Order No.*", coord_array);

For additional information on using regular expressions, please refer to the Using Regular Expressions chapter in the WinRunner User's Guide. The following articles also provide additional information:

 

How To Use Regular Expressions
Date Posted: 05/05/2012

Problem Description: How to use regular expressions Solution: Using regular expressions A regular expression is a string that specifies a complex search phrase. In most cases the string is preceded by an exclamation point (!)...  

 
 
82How To Update XML File From QTP
Date Posted: 05/05/2012

 
 

How to retrieve values returned by a db_execute_query statement Use ...  

 
 
84How To Locate And Click On An Item In A Web Table
Date Posted: 05/05/2012

 
 
85How To Get The Text Of A Link Object Retrieved Using The Childitem Method
Date Posted: 05/05/2012

set obj=browser("hotmail-the").page("hotmail inbox").webtable("allbox").childitem(6,3,"link",0)
if obj.queryvalue("text")="expected value" then
obj.click
end if

 
 

How to get data from an Excel file without importing the data to the dat...  

 
 
87

How to format a date to dd/mon/yyyy

The user would like to retrieve the system date in a specific format (such as DD/MON/YYYY). Is there a way to specify the desired format?
________________________________________
Solution: Retrieving the date in the desired format
QuickTest Professional does not have a built-in function that will allow you to specify the format of the returned date. You can write custom functions to get the date in the desired format. VBScript's date and time functions can be used internally.
Date
Returns the current system date.
Day(date)
Returns a whole number between 1 and 31, inclusive, representing the day of the month.
Month(date)
Returns a whole number between 1 and 12, inclusive, representing the month of the year.
Year(date)
Returns a whole number representing the year.
MonthName(month[, abbreviate])
Returns a string indicating the specified month.
WeekdayName(weekday, abbreviate, firstdayofweek)
Returns a string indicating the specified day of the week.
date    Any expression that represents a date.
month    The numeric designation of the month.
weekday    The numeric designation for the day of the week.
abbreviate    Boolean value that indicates if the month or weekday name is to be abbreviated.
For additional information on these functions or the time functions, refer to the VBScript Reference Guide (QuickTest Professional Help -> Microsoft Windows Script Technologies -> VBScript -> Reference -> Functions).
Note:
This function is not part of QuickTest Professional. It is not guaranteed to work and is not supported by Mercury Customer Support. You are responsible for any and all modifications that may be required.
Example:
Function date_ddmonyyyy()
' return the date in the DD/MON/YYYY format, ex. 31/Aug/2004
a = MonthName(Month(Date()), true)
b = Day(Date())
c = Year(Date())
If b<10 Then
b="0"& b
End If
date_ddmonyyyy = b & "/" & a & "/" & c
End Function
d = date_ddmonyyyy()
msgbox d

How To Format A Date To Dd/mon/yyyy
Date Posted: 05/05/2012

How to format a date to dd/mon/yyyy The user would like to retrieve the system date in a specific format (such as DD/MON/YYYY). Is there a way to specify the desired format? ________________________________________ Solution: Retrieving th...  

 
 

Problem Description: How to compare two tables within a database Sol...  

 
 

 How to add cells, rows, or columns to an Excel document ...  

 
 

Here are several different connection strings which you may use to conne...  

 
Showing 81 - 90 of 114 Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next
Shadow Bottom
 
 
© 2005 -