GeekInterview.com
Series: Subject: Topic:
Question: 145 of 779

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
Asked by: Punitha.R | Member Since Oct-2007 | Asked on: Dec 19th, 2007

View all questions by Punitha.R   View all answers by Punitha.R

Showing Answers 1 - 4 of 4 Answers
LuckyJindal

Answered On : Dec 21st, 2007

View all answers by LuckyJindal

You can Use Regular Expressions for this. Just go the QTP help & you will find how to use regular ecxpressions.

  
Login to rate this answer.
ramugogurla

Answered On : Dec 22nd, 2007

View all answers by ramugogurla

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

  
Login to rate this answer.
ramugogurla

Answered On : Dec 22nd, 2007

View all answers by ramugogurla

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")

  
Login to rate this answer.
brainwood

Answered On : Jan 1st, 2008

View all answers by brainwood

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


  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.