zoukankan      html  css  js  c++  java
  • ios testing

    http://www.cnblogs.com/vowei/archive/2012/08/10/2631949.html

    Automating UI Testing   Instruments User Guide

    https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html

    Testing, Debugging, and Performance

    https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_debugging/SAppsDebugging.html

    UI Automation JavaScript Reference

    http://developer.apple.com/library/ios/#documentation/DeveloperTools/Reference/UIAutomationRef/_index.html

     Note: To fully understand this section, you should be familiar with the information in iOS Human Interface Guidelines.

    Frank: Automated Acceptance Tests for iPhone and iPad

    http://blog.thepete.net/2010/07/frank-automated-acceptance-tests-for.html

    #import "<path-to-library-folder>/TestUtilities.js"
    

      

    UIATarget.localTarget().frontMostApp();
    
    //To reach the app window, the main window of your app, you would specify
    
    UIATarget.localTarget().frontMostApp().mainWindow();
    

      

    UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0];
    
    UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[0];
    
    UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()[0].elements()["Chocolate Cake"];
    

      

    // List element hierarchy for the Recipes screen
     
    UIALogger.logStart("Logging element tree …");
    UIATarget.localTarget().logElementTree();
    UIALogger.logPass();
    

      

    // List element hierarchy for the Unit Conversion screen
     
    var target = UIATarget.localTarget();
    var appWindow = target.frontMostApp().mainWindow();
    var element = target;
     
    appWindow.tabBar().buttons()["Unit Conversion"].tap();
    UIALogger.logStart("Logging element tree …");
    element.logElementTree();
    UIALogger.logPass();
    

      

    // Switch screen (mode) based on value of variable
     
    var target = UIATarget.localTarget();
    var app = target.frontMostApp();
    var tabBar = app.mainWindow().tabBar();
     
    var destinationScreen = "Recipes";
     
    if (tabBar.selectedButton().name() != destinationScreen) {
        tabBar.buttons()[destinationScreen].tap();
    }
    

      

    Performing User Interface Gestures

    UIATarget.localTarget().frontMostApp().navigationBar().buttons()["Add"].tap();
    UIATarget.localTarget().tap({x:100, y:200});
    UIATarget.localTarget().doubleTap({x:100, y:200});
    UIATarget.localTarget().twoFingerTap({x:100, y:200});
    
    UIATarget.localTarget().pinchOpenFromToForDuration({x:20, y:200}, {x:300, y:200}, 2);
    
    UIATarget.localTarget().pinchCloseFromToForDuration({x:20, y:200}, {x:300, y:200}, 2);
    
    UIATarget.localTarget().dragFromToForDuration({x:160, y:200}, {x:160, y:400}, 1);
    
    UIATarget.localTarget().flickFromTo({x:160, y:200}, {x:160, y:400});
    
    var recipeName = "Unusually Long Name for a Recipe";
    
    UIATarget.localTarget().frontMostApp().mainWindow().textFields()[0].setValue(recipeName);
    
    
    
    var tabBar = UIATarget.localTarget().frontMostApp().mainWindow().tabBar();
    
    var selectedTabName = tabBar.selectedButton().name();
    
    if (selectedTabName != "Unit Conversion") {
    
    tabBar.buttons()["Unit Conversion"].tap();
    
    }
    
    
    UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0]
    
    .scrollToElementWithPredicate("name beginswith ‘Turtle Pie’");
    

      

    Adding Timing Flexibility with Timeout Periods

    UIATarget.localTarget().pushTimeout(2);
    
    //You then run the code to perform the action and pop the custom timeout off the stack.
    
    UIATarget.localTarget().popTimeout();
    
    UIATarget.localTarget().delay(2);
    

      

    Logging Test Results and Data

    var testName = "Module 001 Test";
    UIALogger.logStart(testName);
    //some test code
    UIALogger.logPass(testName);
    
    
    ///////////
    var testName = "Module 001 Test";
    
    UIALogger.logStart(testName);
    
    //some test code
    
    UIALogger.logMessage("Starting Module 001 branch 2, validating input.");
    
    //capture a screenshot with a specified name
    
    UIATarget.localTarget().captureScreenWithName("SS001-2_AddedIngredient");
    
    //more test code
    
    UIALogger.logPass(testName);
    

      

    Verifying Test Results

    var cell = UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0].cells()
        .firstWithPredicate("name beginswith ‘Tarte’");
    if (cell.isValid()) {
        UIALogger.logPass(testName);
    }
    else {
        UIALogger.logFail(testName);
    }
    

      

    Handling Alerts

    UIATarget.onAlert = function onAlert(alert) {
    
    var title = alert.name();
    
    UIALogger.logWarning("Alert with title '" + title + "' encountered.");
    
    // return false to use the default handler
    
    return false;
    
    }
    

      

    Handling Internally Generated Alerts

    UIATarget.onAlert = function onAlert(alert) {
    
    var title = alert.name();
    
    UIALogger.logWarning("Alert with title '" + title + "' encountered.");
    
    if (title == "The Alert We Expected") {
    
    alert.buttons()["Continue"].tap();
    
    return true; //alert handled, so bypass the default handler
    
    }
    
    // return false to use the default handler
    
    return false;
    
    }
    

      

    Detecting and Specifying Device Orientation

    var target = UIATarget.localTarget();
    
    var app = target.frontMostApp();
    
    
    //set orientation to landscape left
    
    target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPELEFT);
    
    UIALogger.logMessage("Current orientation now " + app.interfaceOrientation());
    
    
    //reset orientation to portrait
    
    target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT);
    
    UIALogger.logMessage("Current orientation now " + app.interfaceOrientation());
    

      

    Testing for Multitasking

    UIATarget.localTarget().deactivateAppForDuration(10);
    

      

  • 相关阅读:
    linux添加到普通用户sudo才干
    跳跃Java一些周期,双跳FOR周期
    Android虚拟机器学习总结Dalvik虚拟机创建进程和线程分析
    Notes系统安全日志
    android Intent.createChooser 应用选择
    创业这么难,去哪儿?
    视频和音频播放的演示最简单的例子6:OpenGL广播YUV420P(T经exture,采用Shader)
    名单(两)——基本操作单向链表(创、删、印、节点统计数)
    JS列
    第38周三
  • 原文地址:https://www.cnblogs.com/zyip/p/2867066.html
Copyright © 2011-2022 走看看