Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using QTP to capture screen shot
#8
Solved: 10 Years, 9 Months ago
Capture Screenshot
1. Library file 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 )
End Sub

Just paste the following code above the script

Code:
RegisterUserFunc "Page", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Browser", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Frame", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Dialog", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "swfWindow", "CaptureScreenshot", "CaptureScreenshot"
use the below line for capturing screenshot

Code:
Browser("micclass:=Browser").Page("micclass:=Page").CaptureScreenshot micPass, "Page ScreenShot."
Reply


Messages In This Thread
Using QTP to capture screen shot - by ravi.gajul - 01-31-2012, 11:08 PM
RE: Using QTP to capture screen shot - by Ankesh - 02-01-2012, 05:11 PM
RE: Using QTP to capture screen shot - by rajpes - 02-03-2012, 08:37 AM
RE: Using QTP to capture screen shot - by Ankesh - 02-03-2012, 10:48 AM
RE: Using QTP to capture screen shot - by vinod123 - 08-28-2012, 02:52 PM
RE: Using QTP to capture screen shot - by sims - 02-09-2015, 07:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Capture screen shot for unexpected Errors. uma87 10 17,867 11-08-2014, 12:18 AM
Last Post: supputuri
  How to capture text from a tooltip using QTP sasmitakumari 2 14,671 04-03-2014, 05:59 PM
Last Post: Ankur
  qtp 11, Unable to prove the disappearance ofdynamic objects displayed on same screen. priyaang 1 2,309 03-24-2014, 12:53 AM
Last Post: supputuri
  capture screenshot using html code and view in QTP Test results Bhuvan 3 7,010 07-19-2013, 02:38 PM
Last Post: Bhuvan
  How to get uppermost java object displayed on screen using QTP shirkaan_2010 1 4,557 07-29-2011, 01:41 PM
Last Post: rajpes

Forum Jump:


Users browsing this thread: 1 Guest(s)