Wednesday, November 26, 2008

How to get Tool tip of Images in a web page

Browser("abc").Page("abc").Sync
Set desc_img = Description.Create
desc_Img("html tag").value = "IMG"
Set list_imgs= Browser("abc").Page("abc").ChildObjects(desc_img)
For i = 0 To list_imgs.Count - 1
tool_tiptxt= list_imgs(i).GetROProperty("alt")
If tool_tiptxt <> "" Then
MsgBox "Tool tip text= " & tool_tiptxt
End If
Next

Monday, November 24, 2008

Wednesday, November 5, 2008

11:30 PM - , No comments

VB Scripting Imp Functions

Some VB Script IMP Functions


Array Function

Returns a Variant containing an array.

Array(arglist)

The required arglist argument is a comma-delimited list of values that are assigned to the elements of an array contained with the Variant. If no arguments are specified, an array of zero length is created.

Remarks

The notation used to refer to an element of an array consists of the variable name followed by parentheses containing an index number indicating the desired element. In the following example, the first statement creates a variable named A. The second statement assigns an array to variable A. The last statement assigns the value contained in the second array element to another variable.

Dim A
A = Array(10,20,30)
B = A(2)   ' B is now 30.

Note A variable that is not declared as an array can still contain an array. Although a Variant variable containing an array is conceptually different from an array variable containing Variant elements, the array elements are accessed in the same way.

CDate Function

Returns an expression that has been converted to a Variant of subtype Date.

CDate(date)

The date argument is any valid date expression.

Remarks

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.

The following example uses the CDate function to convert a string to a date. In general, hard coding dates and times as strings (as shown in this example) is not recommended. Use date and time literals (such as #10/19/1962#, #4:45:23 PM#) instead.

MyDate = "October 19, 1962"   ' Define date.
MyShortDate = CDate(MyDate)   ' Convert to Date data type.
MyTime = "4:35:47 PM"         ' Define time.
MyShortTime = CDate(MyTime)   ' Convert to Date data type.

Chr Function

Returns the character associated with the specified ANSI character code.

Chr(charcode)

The charcode argument is a number that identifies a character.

Remarks

Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character.

The following example uses the Chr function to return the character associated with the specified character code:

Dim MyChar
MyChar = Chr(65)   ' Returns A.
MyChar = Chr(97)   ' Returns a.
MyChar = Chr(62)   ' Returns >.
MyChar = Chr(37)   ' Returns %.

Note The ChrB function is used with byte data contained in a string. Instead of returning a character, which may be one or two bytes, ChrB always returns a single byte. ChrW is provided for 32-bit platforms that use Unicode characters. Its argument is a Unicode (wide) character code, thereby avoiding the conversion from ANSI to Unicode.

IsObject Function

Returns a Boolean value indicating whether an expression references a valid Automation object.

IsObject(expression)

The expression argument can be any expression.

Remarks

IsObject returns True if expression is a variable of Object subtype or a user-defined object; otherwise, it returns False.

The following example uses the IsObject function to determine if an identifier represents an object variable:

Dim MyInt, MyCheck, MyObject
Set MyObject = Me
MyCheck = IsObject(MyObject)   ' Returns True.
MyCheck = IsObject(MyInt)   ' Returns False.

Join Function

Returns a string created by joining a number of substrings contained in an array.

Join(list[, delimiter])

Arguments

list

Required. One-dimensional array containing substrings to be joined.

delimiter

Optional. String character used to separate the substrings in the returned string. If omitted, the space character (" ") is used. If delimiter is a zero-length string, all items in the list are concatenated with no delimiters.

Remarks

The following example uses the Join function to join the substrings of MyArray:

Dim MyString
Dim MyArray(3)
MyArray(0) = "Mr."
MyArray(1) = "John "
MyArray(2) = "Doe "
MyArray(3) = "III"
MyString = Join(MyArray) ' MyString contains "Mr. John Doe III".

LBound Function

Returns the smallest available subscript for the indicated dimension of an array.

LBound(arrayname[, dimension])

Arguments

arrayname

Name of the array variable; follows standard variable naming conventions.

dimension

Whole number indicating which dimension's lower bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.

Remarks

The LBound function is used with the UBound function to determine the size of an array. Use the UBound function to find the upper limit of an array dimension.

The lower bound for any dimension is always 0.

LCase Function

Returns a string that has been converted to lowercase.

LCase(string)

The string argument is any valid string expression. If string contains Null, Null is returned.

Remarks

Only uppercase letters are converted to lowercase; all lowercase letters and non-letter characters remain unchanged.

The following example uses the LCase function to convert uppercase letters to lowercase:

Dim MyString
Dim LCaseString
MyString = "VBSCript"
LCaseString = LCase(MyString)   ' LCaseString contains "vbscript".

Left Function

Returns a specified number of characters from the left side of a string.

Left(string, length)

Arguments

string

String expression from which the leftmost characters are returned. If string contains Null, Null is returned.

length

Numeric expression indicating how many characters to return. If 0, a zero-length string("") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Remarks

To determine the number of characters in string, use the Len function.

The following example uses the Left function to return the first three characters of MyString:

Dim MyString, LeftString
MyString = "VBSCript"
LeftString = Left(MyString, 3) ' LeftString contains "VBS".

Note The LeftB function is used with byte data contained in a string. Instead of specifying the number of characters to return, length specifies the number of bytes.

LTrim; RTrim; and Trim Functions

Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim).

