Thursday, December 25, 2008

Function Vs Sub:

Similiarities among them:
  1. They are public by default i.e. they are visible to all procedures in the script.
  2. They can manipulate their input arguments, if there are passed by reference.
  3. They can be recursive.
The only difference between them is unlike Sub, Function can return a value i.e. function can be used to assign a value to variable.
strValue = FnConcat(sArg1, sArg2)

Note: If you want to discard the return value from user defined function or any intrinsic functions like Abs, Sqr, etc, then use the syntax Call before them.
Call FnSetEnvironment("xp","IE")

Friday, December 19, 2008

Xploring 9.5: Changes in Object Repository

There are two significant changes in OR and they are as follows

  • Checkpoint and Output Objects in the Object Repository.
  • Exporting Local Objects to a Shared Object Repository.

Both are beneficial in terms of saving time and managing the script.
Checkpoint and Output Objects in the Object Repository: The people who are using lots of checking points and output values will definitely find this option as a savior. As they would find it hard to manage them ESP. when some important checkpoints are present inside 1000 lines of code. Now the new OR, not only stores all the checkpoints and output values and also enable the user to view/modify them. Of course, if you modify its logical name in OR, then appropriate changes would be made in code. I believe the people who shuns checkpoint, might change their mind after looking this feature.

Export and Replace Local Objects: This feature present as second option under the File menu. It performs 3 tasks in a single click. First it stores the objects in shared repository (.tsr) file, then associates that shared repository(.tsr) with the current action and finally deletion of local objects followed by replacing of objects from shared repository. Since the above tasks are mostly performed by user manually, this feature comes as a mere time-saving option.
Note: Now the user can drag and drop objects from OR.



Accessing the Runtime/Internal properties of Web Objects

Use of Object Property:

If you are working with IE, then use the Object property for accessing the internal properties and methods of Web objects. When you use the Object property on a Web object in your test or component, you actually get a reference to the DOM (Document Object Model) object. This means that every operation you can perform on the DOM object, you can also perform on the eb object using the Object property.

Some of the practical scenarios:

  • Following statement can be used to get retrieve the tabindex of any object (mostly input object)in a web application.
    intIndex =Browser("").Page("").Frame("").AnyWebObject("").Object.tabIndex
    Note: The tab index value is very useful when you need to test the Tab Ordering among the controls. It is simple and easy instead of using micTab or sendkeys approach to test the same.
  • Following statement can be used to trigger the function ‘focus’ of a specific text box,
    Browser("").Page("").Frame("").WebEdit("name:=USER").Object.focus()
    (Note:the above operation can also be achieved using FireEvent method).
  • Similiarly, for WebEdit one can get some useful information at runtime from the properties like isContentEditable, isMultiLine, ContentEditable, maxlength, etc.
  • Use Browser("").Object property to fetch some important information from properties like GoBack, LocationURL, StatusText, ToolBar, StatusBar, etc.

For more information about the Document Object Model, refer to:
http://msdn.microsoft.com/en-us/library/ms533043%28VS.85%29.aspx

http://msdn.microsoft.com/en-us/library/aa752127.aspx

Monday, December 15, 2008

Xploring 9.5: My First Look

Atlast after 10 months of wait, I finally got the opportunity to work with QTP9.5. I am very excited, as this is the first release from HP(after acquiring Ver9.2 from mercury). After gazing the tool for few minutes, I captured few things which have been added/modified in this version, and I have elaborated below.

New IDE Panes: Mere scripting in expert view will be boring to anyone in long run. So this pane has something do for us. In some critical situation (like complex keyword driven framework), the information from panes like missing resource, debug viewer, etc will enable us to solution at ease. In that way, I consider these panes are really a highlight in QTP tool. Following shows how the new panes made a difference in 9.5.

1. Resources: This is present in QTP 9.2, but it is slightly enhanced in 9.5 showing Associated Recovery Scenario and not also associated function libraries. I personally feel good about this feature, as it shows all things that make the test namely internal actions, external actions, repositories, function library and recovery scenario thus giving a complete picture in a single window.

2. Test Flow: This pane will gives you a big picture of all actions involved in a current test and also shows the control flow between those actions. It is something like high level flow chart for the under test. Technically speaking this pane traces for the "RunAction" statements and portrays their relations in a 'Tree View' manner. It is somewhat powerful as the moment user completes the "Run Action" statement panes updates its structure. I believe it could be useful if you are handling multiple actions/multiple calls among the actions.

3. Available Keywords: Through this pane, one gets a big picture on list of functions within libraries/local action and also test objects associated. It is more like an enhanced/pictorial "Test Generator" feature, where you select objects/functions rather than typing them. Apart from just showing the keywords, it enables you to use them by just drag and drop the object/function to your test, statement is automatically generated for you. Double clicking a function will not only open the hosing file in the main window, but also focus on the exact position of the function within the file which is similar to operation of right click on function call -> Go to Function Definition . It is very useful when used in keyword driven framework where many library files with lots of functions are associated.

4. Process Guidance: This something which claims to be a big addiction in 9.5 (in process perspective), which elaborates the steps needs to be followed in user-selected process. This is actually achieved using two panes namely Process Guidance Activities and Process Guidance Description. By default, it shows process like keyword-driven, Application Areas, Business Components. User can also define and add his process, so that his team members could follow the steps in building the test cases. By this way, QTP guides the user in following some custom standards.

Thursday, July 17, 2008

Setting Relative Path while calling Reusable actions

Hello Friends,
In QTP, very often we call use Reusable Actions. While calling them from main script we always use absolute path to locate it (shown in the pic like D:\QTP\ReusableActions)




















But when you use absolute path we might have some problems when you move your scripts to different location(may be different drives/machine).
However
such problems would be avoided if you use Relative path.(shown in the pics like ..\QTP\ReusableActions)


















Hope this would be useful to you.