Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
click each web link in a page using Index or other method in QTP
#9
Solved: 11 Years, 8 Months, 1 Week ago
hi ,

In above program after each link clicked, as a effect of click on the links some time new web window will open and some time the Content of main page will change.

i need to check after clicking a link no error should be displayed in the web page


i used the below program to find whether any error occured in the web page. I called a program which will return false if any error occured in the page. then in main progrma i can write lik if error occured then just click on log off button so that it should lead to same page as it was before the occurance of error.

Here control is not going inside the statement--
If IsPageCannotBeDisplayed(oBrw,PCD_Keywords) Then

And also i am passing the argument oBrw as same all the time, how can i pass the web page name which is currently opened (it may be new Web page window or the same page where the data chanaged)

Below is the program where i changed

Bold letters are same as you mentioned in the above program

For k = 0 to LinkCount-1
objLinks(k).Click


Code:
Set oBrw = Browser("A").Page("B")
       If IsPageCannotBeDisplayed(oBrw,PCD_Keywords) Then
       Browser("A").Page("B").Frame      
        ("corner").Link("Log off").Click
       End If



Next




' Function which i am calling

Code:
Public Function IsPageCannotBeDisplayed (oBrw,PCD_Keywords)
    Dim  sUrl,sPageText,oPg

    IsPageCannotBeDisplayed = False

    If Not oBrw.Exist(0) Then

    Exit Function
    End If

    'Get the page object
    Set oPg = oBrw.Page("micclass:=Page")

    'A page might not exist when the dialog modal is present
    'in the browser
    If Not oPg.Exist(0) Then
    Exit Function
    End If


    sURL = oBrw.Page("micclass:=Page").GetROProperty("URL")

    'Special check for IE and FF URL checks
    If InStr(1,sURL,"shdoclc.dll",vbTextCompare) <> 0 Or InStr(1,sURL,"about:neterror?",vbTextCompare) <> 0 Then
        IsPageCannotBeDisplayed = True

    'IF IE then we will use HTML DOM to get the whole page text
    ElseIf InStr(1,oBrw.GetROProperty("version"),"internet explorer",vbTextCompare) Then
        sPageText = oPg.Object.documentElement.outerText
    End If

    Dim  sKeyword

    For Each sKeyword In PCD_Keywords
        'Check if our keyword exist on the page
        If InStr(1,sPageText,sKeyword,vbTextCompare) Then
            IsPageCannotBeDisplayed = True
            Exit Function
        End If
    Next
End Function

Dim  PCD_Keywords
PCD_Keywords = Array("The page cannot be displayed","Sorry page is not found","error")
Reply


Messages In This Thread
RE: click each web link in a page using Index or other method in QTP - by mss - 07-11-2009, 05:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Webtable contains cell contains two links, how to click on link srinivassure 9 54,212 07-30-2016, 03:41 PM
Last Post: Akshay
  VB Script to count number of links in a web page. Suma Parimal 4 25,759 07-01-2015, 12:59 PM
Last Post: govind
  Upgraded QTP 11.0 to UFT 11.53, Object Index Properties are varying Raghava M 0 2,300 01-28-2015, 06:02 PM
Last Post: Raghava M
  General run error. Line (18): "Loop while Browser("Index:=0").Object.Busy" AshokReddy 3 5,474 12-20-2013, 01:44 PM
Last Post: sshukla12
  Unable to select a combo item by value or index martinshort 2 3,733 08-26-2013, 07:55 PM
Last Post: sudhirzpatil

Forum Jump:


Users browsing this thread: 1 Guest(s)