TESTEVERYTHING

Thursday, 28 April 2011

Highlight the text on page using the QTP


Hi All,
Someone asked me how to highlight the text on page using the QTP. So here I have created a function that will find the text on page and highlight it if finds else not.


REM  ——  Set page object     ———
set objpage = Browser("BrowserName").Page("Pagename")


call   HighLightTextPresentOnPage(objpage ,"News" )

Function HighLightTextPresentOnPage(byval objpage , byval Textvalue )

On error resume next

REM ——- Create child object description
Set childobj = Description.Create()
childobj("micclass").value="WebElement"
childobj("html tag").value=".*[A-Za-z0-9].*"
childobj("outertext").value =Textvalue

REM  ———-Create ALL child object 
set allobj = objpage.ChildObjects(childobj)

 REM here highlight method we will use that is in build in QTP for object
For i=1 to allobj.count-1
    allobj.Item(i).HighLight
Next
           If allobj.count > 0 then
              HighLightTextPresentOnPage = true
           Else
              HighLightTextPresentOnPage = false
           End if

             On Error GoTo 0
End Function

Monday, 18 April 2011

Close All Browser QTP

‘ This function Close All open Browser

REM *************************************************************************
REM this function close All open browser
Public Function   fn_CloseAllBrowser()

    While Browser(“CreationTime:=0″).Exist

          Browser(“CreationTime:=0″).Close

   Wend

End Function

REM *************************************************************************
Rem another way to close browser here  this function terminate application ‘process
rem like internet explorer exe will close from system process
dim sApplicationExe
sApplicationExe = “iexplore.exe”
Rem call function to close application process
call fn_CloseApplication( sApplicationExe)
REM This function kill the given process exe  through task manager
Public Function  fn_CloseApplication( byval sApplicationExe)

   Dim strComputer

   Dim objWMIService

   Dim colProcesses

  Dim objProcess

  strComputer = “.”

  Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2″)
  Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘”&sApplicationExe&”‘”)

  For Each objProcess in colProcesses

   objProcess.Terminate()

  Next

  Set objWMIService = Nothing

  Set colProcesses=Nothing

End Function

REM through this function you can close any application process



QTP is not recording the web application

Hi All,
I faced the problem when I installed the QTP in vista.QTP  was not recording any web application then i tried to check with OBJECT SPY how its identify the web object Object Spy identify the each web object as a winobject. Then i found the solution to solve this problem this was because vista User control . In Vista you need to off USER CONTROL option after that QTP works fine and records the web application. To off the USER CONTROL option follow the following steps:
Click Start  >Control Panel>User Accounts and Family Safety>User Accounts
and uncheck  the Turn User Account Control On or OFF option

QTP not recording web application in VISTA