LTrim(string)
RTrim(string)
Trim(string)

The string argument is any valid string expression. If string contains Null, Null is returned.

Remarks

The following example uses the LTrim, RTrim, and Trim functions to trim leading spaces, trailing spaces, and both leading and trailing spaces, respectively:

Dim MyVar
MyVar = LTrim("   vbscript ")   ' MyVar contains "vbscript ".
MyVar = RTrim("   vbscript ")   ' MyVar contains "   vbscript".
MyVar = Trim("   vbscript ")   ' MyVar contains "vbscript".

Right Function

Returns a specified number of characters from the right side of a string.

Right(string, length)

Arguments

string

String expression from which the rightmost characters are returned. If string contains Null, Null is returned.

length

Numeric expression indicating how many characters to return. If 0, a zero-length string is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Remarks

To determine the number of characters in string, use the Len function.

The following example uses the Right function to return a specified number of characters from the right side of a string:

Dim AnyString, MyStr
AnyString = "Hello World"      ' Define string.
MyStr = Right(AnyString, 1)    ' Returns "d".
MyStr = Right(AnyString, 6)    ' Returns " World".
MyStr = Right(AnyString, 20)   ' Returns "Hello World".

Note The RightB function is used with byte data contained in a string. Instead of specifying the number of characters to return, length specifies the number of bytes.

Split Function

Returns a zero-based, one-dimensional array containing a specified number of substrings.

Split(expression[, delimiter[, count[, compare]]])

Arguments

expression

Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.

delimiter

Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.

count

Optional. Number of substrings to be returned; -1 indicates that all substrings are returned.

compare

Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.

Settings

The compare argument can have the following values:

Constant

Value

Description

vbBinaryCompare

0

Perform a binary comparison.

vbTextCompare

1

Perform a textual comparison.

Remarks

The following example uses the Split function to return an array from a string. The function performs a textual comparison of the delimiter, and returns all of the substrings.

Dim MyString, MyArray, Msg

MyString = "VBScriptXisXfun!"

MyArray = Split(MyString, "x", -1, 1)

' MyArray(0) contains "VBScript".

' MyArray(1) contains "is".

' MyArray(2) contains "fun!".

Msg = MyArray(0) & " " & MyArray(1)

Msg = Msg & " " & MyArray(2)

MsgBox Msg

Sqr Function

Returns the square root of a number.

Sqr(number)

The number argument can be any valid numeric expression greater than or equal to 0.

Remarks

The following example uses the Sqr function to calculate the square root of a number:

Dim MySqr
MySqr = Sqr(4)   ' Returns 2.
MySqr = Sqr(23)   ' Returns 4.79583152331272.
MySqr = Sqr(0)   ' Returns 0.
MySqr = Sqr(-4)   ' Generates a run-time error.

StrComp Function

Returns a value indicating the result of a string comparison.

StrComp(string1, string2[, compare])

Arguments

string1

Required. Any valid string expression.

string2

Required. Any valid string expression.

compare

Optional. Numeric value indicating the kind of comparison to use when evaluating strings. If omitted, a binary comparison is performed. See Settings section for values.

Settings

The compare argument can have the following values:

Constant

Value

Description

vbBinaryCompare

0

Perform a binary comparison.

vbTextCompare

1

Perform a textual comparison.

Return Values

The StrComp function has the following return values:

If

StrComp returns

string1 is less than string2

-1

string1 is equal to string2

0

string1 is greater than string2

1

string1 or string2 is Null

Null

Remarks

The following example uses the StrComp function to return the results of a string comparison. If the third argument is 1, a textual comparison is performed; if the third argument is 0 or omitted, a binary comparison is performed.

Dim MyStr1, MyStr2, MyComp

MyStr1 = "ABCD": MyStr2 = "abcd" ' Define variables.

MyComp = StrComp(MyStr1, MyStr2, 1) ' Returns 0.

MyComp = StrComp(MyStr1, MyStr2, 0) ' Returns -1.

MyComp = StrComp(MyStr2, MyStr1) ' Returns 1.

StrReverse Function

Returns a string in which the character order of a specified string is reversed.

StrReverse(string1)

The string1 argument is the string whose characters are to be reversed. If string1 is a zero-length string (""), a zero-length string is returned. If string1 is Null, an error occurs.

