Wednesday, August 18, 2010

QTP: Tips and trix

Here i will gather several lessons that I have learned while working in QTP/QC. Lessons that I want to share but are not complicated enough to warrant their own post. I will continue to add new lessons here as I learn more about QTP/QC.

1) Sync Problems When Uploading With The QCUtil API
When uploading a resource to QC using QCResource.uploadResource the file is uploaded to QC, but it is not synced with the datatable. So if you try to fetch it using DataTable.import or .importSheet you will get a version of that might not match with the one you uploaded.
Workaround: Use QCResource.downloadResource instead of import. That will go straight for the file and you will not suffer any sync problem.

2) "This files is used by somebody else"
If your QTP breaks down while working with a checked out file you might get a message saying something like "This file is checked out by somebody else". And you will get a error message in QC if you try to check in the file, even though QC recognised it is you who checked out the file.
Fix: Open the QC Connection dialoge from QTP. Disconnect and reconnect. This might fix it.

3) Version management in QC from QTP
Check out files with:
Resource.VC.CheckOut ""
And check the back in with
Resource.VC.CheckIn "Comments"
Note: Resource should be a QCResource object

4) Asserts
You can use the Reporter object to report fail and pass in QC/QTP
Reporter.ReportEvent micFail, "name", "detailed comment, e.g. X is not equal Y"
Reporter.ReportEvent micFail, "name", "detailed comment, e.g. everything seems to be in order"

5) New Line/Page Break
Use vbCrLf to make a Page Break and Carrige Return in vbscript
Example:
msgbox "Row one." + vbCrLf + "Rwo two!"

No comments: