Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Index number of tables
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
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 ;-)
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
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.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Luth, I will try this. Thx!
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  click each web link in a page using Index or other method in QTP smeijer 13 24,685 04-29-2017, 04:53 PM
Last Post: kowshik
  Page element keep changing chong67 4 4,620 11-08-2016, 09:17 PM
Last Post: Paul Rammone
  Upgraded QTP 11.0 to UFT 11.53, Object Index Properties are varying Raghava M 0 2,180 01-28-2015, 06:02 PM
Last Post: Raghava M
  General run error. Line (18): "Loop while Browser("Index:=0").Object.Busy" AshokReddy 3 5,062 12-20-2013, 01:44 PM
Last Post: sshukla12
  Unable to select a combo item by value or index martinshort 2 3,567 08-26-2013, 07:55 PM
Last Post: sudhirzpatil

Forum Jump:


Users browsing this thread: 1 Guest(s)