Remarks

The following example uses the StrReverse function to return a string in reverse order:

Dim MyStr
MyStr = StrReverse("VBScript") ' MyStr contains "tpircSBV".

Reference: HP QTP 9.5 Help

Wednesday, October 29, 2008

What's New in QuickTest Professional 9.5


Maintenance Run Mode:

Repair your test on the fly, this will assist you to adding the steps or updating the object properties in OR on the fly.i.e. If your object properties are changed after a new build, you just run the Maintenance Run Mode and update your OR according to that on the fly.

Process Guidance:

This is little more than more accessible help files. Maybe this is good for when you are first learning to record a test, but it doesn’t seem to add much utility.

Test Flow Pane

The Test Flow pane enables you to view all the calls to actions in the current test and the order in which they are run. You can right-click an action in the pane to view or modify the action or action call properties. You can double-click any action in the pane to open it in the document window. The icons in the flow pane indicate the type of action (local, reusable, external, looped action call, or missing action).

Available Keywords Pane

Use the Available Keywords pane to view all the objects and functions available to your test actions and components (from associated resources) and then drag and drop these objects and functions directly into your test or component.

When you drag and drop an object from the Available Keywords Pane into your test or component, QuickTest inserts a step with the default operation for that object. When you drag and drop a function into your test or component, QuickTest inserts a call to that function.

The Available Keywords pane can display the keywords available to your action or component sorted by resource or sorted by keyword.

Resources Pane

Using the Resources pane, you can associate new resources with your test, and you can remove, open, change the priority of, and otherwise manage the function libraries, recovery scenarios, and object repositories that are already associated with your test.

Missing Resources Pane

Use the Missing Resource pane to resolve references to resources that QuickTest is unable to find, including missing actions, function libraries, shared object repositories, environment variable files, and unmapped repository parameters.

Checkpoint and Output Objects in the Object Repository

For the first time, all your checkpoints and output values are stored as objects in the object repository so that you can manage them together with your test objects.

When these checkpoint and output objects are stored in a shared object repository, you can copy, move, and perform other operations on these objects just like you do with test objects.

In some cases, you may also find it convenient to insert an existing checkpoint or output value object into a new step in order to check, or retrieve data from, another test object of the same class. To do this, you can use the new Insert > Checkpoint > Existing Checkpoint or Insert > Output Value > Existing Output Value options.

Note: Bitmap checkpoints now include options for specifying tolerance values.

New Object Repository Options

When you export local objects to a shared object repository, you can choose to have QuickTest automatically update your steps to refer to the new object from the shared object repository.

Other Enhancements

    • By default, new actions are inserted as reusable actions.
    • When you specify an absolute path for a resource, QuickTest can automatically convert the path to a relative path.
    • You can now specify your text recognition preferences in the Options dialog box.
    • In QuickTest 9.5, you can learn objects from multiple technologies in a single learn (Add Objects) operation.
    • The Java Add-in now supports recording on SWT objects

New Supported Operating Systems and Environments

QuickTest Professional 9.5 has added new support for the operating systems, browsers, and development environments listed below.

For a complete list of all supported operating systems, browsers, and development environments, see the QuickTest Professional Readme.

  • Windows Vista 64-bit Edition
  • Netscape Browser 8.1.3, and 9
  • Mozilla Firefox 2 and 3.0 Alpha 7
  • Microsoft .NET Framework 3.5
  • Oracle Forms and Oracle Applications, version 10g
  • Java SWT toolkit, versions 3.2, and 3.3
  • Eclipse IDE, version 3.2 and 3.3 (For Java Add-in Extensibility)
  • New Terminal Emulator types and versions:
    • AttachmateWRQ EXTRA! 9, Terminal Viewer (compatible EXTRA! 9), Reflection for Unix and OpenVMS sessions 14, Reflection 14
      (Note: Reflection 13 is not supported.)
    • Hummingbird HostExplorer 2007
      (Note: HostExplorer 2006 is not supported)
    • IBM IBM 5.9, IBM WebSphere Host On-Demand 10
    • NetManage RUMBA 7.5, RUMBA Web-to-Host 5.3
    • Seagull BlueZone 4
    • Zephyr PASSPORT 2007, PASSPORT PC TO HOST / WEB TO HOST 2004 and 2007

Sunday, October 26, 2008

Action Template in QTP

Q: How to create a Action Template in QTP?
Ans:
Every time you open New script in QTP you will get a blank window in Expert view, 
now you can create a Template which you can use for all the scripts.
Just follow the Steps bellow....
1. Create a text file with what all things need to be in the script.
2. Save as this text file as ActionTemplate.mst file in the
C:\Program Files\hp\QuickTest Professional\dat Folder.
3. Now Click on new script in QTP. You will get what ever you have
text you have kept in the template !!!!!