Sunday, July 29, 2012

iOS UI Automation Test -- Select image when using carema

When we doing a UI Automation Test in iPhone Simulation, and we would like to test the camera function.

At this point, the way is to store the image which we want to scan to iphone simulation photo library , and then pop up the image library when use camera simulation.


In the simulator, it said "Tap and hold with two fingers to select image", here is the code to do that

targt.tapWithOptions({x:0.27,y:0.45},{touchCount:2, tapCount:1,duration;1.5});


this code will pop up the photo library.




And here is the UIAElement Class Reference from Apple 


UIAElement Class Reference Link

Monday, July 23, 2012

iPhone UIAutomation Javascript -- Alert View Message

To write UIAutomation Javascript,  one hard part is to handle Alert view,

Here is the example to get Alert view's title and message:

Code:

UIATarget.onAlert = function onAlert(alert){
// To get alert title
var title = alert.name();
//To get alert body message
// [0]  is title
var message = alert.staticTexts()[1].name();

              //if(message == "Are you sure to logout?")
              if(title == "Logout")
                {
                 alert.buttons()["Yes"].tap();
                 return true;
                 }
                 return false;
              }

Thursday, July 19, 2012

iOS -- Device Capabbilities

Accessing Basic Device Information


UIDevice *device = [UIDevice currentDevice];
NSLog(@"System name: %@", device.systemName);
NSLog(@"Model: %@", device.model);
NSLog(@"Name: %@", device.name);


Working with Basic Orientation



 UIDeviceOrientationUnknown—The orientation is currently unknown.
 UIDeviceOrientationPortrait—The home button is down.
 UIDeviceOrientationPortraitUpsideDown—The home button is up.
 UIDeviceOrientationLandscapeLeft—The home button is to the right.
 UIDeviceOrientationLandscapeRight—The home button is to the left.
 UIDeviceOrientationFaceUp—The screen is face up.
 UIDeviceOrientationFaceDown—The screen is face down.

Wednesday, July 4, 2012

Automating User Interface Testing with Instruments


This is a very good article for iOS UI Automating test.

This is the link.


Another good article

This is the link