iOS UI Automation: Adding Screen Capture Functionality to UIAElement


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.

Advertisements
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s