Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to get the total links on my webpage
#1
Not Solved
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
Reply
#2
Not Solved
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.
Reply
#3
Not Solved
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
Reply
#4
Not Solved
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.
Reply
#5
Not Solved
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
Reply
#6
Not Solved
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?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#7
Not Solved
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
Reply
#8
Not Solved
Hi,

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

Thanks
RG
Reply
#9
Not Solved
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Capture All text from webpage and copy it... mpatra 3 4,898 07-25-2018, 05:33 PM
Last Post: vimlesh
  Reading XML Data from a WebPage shaan.mishra87@gmail.com 1 2,028 09-28-2016, 09:16 PM
Last Post: supputuri
  Using static descriptive programming how to count no. of objects on any webpage alpha1 4 6,714 08-11-2015, 08:48 PM
Last Post: kotaramamohana
  I want to click on all the links in the webtable. These links are nothing but some co abhideshpande001 0 2,565 07-22-2015, 09:36 AM
Last Post: abhideshpande001
  Fetching total number of records inside a webtable vidya2k2 2 3,651 06-15-2015, 02:55 PM
Last Post: venkatesh9032

Forum Jump:


Users browsing this thread: 1 Guest(s)