Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to click all the links on page and verify respective contents
#1
Not Solved
Hi All,

I want to click all the available links on the page and verify recpective contents of te page.

For example in http://newtours.demoaut.com web application there are following links like Home, Flights, Hotels,Sign Off, Register.

When click on each link relative contents displayed . I want to verify them.

I used Descriptive programing to get the counts of No of links and name. But then how to click each link and verify the content displayed when clicked on that link.

Any Idea friends ?

Thanks

Sudhir
Reply
#2
Not Solved
Hi

please find the below example
Code:
Set oDesc = Description.Create()
oDesc("html tag").Value = "A"
Set rc = Browser().Page().ChildObjects(oDesc)
num = rc.Count()

For i=0 to num-1
   tag = rc(i).GetROProperty("innertext")
   href = rc(i).GetROProperty("href")
   Reporter.ReportEvent 0, "Links in Page", "name: " & tag & ";    url: " & href
Next

If you want to click on the link...then inside the for loop you can write
rc(i).Click
Reply
#3
Not Solved
Thanks kavitaPriya,

I used same script, but after clicking First link, it stopped and not proceed further without any error.
Also it's not clear in which order it will going to click , so how can i insert checkpoint with respect to that page ?
Reply
#4
Not Solved
Yes i thought of telling you this.
Browser properties may change when you click on the links each time... please check this and let me know.
Reply
#5
Not Solved
Hi KavitaPriya,

I tried it with following script.
Code:
Set oLinks = Description.Create
oLinks("micclass").value = "Link"
set objLinks = Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").ChildObjects(oLinks)
LinkCount = objLinks.Count
msgbox LinkCount
For i = 0 to LinkCount-1step 1
linkname=objLinks(i).getroproperty("name")
msgbox linkname,0,"Current link is"
objLinks(cint(i)).Click
next

But
I am getting following error.

The test run cannot continue due to an unrecoverable error.

General run error.
Line (9): "objLinks(cint(i)).Click". The test run cannot continue due to an unrecoverable error.
Reply
#6
Not Solved
Hi
What i meant was, the browser property may be changing after click action, its not necessary to usecInt function here it seems.
For example in ur script
Code:
set objLinks = Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").ChildObjects(oLinks)
Browser property => "Welcome: Mercury Tours" may be changing after click action. Please use the object spy to verify this after clicking on the available links.
Reply
#7
Not Solved
Hi Kavitapriya,
yes the pagename is different for diff link. Also some links have same name.I tried with Object spy but didnt find any property which will display ' page name' value of the link.

Will you pls suggest any workaround how to get page name of all available Links and click them ?
Thanks in advance.
Reply
#8
Not Solved
Hi,

Try using class property for browser and page instead of the dynamic properties.
Reply
#9
Not Solved
I think once you get the links for a page the get the url of every link using GetRoProperty and store it in an array. Now once you have the url the you navigate to that url. now for every url you can put your checks for the respective page.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  click each web link in a page using Index or other method in QTP smeijer 13 24,628 04-29-2017, 04:53 PM
Last Post: kowshik
  [UFT] [WPF] Verify if the cell contains an image robertosalemi 0 1,892 10-25-2016, 06:57 PM
Last Post: robertosalemi
Question Webtable contains cell contains two links, how to click on link srinivassure 9 53,479 07-30-2016, 03:41 PM
Last Post: Akshay
  Need to verify the drop down values based on condition santhoshmscsoftware 1 2,898 05-04-2016, 11:28 PM
Last Post: supputuri
  verify that parent properties match object currently displayed in your application. sona 0 3,127 02-21-2016, 12:00 PM
Last Post: sona

Forum Jump:


Users browsing this thread: 1 Guest(s)