QTP Script for runtime changing objects

Hi,

How i can write the script for the runtime changing objects

For Example My webtable name is "Wtable"
Its containing n number of links "120 orders" "130 orders" "100 orders".......
These orders text will dynamically changing like "120 orders" can be change as "121 orders"
In this how can i write code for click these links in this webtable

First i count the child objects in "WTable"
Its now written 3
It may be change as 4 or 5 in Run time (no prob for count its takes the value)
But i cant write the code for click these links dynamically
If i write the code Browser(B).Page(P).Link("120 orders").click (Runtime this text may change)

So i have to write this script in this childObjects count function itself.

Is it possible?

Plz help me.

Thx & Regards

Punitha

Questions by Punitha.R   answers by Punitha.R

Showing Answers 1 - 4 of 4 Answers

ramugogurla

  • Dec 22nd, 2007
 

see if it is a webtable go to stepgenerator and put mouse on corresponding link and select getcelldata(row,column) of that particular place

and returrn that value to datatable then parameterised to that link


what ever link will come over there it will click

  Was this answer useful?  Yes

ramugogurla

  • Dec 22nd, 2007
 

Browser(B).Page(P).Link("120 orders").click (Runtime this text may change)

here use getcelldata(row,column)


a=Browser(B).Page(P).getcelldata(2,3)
datatable.value("link",1)=a
Browser(B).Page(P).link("a")

  Was this answer useful?  Yes

brainwood

  • Jan 1st, 2008
 

I'd get all the link objects for the page, or object that match a certain criteria. In this case, all your order links match ".*orders", then run a loop to click each of them

For example:
 
        ' Set up an object description array for matching links
        Set arrObjectDescriptionField =  Description.Create()

        ' Set our link match criteria
        arrObjectDescriptionField("html tag").Value = "A"
        arrObjectDescriptionField("text").Value = ".*orders"
       
        ' Retrieve an array of objects from the browser that match
        ' the description criteria
        Set arrObjectsLinks = Browser("MyBrowserName").Page("MyPageName").WebTable("MyTableName").ChildObjects(arrObjectDescriptionField)
       
        ' Count the number of links found that are stored in the array
        intObjectCountTotal = arrObjectsLinks.Count

        ' Run one iteration for each link
        For  intObjectIterator = 0 to intObjectCountTotal - 1

             ' Click on the link
            arrObjectsLinks(intObjectIterator).Click


             ' Your verification code should go here, along with code to bring you back to the original web page.

             ' After you come back from the page you clicked on you will need to
             ' re-index the array of browser objects, otherwise it will cause a
             ' runtime error (Unless your links open in a new window)
            Set arrObjectsLinks = Browser("MyBrowserName").Page("MyPageName").WebTable("MyTableName").ChildObjects(arrObjectDescriptionField)
       

       Next


Hope that helps


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions