Micro Focus QTP (UFT) Forums
Changing Index number of tables - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Changing Index number of tables (/Thread-Changing-Index-number-of-tables)



Changing Index number of tables - mv8167 - 08-12-2011

I have 13 links on a page. When I select one of the links, a table opens with a set of new links. Each table that opens has all of the same attributes as the other 12 except the Index number. And, only onev table can be open at a time (opening a second table forces the first table to close)

Churently, I am setting myn table using this code:
Code:
Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type")
--- As the OR has the Index = 5)

Thus, the table where Index = 5 is always uses the 1st link's table links (even though the table is hidden).

In the OR, I tried to remove the Index from the Document Type(table) object, but I cannot.

The Index goes from 5, 7, 9, 11, ... , 29, 31.

How can I use DP (or any other method) to find the correct
"open" table?

I just tried
Code:
Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type", "Index = (Gr*2)+5)")
but no luck

In OR;
The Name of the object is Document Type
The name is ANNUAL SUMMARIES AND YEARLY TAX FORMS, but changes for each table
The text is "Document TypeDocument IDActions.ANNUAL SUMMARIES AND YEARLY TAX FORMSYETSBRGREB[Display] [Search] [Add Fav.]ASSET TRANSFER/401 NOTIFICATIONSASSETXFER2[Display] [Search] [Add Fav.]BRR CERTIFICATIONSBRR_CERTAB[Display] [Search] [Add Fav.]CLIENT CONFIRMATIONS - HISTORICALCONFIRMS2[Display] [Search] [Add Fav.]CLIENT CONFIRMATIONS - PRIOR 3 MONTHSCONFIRMS4[Display] [Search] [Add Fav.]CLIENT LETTERS AND DOCUMENTS BY ACCOUNTCLIENTDOCA[Display] [Search] [Add Fav.]COMMAND CHECK IMAGESWSTA_CAPCK[Display] [Search] [Add Fav.]CUSTOMER CHECKS BY ACCOUNT#CSDV_RPTS1[Display] [Search] [Add Fav.]STATEMENTS - HISTORICALFSTA_ACCTB[Display] [Search] [Add Fav.]STATEMENTS - PRIOR 13 MONTHSBROKERAGE7[Display] [Search] [Add Fav.] "
The Index is 5, 7, 9 ... 31

My code is:

Code:
For Gr = 1 to 13         'Loop thru GroupNames in Action1 file
            GroupName = DataTable.GetSheet("Action1").GetParameter("GroupName").ValueByRow(Gr)
            Browser("Wisdom").Page("WisdomLogin").Frame("parent").Link(GroupName).Click    

            'Find table to extract data from
            Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type", "name:=GroupName", "Index:= (Gr*2)+5)")
Next


thx

Lorena ;-)


RE: Changing Index number of tables - luth - 08-17-2011

Hi Lorena,

Maybe you could try using the mathematical formula to get any odd number:

Odd Number = n*2+1

You just have to start your sequence with n=2 (2*2+1 = 5). Then just increase your n until you reach the last link (if you have 13 links then the last n will be 15, 15*2+1 = 31)

You could assign the index you want to your object using

Code:
Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type").SetTOProperty "index", n*2+1

This way you could go increasing you index two by two, by increasing n one by one.

I hope this could help you.
Luth.


RE: Changing Index number of tables - mv8167 - 08-17-2011

Luth, I will try this. Thx!


RE: Changing Index number of tables - mv8167 - 08-24-2011

Luth,

I finally got a chance to try your solution, but I get a Run Error.

The test run cannot continue due to a syntax error.

Expected end of statement

Line (57):
Code:
"Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type").SetTOProperty "index", Gr*2+3".
This however works:

Code:
NumGr = Gr*2+3
Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type_" & NumGr)
but, I must have every Document Type_# in my OR. this I was hoping to avoid.

Any thoughts?

thx


RE: Changing Index number of tables - luth - 08-25-2011

Hi again,

Maybe you could try to make a cast of the index value, forcing it to be an integer:

Code:
Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type").SetTOProperty "index", cint(Gr*2+3)

Make sure the variable Gr is always an integer.

If this failes you could try this:

Code:
NumGr = Gr*2+3
Set TableObj = Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebTable("Document Type").SetTOProperty "index", NumGr

I don't know, but maybe the QTP is a little "picky" with the index values, and should be forced to be integers (even when you're treating it just like that). This last solution is the one I use, and it always has worked for me.

Hope this could help you.

Regards!
Luth