Here is the sequence of tries
1. Try Opening QTP-11 as Administrator mode
Right click QTP short cut>>Run As Administrator Mode
2. If above does not work then go to control panel and set User account setting to low level ie. not to notify and then repeat step-1
3. If both 1&2 does not work then go to IE>Tools>Internet Options>Advanced>Browsing>Enable Third Party Browser extension ( usually in IE8 by default it will be enabled) and then repeat step-1/2
4. If all above 3- does not work then you may think of running IE as 32-bit ( but i din;t understood how one can run IE8 32-bit browser on 64-bit machine. ( I have not tried this solution…/ And i suggest not to try step-4.)

Sunday, 17 April 2011

QTP 11 Installation Issues/Errors


Hi All ,Most of time, we are facing the problem while running the QTP OR installation but some times these problems are unknown to us because we did not read the installation procedure or limitations or known issues, So please have a look :-

Notes and Limitations


This section includes the following:
     
  • Before You Install
  • Supplemental Information

Before You Install


This section includes information that is important for you to know before you install QuickTest.
     
  • You cannot install QuickTest when a McAfee Anti-Virus application is running.
  • Workaround: Disable the antivirus application during the QuickTest installation process.
  • QuickTest Professional supports the Sentinel RMS License Manager version 8.3.0 as its concurrent license server. Earlier versions of the concurrent license server are not supported.
  • QuickTest does not support Windows user names with non-English letters. If you log in to Windows using a user name (with administrative privileges) that contains non-English characters and then install QuickTest, the installation may complete successfully, but you may not be able to open QuickTest or it may not behave correctly.
  • The path in which installation files for QuickTest are located, and the path in which QuickTest is installed, can contain only English characters.
  • When upgrading to QuickTest 11.00 from a QuickTest 9.5 or 10.00 installation on which a Language Pack (localized version of QuickTest) was previously installed, you may get an error message when opening QuickTest after the upgrade.
  • Workaround: Repair the installation:
       
    1. In the Control Panel, select Add/Remove Programs and select the HP QuickTest Professional entry.
    2. Click the Change button.
    3. In the installation wizard that opens, choose the Repair option and follow the on-screen instructions.
  • If you install QuickTest 11.00 while the QTPNET_00015 patch (a QuickTest 10.00 patch) is installed on your computer, QuickTest may behave unexpectedly.
  • Workaround:
       
    1. Open the Add/Remove Programs dialog box from the Control Panel.
    2. Display the installed patches by selecting the Show updates check box (or click the View Installed Updates button, depending on your operating system version.)
    3. Locate HP QuickTest Professional in the list and check whether QTPNET_00015 for HP QuickTest Professional 10.00 QFE is listed as an installed update.
    4. If it is installed, click Remove to uninstall this patch before you install QuickTest 11.00.
  • If you want to work with .NET 4.0, it is best to install it before you install QuickTest. If you install .NET 4.0 after you install QuickTest, you must manually register two .NET DLLs as follows:
  • In <QuickTest installation folder>\GlobalAssemblyCache\Net4, execute the following commands:
       
    • ..\..\bin\GACRegUtil4x86.exe -i Mercury.QTP.Agent.dll
    • ..\..\bin\GACRegUtil4x86.exe -i Mercury.QTP.WpfAgent.dll
  • In Windows XP and Windows 2003, if you install the Oracle Add-in, the Windows Remote Shell Service (rshsvc.exe) may fail and display an error message every time you restart the computer. This occurs only if the Remote Shell Service is configured to run automatically.

Supplemental Information


Use the information in this section as a supplement to the product documentation.

Additional troubleshooting information, guidelines, and feature-specific limitations are described in the relevant locations of the installation and product documentation. Make sure you are aware of those issues when working with the relevant features.

This section includes the following:

Installation

     
  • When you install a new QuickTest 11.00 installation and you specify a single concurrent license server in the License Wizard, QuickTest now automatically specifies the server in an LSFORCEHOST environment variable, to optimize performance. However if you perform an upgrade from QuickTest 10.00, and you already had an LSHOST variable defined, the upgrade installation does not change the setting to LSFORCEHOST.
  • Workaround: If desired, set the LSFORCEHOST variable manually, as described in the HP Functional Testing Concurrent License Server Installation Guide.
  • If you manually set an LSHOST environment variable to a particular server (or upgrade from a previous version of QuickTest where the LSHOST variable was set), QuickTest sometimes gets its license from another server, even when the specified server has the required licenses available.
  • Workaround: To ensure that a specific server will be used, specify an LSFORCEHOST environment variable instead.

Operating Systems


If you work with QuickTest on a Windows 7 operating system with User Account Control (UAC) turned on, and you open a test from a protected location (such as Program Files), it is opened in read-only mode and a message is displayed that you do not have permissions to open it in read-write mode.

General

     
  • When you save a test using the Save Test with Resources option, it also saves any tests containing called external actions. However, to preserve space, these called tests contain only the called actions, and not all of the actions from the original test. Therefore, you cannot open these called tests in QuickTest from the local copy.
  • Workaround: If you need to have full access to the called tests as well as the main test that you save using the Save Test with Resources option, then you must manually save all required tests locally and then manually edit all references to the relevant actions from the main test to the actions it calls.

Web Add-in

     
  • The If Handler option in the Web Event Recording Configuration dialog box works on Mozilla Firefox browsers only if the handler is assigned as an attribute (for example, <A onclick = “some code”/>) and not if it is assigned as a property (for example, aObj.onclick = function() {some code})

Silverlight Add-in

     
  • When Silverlight applications are opened in two tabs sequentially (without QuickTest performing any operations on the first one before the second opens), QTP will use a custom server to support controls only in the first application with which you interact. The same is true when two tabs are refreshed sequentially.
  • Workaround: Perform an operation (for example, use the Object Spy) with the first tab opened/refreshed before opening/refreshing the second one.
  • If a Web page contains a Silverlight application that is windowless and is scrolled out of view when the page opens the first time, QuickTest will not be able to make this application visible. (For example, in this scenario, QuickTest will not be able to perform an SlvWindow.MakeVisible step).

Quality Center and Business Process Testing

     
  • When comparing two baselines, if the only change in a resource is its association to a test or component, the Asset Comparison Tool does not indicate any change in the resource even though HP ALM or Quality Center may indicate that the resource is Modified.
  • If an HP ALM or Quality Center user manually changes the status of a test instance run, HP ALM/Quality Center creates something called fast run results to record the change of the test status. The fast run results are not valid QuickTest run results files. However, when you try to select results to open or delete in the Run Results Viewer or Run Results Deletion tool, the fast run results are available in the list.
  • After you run a component locally in QuickTest, you cannot use the Jump to Step in QuickTest option from the Run Results Viewer.
  • You cannot perform a remote execution of a business process test on a Windows 2008 R2 QuickTest computer.

Documentation

     
  • The QuickTest Help Index tab contains only reference items, such as objects, methods, properties, and functions. It does not contain any entries from the user guides.
  • To search for information from all the documents in the QuickTest Documentation Library, use the Search tab.
  • On some operating systems or after installing certain Windows service packs or updates, you may not be able to view the content of some Help files.
  • Workaround:
       
    1. Right-click the CHM file in <QTP installation folder)\help, and click Properties.
    2. In the dialog box that opens, click Unblock.
    3. For details, see http://support.microsoft.com/kb/902225

