UIATarget has two screen capturing functions namely captureScreenWithName and captureRectWithName. The function captureScreenWithName allows you to capture the whole iPhone screen while the captureRectWithName allows you to capture a portion of the screen as specified in the first parameter which is of type Rect. The following code snippet gives an easier way to capture a specific UIAElement without the need to specify the Rect parameter:
UIAElement.prototype["captureRectWithName"] = function(pstrFileName)
{
if (!pstrFileName)
pstrFileName = this.name();
UIATarget.localTarget().captureRectWithName(this.rect(), pstrFileName);
};
The idea is to extend the UIAElement and encapsulate within the captureRectWithName the call to the rect() function.


