You are on page 1of 14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Advanced QTP Forums


Old Forums - For reference only (R/O) Skip to content
Search Search

Advanced search Board index AdvancedQTP Forums Web Q&A Change font size Print view FAQ Login

Select a weblist in a webtable


Topic locked
Search this topic Search

13 posts Page 1 of 1
Recom m end Be the first of your friends to recommend this.

Select a weblist in a webtable


www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 1/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

by Basanth Kumar April 9th, 2008, 1:33 pm Hello All, Here is a intersting scenario. I am trying to automate a piece of functionality which when spyed upon is identified as a webtable. However one of the columns of the webtable has data stored in as a weblist. I need to select the value from the weblist in sync with the value in the first column. This is best explained in the screenshot. For eg : I would need to select the value "Print" from the weblist against amoxcillin. I tried the simplest of the logic to retrieve the values from the webtable and then click on the respective column but how do i select it Please help me out. Warm Regards, B Attachments

Last edited by Anonymous on April 9th, 2008, 1:34 pm, edited 1 time in total. Basanth Kumar Active User

Posts: 71 Joined: December 3rd, 2007, 11:35 am Top

www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121

2/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Re: Select a weblist in a webtable


by Anshoo Arora April 9th, 2008, 10:02 pm Personally, I haven't tried this but this might just work: Set oWebTable = Browser("micclass:=Browser").Page("micclass:=Page").WebTable("ScriptPad")_ .Webtable("ScriptPad").WebTable("Medication&Sig").WebTable("Medication&Sig")_ .ChildItem(row,col,"WebList",0) oWebTable.Highlight oWebTable.Select "someValue"

'Please replace the values for all WebTables to match accurate descriptions. Also, replace "someValue" with the value that you want to select in the list. If you have correctly identified the WebTable, it should at least highlight itself. Best Regards, Anshoo Arora AdvancedQTP Forums Moderator http://relevantcodes.com - My Blog Anshoo Arora Advanced User

Posts: 886 Joined: November 23rd, 2007, 11:55 am Location: Atlanta, GA Website

www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121

3/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Top

Re: Select a weblist in a webtable


by Basanth Kumar April 14th, 2008, 7:25 am It worked. thanks anshoo Basanth Kumar Active User

Posts: 71 Joined: December 3rd, 2007, 11:35 am Top

Re: Select a weblist in a webtable


by khang hoang August 12th, 2008, 12:56 am Set oWebList = Browser("name:=Medications").Page("Title:=Medications").WebList("html id:=selectInput")_ .ChildItem ("selectInput",0) would that work for this scenario? please help. Attachments

khang hoang User


www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 4/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Posts: 8 Joined: February 22nd, 2008, 12:19 am Top

Re: Select a weblist in a webtable


by Anshoo Arora August 19th, 2008, 12:30 am Khang, If you refer to QTP's reference, you will see that the syntax for ChildItem is: Code: Select all
o b j e c t . C h i l d I t e m( R o w ,C o l u m n ,M i c C l a s s ,I n d e x )

You will notice that this method is for WebTables, thus, the mention of Row and Column. Code: Select all
S e to W e b L i s t=B r o w s e r ( " n a m e : = M e d i c a t i o n s " ) . P a g e ( " T i t l e : = M e d i c a t i o n s " ) . W e b L i s t ( " h t m l i d : = s e l e c t I n p u t " ) . C h i l d I t e m( " s e l e c t I n p u t " , 0 )

If we see the above statement, you can notice that no WebTable is defined. However, there is a description of the WebList. In this case, you can simply choose one of the list values:
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 5/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Code: Select all


B r o w s e r ( " n a m e : = M e d i c a t i o n s " ) . P a g e ( " t i t l e : = M e d i c a t i o n s " ) . W e b L i s t ( " h t m li d : = s e l e c t I n p u t " ) . S e l e c t" # 1 " ' o r S e to W e b L i s t=B r o w s e r ( " n a m e : = M e d i c a t i o n s " ) . P a g e ( " t i t l e : = M e d i c a t i o n s " ) . W e b L i s t ( " h t m li d : = s e l e c t I n p u t " ) o W e b L i s t . S e l e c t" # 1 "

Best Regards, Anshoo Arora AdvancedQTP Forums Moderator http://relevantcodes.com - My Blog Anshoo Arora Advanced User

Posts: 886 Joined: November 23rd, 2007, 11:55 am Location: Atlanta, GA Website

Top

Re: Select a weblist in a webtable


by Manoj Patra August 19th, 2008, 8:29 pm Hi Anshoo,
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 6/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Can you solve my problem? I have a web table in which there are link objects in a column. Among those link there are very few link which has Image object adjacent to it. The link and the image object is withing the same cell. I need to click on that link only which has got the image adjacent to it. I tried with childItem but is not working. Please suggest me some alternatives for this Thanks Manoj Patra Active User

Posts: 71 Joined: June 12th, 2008, 4:53 pm Top

Re: Select a weblist in a webtable


by Anshoo Arora August 19th, 2008, 11:57 pm Hi Manoj, I think there are two ways you can do this:

1. object .ChildItemCount(row, col, micclass) (This would return the number of objects with your specified class in a given WebTable cell)

2. This is a little more complex, and will require a bit of work from your side. But, you can retrieve the object.innerhtml/outerhtml from your WebTable and find the "tag" that you are looking for. If you find within the HTML code a tag mention of an Image, that's the cell where you would find the link that you need to click.

I hope this helps a little.