Internationalization

     
  • If you are working with a QuickTest User Interface Pack, install it before running QuickTest for the first time, if possible.
  • If you install a QuickTest User Interface Pack after running QuickTest, the following items may remain in English after installing the User Interface Pack:
       
    • Menus and toolbars in the Object Repository window (in QuickTest or in the Object Repository Manager)
    • The Find dialog box in the Expert View
    • Workaround: Close QuickTest and delete the folder: %APPDATA%\HP\QuickTest Professional(For example, C:\Documents and Settings\<username>\Application Data\HP\QuickTest Professional).
  • When working on an operating system using a Spanish locale, you may get an assertion error message at the beginning of the QuickTest installation.
  • Workaround: Modify the sLanguage registry key value as follows:
       
    1. In the Start > Run dialog box, type: regedit.
    2. Go to the registry path: HKEY_CURRENT_USER\Control Panel\International
    3. Change the sLanguage value from ES to ESN
    4. If the above steps do not solve the problem, restart your computer and try again.
    5. Run the QuickTest installation again.
  • Selecting the View Sample Snapshot option in the QuickTest Asset Comparison Tool opens a window containing a sample image of the selected element in QuickTest. The image displays the English user interface.
  • The Add-in Extensibility SDKs are not localized.

Visual Relation Identifiers QTP 11

HI All,
In QTP 11 has added one more advanced feature Visual Relation Identifiers that will help to identify the objects with relation to other objects
You can now use visual relation identifiers to identify application objects based on other objects that are always near them.

This enables you to create a more reliable identification definition for test objects that are otherwise difficult to differentiate, and to ensure that the identification remains reliable even if the user interface design changes.
When testing applications with multiple identical objects, QuickTest assigns an ordinal identifier to each test object. This may lead to unreliable object identification. However, it may not (immediately) result in a failed step.
A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. You can select neighboring objects that will maintain the same relative location to your object, even if the user interface design changes. This enables you to help QuickTest identify similar objects much as a human tester would, and helps in creating more stable object repositories that can withstand predictable changes to the application’s user interface.
How Visual Relation Identifiers Work
Suppose that you are shown a photograph of a classroom, and are then asked to note identical twins sitting at different desks, and to be able to identify each twin successfully when shown different photographs of the same classroom at a later time.
You are told that one differentiating characteristic is that one twin always carries a blue school bag, and that the other twin always carries a red school bag. You are then also told that each twin has an assigned desk partners, which means that even if the twins sit at a different desk in other photographs, they always sit next to their assigned lab partners.
Therefore, the solution is to identify the twin with the blue school bag in this manner: <twin> is nearest to <twin’s desk partner>, and carries <blue school bag>.
QuickTest uses visual relation identifiers in a similar manner, by examining related objects in the application that you are testing. However, because QuickTest compares the related objects based on their relation to the test object to identify as a set of definitions, you would state that <twin’s desk partner> is nearest to <twin>, and not vice versa.
Watch the Visual Relation Identifiers movie to see a demonstration of how this functionality can be used in an end-to-end process.


NOTE : — > QuickTest uses visual relation identifiers only when one or more objects match the test object’s description properties during the identification process. If no objects in the application match the test object’s description properties, then the visual relation identifier you defined is ignored, and QuickTest continues to Smart Identification (if defined for that test object class).

Wednesday, 13 April 2011

Use Regular Expressions QTP


