Micro Focus QTP (UFT) Forums
Unable to get the total links on my webpage - 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: Unable to get the total links on my webpage (/Thread-Unable-to-get-the-total-links-on-my-webpage)



Unable to get the total links on my webpage - RGummadidala - 02-10-2011

Hi All,

In the process of learning descriptive programming, I started with this small program to return the count of hyperlinks on "https://login.yahoo.com/config/login_verify2?&.src=ym"

Code:
Dim obj_Desc
Set  obj_Desc = Description.Create
obj_Desc("micclass").Value="Links"
Set Links = Browser("Yahoo! Mail: The best web-based email! ").Page("Yahoo! Mail: The best web-based email! ").ChildObjects(obj_Desc)
Msgbox "Number of Links " & Links.Count

My expectation is to get back the count of hyperlinks.

For this to run, I closed all the browsers and opened a new browser pointed to above URL. I have not made any other setup apart from writing this script in expert view and run it.

I ended up with

"The "Yahoo! Mail: The best web-based email! " object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.

Line (4):
Code:
"Set Links = Browser("Yahoo! Mail: The best web-based email! ").Page("Yahoo! Mail: The best web-based email! ").ChildObjects(obj_Desc)".


Tip: If the objects in your application have changed, the Maintenance Run Mode can
help you identify and update your steps and/or the objects in your repository.


Since I'm working on descriptive programming, I suppose I need not have the objects declared in object repository. What am I missing here ? Please advise.

Thanks
Ravi


RE: Unable to get the total links on my webpage - ksrikanth2k9 - 02-10-2011

In descriptive programming we are not bypass the object repository.So in the script you have written code for only one object.That's why QTP is unable to find the the browser properties and page properties.create separate objects for page and browser in the same way.


RE: Unable to get the total links on my webpage - govi - 02-18-2011

Check the following code

Code:
Dim obj_Desc
Set obj_Desc = Description.Create
obj_Desc("micclass").Value="Link"

Set Links = Browser("title:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").ChildObjects(obj_Desc)
Msgbox "Number of Links " & Links.Count

Make sure that the browser is opened, after QTP application is launched


RE: Unable to get the total links on my webpage - RGummadidala - 02-19-2011

Hi Govi,

I tried the above program as it is, but I ended up with the below error

General run error.

Line (6): "Set Links = Browser("title:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").ChildObjects(obj_Desc)".

I have started the browser after starting the qtp application.

As some where read, I have also used MsgBox DescribeResult(Err.Number) but it did not give me any description of the error. It says general run time error, but does not specify me the exact probleml.


RE: Unable to get the total links on my webpage - priya999 - 02-25-2011

try

Code:
set v =browser("title=.*").page("title=.*").childobjects(odesc)
msgbox v.count

try

Code:
set v =browser("title=.*").page("title=.*").childobjects(odesc)
v.count



RE: Unable to get the total links on my webpage - basanth27 - 02-25-2011

Try this first,
Code:
opagechck = Browser("title:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").Exist
Msgbox opagecheck
What does it return?


RE: Unable to get the total links on my webpage - KeepWalking - 03-03-2011

This should give you the total number of links in your page. This only works if you use IE browser.

Code:
msgbox Browser("title:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").Object.all.tags("a").Length

If the above does not work, try below.
Code:
msgbox browser("name:=.*").page("name:=.*").Object.all.tags("a").Length



RE: Unable to get the total links on my webpage - RGummadidala - 05-16-2011

Hi,

It does nothing. I got a dialog box with "ok" button and no message displayed.

Thanks
RG


RE: Unable to get the total links on my webpage - gaveyom - 09-09-2011

Hi RGummadidala,

i hope this will help u

Code:
Dim obj_Desc
Set obj_Desc = Description.Create
obj_Desc("micclass").Value="Link"

Set Links = Browser("name:=Yahoo! Mail: The best web-based email!").Page("title:=Yahoo! Mail: The best web-based email!").ChildObjects(obj_Desc)
Msgbox "Number of Links " & Links.Count

in previous post the issue with Browser("title:=yahoo") is not correct way , you have to use "name" instead of "title" for Browser("name:=yahoo"), v will use title for Page("title:=yahoo") only



or


Code:
Dim obj_Desc
Set obj_Desc = Description.Create
obj_Desc("micclass").Value="Link"

Set Links = Browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(obj_Desc)
Msgbox "Number of Links " & Links.Count

Thanks & Regards,
G@veyom