WORKING WITH QTP

TestEveryThinG

Get Web Page label Error Message QTP

Posted by rajivkumarnandvani on May 13, 2009

REM This function get the label message text from Web page whose class ErrorMessage OR InformationMessage
REM  Input objParent := Object  Name of from which rquired the Message  like Page or Frame
REM  Output(ReturnType) := Label text  message
REM  Created:    22/Nov/2008    Rajiv Kumar Nandvani ## Changed:MM/DD/YYYY
REM  Example to call    fn_GetLabelMessageText(“objPageRMS”)

Public Function fn_GetLabelMessageText( byval objParent)

Dim objdesc , objCollection , objStyle ,nObjectCount  , sMessageText , sAllText ,i
REM create label WEB element object
set objdesc= Description.Create()
objdesc(“micclass”).value =”WebElement”
objdesc(“class”).value  =”ErrorMessage|Information|labelinfo|labelerroer”
objdesc(“innertext”).value =”.*[a-z].*”
REM create array of  web element object found in WEB page
Set objCollection = objParent.ChildObjects(objdesc)
REM count number of object
nObjectCount = objCollection.Count
For i =0 to nObjectCount -1
set objStyle  = objCollection(i).Object.CurrentStyle
If  objStyle.Color =”red” or objStyle.Color =”green” or objStyle.Color = “#367602” or objStyle.Color = “#000000”  Then
sMessageText = objCollection(i).GetROProperty(“innerText”)
End If
If sMessageText <>””  Then
sAllText = sAllText & ”  ” & sMessageText
End If
sMessageText =””
next
fn_GetLabelMessageText = sAllText
REM remove the object
Set objStyle =nothing
Set objCollection =nothing
Set objdesc =nothing

End Function
Rem **********************************************************************************************************

Advertisements

9 Responses to “Get Web Page label Error Message QTP”

  1. Hema said

    I tried the above logic for my script. It displays all object description. I want to display the objects which are currently displayed on the screen. Could you please suggest what modification i need to do ?

    set objdesc= Description.Create()
    objdesc(“micclass”).value =”WebElement”
    objdesc(“class”).value =”ncbu_errormsg”
    objdesc(“innertext”).value =”.*[a-z].*”
    objdesc(“html tag”).value =”SPAN”

    Set objCollection = Browser(“Network Collaboration”).Page(“Network Collaboration”).ChildObjects(objdesc)
    nObjectCount = objCollection.Count

    For i =0 to nObjectCount -1
    set objStyle = objCollection(i).Object.CurrentStyle
    sMessageText = objCollection(i).GetROProperty(“innerText”)
    msgbox sMessageText

    Next

  2. Hi Hema,
    First you check that when label Error message Currently displayed on Screen which property is change like visible = True or False | currentstyle.display = block or None and do compare with the that label error Messages that currentely not displayed on page
    According to that Filter out in your script during run Time.
    Like this
    set objStyle = objCollection(i).Object.CurrentStyle
    rem means if currentely visible on page or Not
    If objStyle.Display=”block” Then
    sMessageText = objCollection(i).GetROProperty(”innerText”)
    End If

    OR Either you can send me the WEBpage Complete HTML by Saving so that i can find out the Property

    Thnaks
    TestEverything

  3. Bhawna said

    i have test the site, the problem is how will show error message when its not working as is nedded to.e.g
    if i click on report it should show the report excel sheet but its not showing any pop up.If I’m recording the script till that page its like not an error for QTP.
    how do i manually insert condition.

  4. Hi bhawana,

    U can insert two check point first check point will check excel sheet and second check point will check no pop -up is coming ( false value)

  5. bhawna said

    hi rajeev,
    thanx for the solution..but actually im new at QTP…and this wrk is assigned to me…im not getting how to do that…

  6. Hi bhawna

    just go through the check point creation in QTP help document.
    that will help you 🙂
    best of luck

  7. Rick said

    Hi,

    Is there is any way to compare the pdf file with the online web-page, using VBScript or any other.

    Please reply.

  8. hi Rick
    You can go through
    http://www.advancedqtp.com/wp-content/uploads/ScriptingQTP/CH16%20-%20Accessing%20PDF.pdf

  9. Anonymous said

    Hey how to Display the error message from the Web Page… Only error Message

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: