Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
capture screenshot using html code and view in QTP Test results
#1
Solved: 11 Years, 4 Months, 2 Weeks ago
Code:
errorpath = "D:\CompilationWarning.bmp"
Browser("creationtime:=0").highlight
Browser("creationtime:=0").CaptureBitmap errorpath,True
Reporter.ReportEvent micFail,"Compilation error is displayed.", "<img src=""" & errorpath &"""></img>"

This is not working.Please help me

Thanks in Advanced.

Thanks,
Bhuvan
Reply
#2
Solved: 11 Years, 4 Months, 2 Weeks ago
Please ensure to include your code between [code] tags while asking or replying to questions. I have done this for you for this time.
Reply
#3
Solved: 11 Years, 4 Months, 2 Weeks ago
you should start with following code
Code:
RegisterUserFunc "Page", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Browser", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Frame", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Dialog", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "swfWindow", "CaptureScreenshot", "CaptureScreenshot"
use the following line where you want take screenshot or snapshot
Code:
Browser("micclass:=Browser").Page("micclass:=Page").CaptureScreenshot micPass, "<h4 align = ""Center"">Page SuccessFully Displayed</h4>"
The below code is a library file. Add the library file to the script
Code:
Public Sub CaptureScreenshot( ByRef Sender, ByVal micStatus, ByVal descriptionStr )
Dim dateTimeNow, fileNameStr, divDesc, caption
Dim dicMetaDescription, qtp
dateTimeNow = DotNetFactory.CreateInstance( "System.DateTime" ).Now.ToString( "ddMMyyHHmmss" )
fileNameStr = Reporter.ReportPath & "\" & dateTimeNow & ".png"
Set qtp = CreateObject( "QuickTest.Application" )
qtp.Visible = False
Wait 0, 500
If IsObject( sender ) Then
Sender.CaptureBitmap fileNameStr, True
caption = Sender.ToString & " - Capture Bitmap"
Else
Desktop.CaptureBitmap fileNameStr, True
caption = "Desktop - Capture Bitmap"
End If
qtp.Visible = True
divDesc = "<table align='center' border='5' cellpadding='1' cellspacing='1' width='100%' title='" & fileNameStr & "' frame='hsides'>" & _
"<caption>" & caption & "</caption>" & _
"<thead><tr><th>Application Exception Description</th></tr></thead>" & _
"<tfoot><tr><td align='center'><img border='2px' src='" & fileNameStr & "' /></td></tr></tfoot>" & _
"<tbody><tr><td>" & descriptionStr & "</td></tr></tbody></table>"
Set dicMetaDescription = CreateObject( "Scripting.Dictionary" )
dicMetaDescription( "Status" ) = micStatus
dicMetaDescription( "PlainTextNodeName" ) = "ApplicationException"
dicMetaDescription( "StepHtmlInfo" ) = "<DIV align=center>" & divDesc & "</DIV>"
dicMetaDescription( "DllIconIndex" ) = 205
dicMetaDescription( "DllIconSelIndex" ) = 205
dicMetaDescription( "DllPAth" ) = EnVironment( "ProductDir" ) & "\bin\ContextManager.dll"
Call Reporter.LogEvent( "User", dicMetaDescription, Reporter.GetContext )
dicMetaDescription("User") = EnVironment ("dicMetaDescription")
dicM
End Sub
I am sure the code will work because i used it in so many projects
Reply
#4
Solved: 11 Years, 4 Months, 2 Weeks ago
[ Thanks for valuable information. I tried with above code.it's working fine. However looking as one hyper link in test results , screenshot is opned when trying to click on that hyper link ]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP - each step screenshot bitmap in to word balamurali 0 2,290 02-07-2018, 10:06 PM
Last Post: balamurali
  Using QTP to capture screen shot ravi.gajul 12 77,367 08-10-2017, 06:58 AM
Last Post: pauljo.kld@gmail.com
  QTP resets values of certain fields, while running (Code attached) niveditachan 1 3,189 02-04-2015, 03:55 PM
Last Post: anshika.agarwal
Rolleyes Snapshots - Test Results Bhadra 8 8,074 11-03-2014, 03:24 PM
Last Post: vinod123
  How to capture text from a tooltip using QTP sasmitakumari 2 15,042 04-03-2014, 05:59 PM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 1 Guest(s)