Some Time QTP not recognize the application object during seond run it Or it run first time successfully then QTP give an error cannot identified the application Window object properties does not match with the test object. there might be a case of window name /object name change each time. Here we required the use of regular expression See the example
Regular Expression
Regular Expression
During Recording of  Flight application QTP record the flight application it identified the Fax order window name property like this
It Text Property is Fax order 11
If you run this script Again it will give an error because Fax order Window name will be
Fax order 12
Regular
Regular
Cannot identify the object “Fax Order No. 11″ (of class Dialog). Verify that this object’s properties match an object currently displayed in your application.
Line (1): “Window(“Flight Reservation”).Dialog(“Fax Order No. 11″).Activate”.
Now we change text property to regular expression open Object properties from object repository  .Click on text property value cell
objectproperty
objectproperty
Check regular expression check box A message will appear click NO. Now change Text box value according to Regular expreesion.
Fax Order No. 11 to Fax Order No.*
Here each time only last part getting changed here we use .* as regular expression means it will check only Fax order No text not whole string
Same case can we apply for different object properties if they getting changed
A regular expression is a string that describes or matches a set of strings. It is often called a pattern as it describes set of strings.
Given underneath is one of the most widely used and ever confused BackLash character. The remaining expressions are serialized below that.
Using the Backslash Character

A backslash (\) instructs QuickTest to treat the next character as a literal character, if it is otherwise a special character. The backslash (\) can also instruct QuickTest to recognize certain ordinary characters as special characters. For example, QuickTest recognizes \n as the special newline character.

For example:

w matches the character w

\w is a special character that matches any word character including underscore

For example, in QTP, while entering the URL of a website,

http://mercurytours.mercuryinteractive.com/

The period would be mistaken as an indication of a regular expression. To indicate that the period is not part of a regular expression, you would enter it as follows:

mercurytours\.mercuryinteractive\.com Note: If a backslash character is used before a character that has no special meaning, the backslash is ignored. For example, \z matches z.
Expressions & Explanation

Special characters and sequences are used in writing patterns for regular expressions. The following describes the characters and sequences that can be used\

