QuickTest Pro can interface directly with the Windows OS clipboard during replay using the VBScript “Mercury.Clipboard” object built in to QTP. This object can be used to validate clipboard data if the AUT programmatically manipulates the clipboard (and your test case requires validation of this functionality).
Some of the more common methods supported in the “Mercury.Clipboard” object include:
- Clear – clear the clipboard contents
- SetText – write text to the clipboard
- GetText – retrieve text from the clipboard
Some of other methods documented in My.Computer.Clipboard object are also supported.
Below is an example of clearing, setting and retrieving text in the clipboard:
Option Explicit Dim objCB Set objCB = CreateObject("Mercury.Clipboard") objCB.Clear objCB.SetText "Data in clipboard set by QTP" MsgBox objCB.GetText Set objCB = Nothing
It is very important to note that sensitive data should not be stored in the clipboard because the content may be accessible by other users.
What other methods have you implemented to interact with the Windows clipboard?
Did you enjoy this article? Help spread the word by sharing:
Engage in the conversation and leave a comment:
About Brian MacKenzie (24 articles)
Brian has over 14 years of experience working in IT, ranging from Software Quality Assurance, Software Development, Business Management to Systems Administration, in a wide range of technologies, languages, databases, systems and software. He has experience in both software quality assurance and software development roles. Brian specializes in HP LoadRunner, HP UFT (QuickTest Pro and Service Test), Mobile Testing and Automation, HP ALM and HP Service Virtualization, as well as delivering certified instructor training in HP UFT and mentoring in Service Test and Service Virtualization.