Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Wednesday, March 24, 2010

Difference between Index and Location

The Definitions by QTP

Index :- Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description.

Index property values are object-specific. Therefore, if you use Index:=3 to describe a WebEdit test object, QuickTest searches for the fourth WebEdit object in the page. However, if you use Index:=3 to describe a WebElement object, QuickTest searches for the fourth Web object on the page—regardless of the type—because the WebElement object applies to all Web objects.

Location :- Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description.

Location property values are object-specific. Therefore, if you use Location:=3 to describe a WinButton test object, QuickTest searches from top to bottom, and left to right for the fourth WinButton object in the page. However, if you use Location:=3 to describe a WinObject object, QuickTest searches from top to bottom, and left to right for the fourth standard object on the page—regardless of the type—because the WinObject object applies to all standard objects.

These are confusing statements. Let me give a stand on  this.

Here is an example.

Index

In the below page image the first link which is appeared is “Web”. The index for this link will be “0” because it is the first link in the page. Like the way Images, News, and Maps will have the index 1,2 and 3.

Location

Location is the position of the object from left to right and top to bottom of the page. This means that when you add an object QTP assigns the location id based on the object position from left to right side and top to bottom.

In the below page the 0th location link is Alerts. Because in the page from left to right QTP will identify a series of links in the same column. Those are Alerts, Blog Search, …..etc. Now QTP assigns location from top to bottom like Alerts –0, Blog Search –1, Books-2…etc.

The link “web” will have the location id “13” but the index is “0”.

The definition by QTP for location says “QuickTest searches from top to bottom, and left to right “. But the actual is “from left to right and top to bottom of the page”.

I am in process of getting clarification from HP on this.

You can get the below page from this URL http://www.google.co.in/intl/en/options/

image

7 comments :

  1. Hi Sudhakar, I still did not understand clearly.. seeing the web page if you left to right , you will still see 'Google' link, and then web , images link.. then how come 'alerts; is first location. Are we talking that it will first search objects from 'Frame' and then move to object in 'Page'?? Because 'Alerts' are displayed on Frame 'More google Products' ..... kindly clarify ....Bhuvanesh Singh

    ReplyDelete
  2. Sudhakar Reddy KakunuriApril 12, 2010 at 5:18 AM

    Here I am referring only link objects not all available objects. If we consider all available objects google image is the first object for Index and Location.If we consider only links, the location for alerts is 0.

    ReplyDelete
  3. HI Sudhakar
    code to capture index values of objects in qtp?

    ReplyDelete
  4. very nice explanation. thx

    ReplyDelete
  5. Thank you very much..i was so confused with index and location..this blog helped me a lot.. :)

    ReplyDelete
  6. Hi Sudhakar,
    How to identify the index value for the ActiveX object?

    ReplyDelete