www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 7/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Last edited by Anonymous on August 20th, 2008, 12:00 pm, edited 1 time in total. Best Regards, Anshoo Arora AdvancedQTP Forums Moderator http://relevantcodes.com - My Blog Anshoo Arora Advanced User

Posts: 886 Joined: November 23rd, 2007, 11:55 am Location: Atlanta, GA Website

Top

Re: Select a weblist in a webtable


by Manoj Patra August 20th, 2008, 3:52 pm Hi Anshoo, The Solution#1 given by you worked for me. I haven't tried with Solution#2 Yet but it can also be used I suppose. Thank you very much for your help. Manoj Manoj Patra Active User
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 8/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Posts: 71 Joined: June 12th, 2008, 4:53 pm Top

Re: Select a weblist in a webtable


by cherry krm August 21st, 2008, 9:19 pm I am not sure if this is relevant question to this post but my question follows: Inside innerhtml,TR has BackgroundColor value.How can I get the bgcolor of a webelement inside "WEBTABLE" ? I need to check each row in a webtable to verify what all rows are selected in a webtable.i.e How do I verify which webelement(row) in a webtable is selected ? I tried following code but didnt work : iRow = Browser("").Page("").WebTable("").GetRowProperty("rows") For i = 1 to iRow Set browsObj = Browser("").Page("").WebTable("").ChildItem(i,1,"WebElement",1) Set getColor = browsObj.Object.bgcolor If getColor = "#eeff44" Then msgbox "Selected row" Else msgbox "Row is not selected" Next Iam not sure if above code is valid but trying to get some help on this issue. Thanks Cherry cherry krm
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 9/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

User

Posts: 11 Joined: April 22nd, 2008, 6:53 pm Top

Re: Select a weblist in a webtable


by Anshoo Arora August 22nd, 2008, 1:21 am You can try the following: Code: Select all
i R o w s=B r o w s e r ( " " ) . P a g e ( " " ) . W e b T a b l e ( " " ) . G e t R o w P r o p e r t y ( " r o w s " ) F o ri=0t oi R o w s-1 s t r C o l o r=B r o w s e r ( " " ) . P a g e ( " " ) . W e b T a b l e ( " " ) . O b j e c t . R o w s ( i ) . C e l l s ( 0 ) . c u r r e n t S t y l e . b a c k g r o u n d C o l o r I fs t r C o l o r=" # e e f f 4 4 "T h e n M s g B o x" S e l e c t e dR o w " E l s e M s g B o x" R o wi sn o ts e l e c t e d " E n dI f N e x t

Best Regards, Anshoo Arora AdvancedQTP Forums Moderator http://relevantcodes.com - My Blog Anshoo Arora
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 10/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Advanced User

Posts: 886 Joined: November 23rd, 2007, 11:55 am Location: Atlanta, GA Website

Top

Re: Select a weblist in a webtable


by cherry krm August 22nd, 2008, 4:25 pm Hi Anshoo , Thank you so much for the code and it works.Now I know where I was misleading.Thank you so much again for taking time and sending the code. Thanks Cherry cherry krm User

Posts: 11 Joined: April 22nd, 2008, 6:53 pm Top

Re: Select a weblist in a webtable


www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 11/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

by cherry krm August 22nd, 2008, 4:46 pm Hi Anshoo, Ok now this code doesnt work when I have one single column with more than 2 rows in webtable. It gives "selected" color code for unselected rows too. I am trying to tweak the code to verify,will submit code if successful. Thanks Cherry cherry krm User

Posts: 11 Joined: April 22nd, 2008, 6:53 pm Top

Re: Select a weblist in a webtable


by Anshoo Arora August 22nd, 2008, 9:03 pm You just need to write another statement to retrieve the number of columns: Code: Select all
i R o w s=B r o w s e r ( " " ) . P a g e ( " " ) . W e b T a b l e ( " " ) . G e t R o w P r o p e r t y ( " r o w s " ) i C o l s=B r o w s e r ( " " ) . P a g e ( " " ) . W e b T a b l e ( " " ) . G e t R o w P r o p e r t y ( " c o l s " ) F o ri=0t oi R o w s-1 F o rn=0t oi C o l s-1 s t r C o l o r= B r o w s e r ( " " ) . P a g e ( " " ) . W e b T a b l e ( " " ) . O b j e c t . R o w s ( i ) . C e l l s ( n ) . c u r r e n t S t y l e . b a c k g r o u n d C o l o r I fs t r C o l o r=" # e e f f 4 4 "T h e n
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 12/14

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

M s g B o x" S e l e c t e dR o w " E l s e M s g B o x" R o wi sn o ts e l e c t e d " E n dI f N e x t N e x t

Best Regards, Anshoo Arora AdvancedQTP Forums Moderator http://relevantcodes.com - My Blog Anshoo Arora Advanced User

Posts: 886 Joined: November 23rd, 2007, 11:55 am Location: Atlanta, GA Website

Top Display posts from previous: All posts Topic locked 13 posts Page 1 of 1 Return to Web Q&A
www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121 13/14

Sort by Post time

Ascending

Go

1/14/14

Advanced QTP Forums View topic - Select a weblist in a webtable

Jump to:

Web Q&A

Go

Who is online
Users browsing this forum: Bing [Bot] and 1 guest Board index The team Delete all board cookies All times are UTC Powered by phpBB Forum Software phpBB Group

www.advancedqtp.com/old_forums/viewtopic.php?f=8&t=1121

14/14

You might also like