Marks the next character as either a special character or a literal. For example, “n” matches the character “n”. “\n” matches a newline character. The sequence “\\” matches “\” and “\(” matches “(“.
^

Matches the beginning of input.
$

Matches the end of input.
*

Matches the preceding character zero or more times. For example, “zo*” matches either “z” or “zoo”.
+

Matches the preceding character one or more times. For example, “zo+” matches “zoo” but not “z”.
?

Matches the preceding character zero or one time. For example, “a?ve?” matches the “ve” in “never”.
.

Matches any single character except a newline character.
(pattern)

Matches pattern and remembers the match. The matched substring can be retrieved from the resulting Matches collection, using Item [0]…[n]. To match parentheses characters ( ), use “\(” or “\)”.
xy

Matches either x or y. For example, “zwood” matches “z” or “wood”. “(zw)oo” matches “zoo” or “wood”.
{n}

n is a nonnegative integer. Matches exactly n times. For example, “o{2}” does not match the “o” in “Bob,” but matches the first two o’s in “foooood”.
{n,}

n is a nonnegative integer. Matches at least n times. For example, “o{2,}” does not match the “o” in “Bob” and matches all the o’s in “foooood.” “o{1,}” is equivalent to “o+”. “o{0,}” is equivalent to “o*”.
{n,m}

m and n are nonnegative integers. Matches at least n and at most m times. For example, “o{1,3}” matches the first three o’s in “fooooood.” “o{0,1}” is equivalent to “o?”.
[xyz]

A character set. Matches any one of the enclosed characters. For example, “[abc]” matches the “a” in “plain”.
[^xyz]

A negative character set. Matches any character not enclosed. For example, “[^abc]” matches the “p” in “plain”.
[a-z]

A range of characters. Matches any character in the specified range. For example, “[a-z]” matches any lowercase alphabetic character in the range “a” through “z”.
[^m-z]

A negative range characters. Matches any character not in the specified range. For example, “[m-z]” matches any character not in the range “m” through “z”.
\b

Matches a word boundary, that is, the position between a word and a space. For example, “er\b” matches the “er” in “never” but not the “er” in “verb”.
\B

Matches a non-word boundary. “ea*r\B” matches the “ear” in “never early”.
\d

Matches a digit character. Equivalent to [0-9].
\D

Matches a non-digit character. Equivalent to [^0-9].
\f

Matches a form-feed character.
\n

Matches a newline character.
\r

Matches a carriage return character.
\s

Matches any white space including space, tab, form-feed, etc. Equivalent to “[ \f\n\r\t\v]“.
\S

Matches any nonwhite space character. Equivalent to “[^ \f\n\r\t\v]“.
\t

Matches a tab character.
\v

Matches a vertical tab character.
\w

Matches any word character including underscore. Equivalent to “[A-Za-z0-9_]“.
\W

Matches any non-word character. Equivalent to “[^A-Za-z0-9_]“.
\num

Matches num, where num is a positive integer. A reference back to remembered matches. For example, “(.)\1″ matches two consecutive identical characters.
\n

Matches n, where n is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, “\11″ and “11″ both match a tab character. “011″ is the equivalent of “01″ & “1″. Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.
\xn

Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, “\x41″ matches “A”. “\x041″ is equivalent to “\x04″ & “1″. Allows ASCII codes to be used in regular expressions

Use Send Key Method QTP VB

Hi All,
Some time we requre keyboard event in Automation so we can use Send key method

rem **********************************************
rem create shell object
set WshShell = CreateObject(“WScript.Shell”)
SystemUtil.Run “C:\Program Files\HP\QuickTest xcxProfessional\samples\flight\app\flight4a.exe”,”C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe”,”",”"
rem first click in the text box then use send key method
Dialog(“text:=Login”).WinEdit(“attached text:=Agent Name:”).Click
rem enter rajiv in agent name text box
WshShell.SendKeys “rajiv”
rem click Password Edit box
Dialog(“text:=Login”).WinEdit(“attached text:=Password:”).Click
rem enter check in Password text box
WshShell.SendKeys “check “
Dialog(“text:=Login”).WinButton(“text:=OK”).Click
rem press escape using send key method
WshShell.SendKeys “{ESC}”
WshShell.SendKeys “{ESC}”
rem **********************************************************
Use the SendKeys method to send keystrokes to applications that have no automation interface. Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example). To send a single keyboard character, send the character itself as the string argument. For example, to send the letter x, send the string argument “x”.
Note To send a space, send the string ” “.
You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument “abc”. The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:
  • plus sign       ”+”,
  • caret             ”^”,
  • percent sign “%”,
  • and tilde       ”~”
Send these characters by enclosing them within braces “{}”. For example, to send the plus sign, send the string argument “{+}”. Brackets “[ ]” have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning (for dynamic data exchange (DDE) for example).
  • To send bracket characters, send the string argument “{[}" for the left bracket and "{]}” for the right one.
  • To send brace characters, send the string argument “{{}” for the left brace and “{}}” for the right one.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (such as BACKSPACE and BREAK). To send these kinds of keystrokes, send the arguments shown in the following table:
KeyArgument
BACKSPACE{BACKSPACE}, {BS}, or {BKSP}
BREAK{BREAK}
CAPS LOCK{CAPSLOCK}
DEL or DELETE{DELETE} or {DEL}
DOWN ARROW{DOWN}
END{END}
ENTER{ENTER} or ~
ESC{ESC}
HELP{HELP}
HOME{HOME}
INS or INSERT{INSERT} or {INS}
LEFT ARROW{LEFT}
NUM LOCK{NUMLOCK}
PAGE DOWN{PGDN}
PAGE UP{PGUP}
PRINT SCREEN{PRTSC}
RIGHT ARROW{RIGHT}
SCROLL LOCK{SCROLLLOCK}
TAB{TAB}
UP ARROW{UP}
F1{F1}
F2{F2}
F3{F3}
F4{F4}
F5{F5}
F6{F6}
F7{F7}
F8{F8}
F9{F9}
F10{F10}
F11{F11}
F12{F12}
F13{F13}
F14{F14}
F15{F15}
F16{F16}
To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, create a compound string argument that represents the keystroke combination. You do this by preceding the regular keystroke with one or more of the following special characters:
KeySpecial Character
SHIFT+
CTRL^
ALT%
Note When used this way, these special characters are not enclosed within a set of braces.
To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:
  • e and c are pressed, send the string argument “+(ec)”.
  • e is pressed, followed by a lone c (with no SHIFT), send the string argument “+ec”.
You can use the SendKeys method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter “x” ten times, you would send the string argument “{x 10}”. Be sure to include a space between keystroke and number.
Note The only keystroke pattern you can send is the kind that is comprised of a single keystroke pressed several times. For example, you can send “x” ten times, but you cannot do the same for “Ctrl+x”.
Note You cannot send the PRINT SCREEN key {PRTSC} to an application.

Translate







Tweet