Micro Focus QTP (UFT) Forums
Data Table and descriptive programing - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Data Table and descriptive programing (/Thread-Data-Table-and-descriptive-programing)

Pages: 1 2 3


RE: Data Table and descriptive programing - laura - 06-24-2009

Ok,
Will ask the questions 1 at a time.
1) I have a link on a web browser, the object name that is recorded takes the name of whoevr is logged in. e.g if user 5, is logged in,, the link's name in the object spy will become user 5. if i now run the script and am logged in as user 7,, the script will fail as QTP name for the object has now changed to user 7. How can I reference this object so no matter who is logged in qtp can recognise the link?


RE: Data Table and descriptive programing - sreekanth chilam - 06-24-2009

Hi Laura,

Step1: Use "childObjects" Method & retrieve all links(link Count) in home page(After Login)

Step2: Use For Loop & retrieve all links "innertext" value one by one & use INSTR method to check whether the "Welcome" value is contained in Link's innertext. continue the loop till required link is found.

Step3: Once the required link is found, then use "split" method with delimiter as " " (no need of "Right" method) & get the user name & you can use anywhere.


Try to implemet the above & it can be done easily.


RE: Data Table and descriptive programing - laura - 06-24-2009

Thanks wil try that and let you know.


RE: Data Table and descriptive programing - laura - 06-24-2009

Tried but just kept getting syntax error.. can you help me with the code pls?? my code was
Code:
Set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
Set Link = Browser("Help").Page("Help").ChildObjects(oDesc)
NumbrLinks=links.Count()
Lists(i)Selecti+1
Next.

Just got stuck here.
appreciate r help.
Thanks


RE: Data Table and descriptive programing - laura - 06-24-2009

Hi,
I have steps 1 and 2 working. For step 3 using the split function hwo do i split the innertext which is e.g Welcome User 10. to have just User 10.

Thanks


RE: Data Table and descriptive programing - sreekanth chilam - 06-25-2009

Hi ,

Lets consider the below example.

Code:
str="Welcome User 10"
x=split(str," ")              ' here x is created as an array.

find the ubound of Array x (say ubound(x)=3 i.e x(0),x(1),x(2))

x(0) will contain "Welcome"
x(1) will contain "User"
x(2) will contain "10"

Just concatenate the x(1),x(2) by using "&" operator as below
Username=x(1)&x(2)
here Username will contain "User10"

If you want a blank space to be included in username , then try as below.
Username=x(1)&" "&x(2)
here Username will contain "User 10"


You will get the "User 10"


Hope You would get it now ...Smile


RE: Data Table and descriptive programing - laura - 06-25-2009

Yes mate!! Thanks a mill.


RE: Data Table and descriptive programing - adikshit - 06-25-2009

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Link("text:="Datatable("Menuitems",dtGlobalsheet")).Click

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Link("text:= & Datatable("Menuitems",dtGlobalsheet)).Clic
k
Please note second solution is right


RE: Data Table and descriptive programing - QTPgrd - 07-01-2009

Can anybody please make this script working.........This is related to the issue discussed in this loop. This issue is with line #11

Code:
1. Browser("QTP Forums").Page("QTP Forums").Link("Login").Click
2. Browser("QTP Forums").Page("QTP Forums").WebEdit("quick_username").Set DataTable("UserName", dtGlobalSheet)
3. Browser("QTP Forums").Page("QTP Forums").WebEdit("quick_password").Set DataTable("Password", dtGlobalSheet)
4. Browser("QTP Forums").Page("QTP Forums").WebButton("Login").Click
5. Browser("QTP Forums").Page("QTP Forums_2").Link("User CP").Click
6. A = DataTable("UserName", dtGlobalSheet)
7. Msgbox (A)
8. Set oLink = Description.create
9. oLink ("name").value="&A"
10. Msgbox (A)
11. Browser("QTP Forums").Page("User Control Panel").Link(oLink).Click
12. Browser("QTP Forums").Page("QTP Forums - Profile of").Link("Log Out").Click

Any help regarding this would be greatly appreciated....

Thanks...........


RE: Data Table and descriptive programing - ritesh - 07-07-2009

Hi,

I feel u shud add few more property for 'oLink'. After #9 add a class property or html tag.
Code:
oLink("class").value="blablabla"
or
Code:
oLink("html tag").value="blablabla"

hope this works...