Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using QTP to capture screen shot
#11
Solved: 11 Years, 3 Months, 3 Weeks ago
i was make a function for capturing screenshot and it will run properly, but my concern is to can i also pass image name and image url like dynamic. please review my code.

Class xyz


' Capture Screenshot

Function capture_bitmap(br,pg)
if browser ("title:="&br).page("title:="&pg).Exist(10) then
browser ("title:="&br).page("title:="&pg).CaptureBitmap "D:\way2sms\screenshot\login.bmp"

Reporter.Reportevent micPass,"success","data entry successful"
else
Reporter.Reportevent micfail,"fail","object identifiction unsuccessful "
End if
capture_bitmap="Screenshot Captured Successfully"
End Function


End class
Reply
#12
Solved: 11 Years, 3 Months, 3 Weeks ago
If you want see my previous post for Capturing Screenshot

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 QTP 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
#13
Solved: 11 Years, 3 Months, 3 Weeks ago
(04-15-2017, 02:05 PM)vinod123 Wrote: If you want see my previous post for Capturing Screenshot

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 QTP 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."

Hi Vinod - I have used your script to capture  as below

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

But mine is a Javawindow . so i have chnaged as below but doesnt work

 JavaWindow("micclass:=JavaWindow").JavaTable("micclass:=JavaTable").CaptureScreenshot micPass, "JavaTable ScreenShot."
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Capture screen shot for unexpected Errors. uma87 10 18,657 11-08-2014, 12:18 AM
Last Post: supputuri
  How to capture text from a tooltip using QTP sasmitakumari 2 15,012 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,454 03-24-2014, 12:53 AM
Last Post: supputuri
  capture screenshot using html code and view in QTP Test results Bhuvan 3 7,228 07-19-2013, 02:38 PM
Last Post: Bhuvan
  How to get uppermost java object displayed on screen using QTP shirkaan_2010 1 4,936 07-29-2011, 01:41 PM
Last Post: rajpes

Forum Jump:


Users browsing this thread: 3 Guest(s)