GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Testing Tools  >  QTP
Go To First  |  Previous Question  |  Next Question 
 QTP  |  Question 601 of 684    Print  
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



  
Total Answers and Comments: 4 Last Update: January 02, 2008     Asked by: Punitha.R 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
December 21, 2007 04:26:59   #1  
LuckyJindal Member Since: December 2007   Contribution: 1    

RE: QTP Script for runtime changing objects
You can Use Regular Expressions for this. Just go the QTP help & you will find how to use regular ecxpressions.
 
Is this answer useful? Yes | No
December 22, 2007 09:15:46   #2  
ramugogurla Member Since: January 2007   Contribution: 14    

RE: QTP Script for runtime changing objects

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


 
Is this answer useful? Yes | No
December 22, 2007 09:20:24   #3  
ramugogurla Member Since: January 2007   Contribution: 14    

RE: QTP Script for runtime changing objects
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")

 
Is this answer useful? Yes | No
January 01, 2008 17:32:58   #4  
brainwood Member Since: January 2008   Contribution: 4    

RE: QTP Script for runtime changing objects
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



 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape