2. UITest相關APIs,uitest相關apis

來源:互聯網
上載者:User

2. UITest相關APIs,uitest相關apis
1. XCUIApplication

- (void)launch;//啟動應用。如果目標應用已運行,首先終止應用,然後再次啟動應用。- (void)terminate;//關閉應用。@property (nonatomic, copy) NSArray <NSString *> *launchArguments;//數組對象,儲存啟動參數。@property (nonatomic, copy) NSDictionary <NSString *, NSString *> *launchEnvironment;//字典對象,儲存啟動環境變數
2. XCUIElement

@property (readonly) BOOL exists;
這個控制項是否存在(不管被遮擋或者不在當前螢幕內都是YES)

@property (readonly, getter = isHittable) BOOL hittable;
這個控制項是否能找到一個點可以點擊

- (XCUIElementQuery *)descendantsMatchingType \:(XCUIElementType)type;
在這個元素裡按照固定的類型尋找其所有的子項目,如:
在Table的Cell裡尋找所有的子Button

locButton = [cell descendantsMatchingType:XCUIElementTypeButton];

- (XCUIElementQuery *)childrenMatchingType \:(XCUIElementType)type;
在這個元素裡按照固定的類型尋找其所有直接的子項目(即無法尋找子項目的子項目),和上一個方法類似。

- (XCUICoordinate *)coordinateWithNormalizedOffset \:(CGVector)normalizedOffset;

在這個控制項雷根據CGVector的比例返回一個點。

XCUICoordinate *bot = [window coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)];//在Window中X比例為0.5,Y比例為0.5的一個點

@property (readonly, copy) NSString *debugDescription;

上面已經敘述過了,就是查詢的調試資訊。

- (void)typeText :(NSString *)text;

可以用這個方法對UITextField 和 UITextView等輸入,但調用之前需要確保鍵盤已經彈出,否則會出錯。

- (void)tap;
單擊這個控制項一次

- (void)doubleTap;
雙擊這個控制項一次

- (void)twoFingerTap;
雙指點擊

- (void)tapWithNumberOfTaps :(NSUInteger)numberOfTaps numberOfTouches :(NSUInteger)numberOfTouches;

可以指定點擊幾次,每次用幾個手指

- (void)pressForDuration :(NSTimeInterval)duration;
長按手勢,可以指定長按的時間。

- (void)pressForDuration :(NSTimeInterval)duration thenDragToElement :(XCUIElement *)otherElement;
先長按然後再拖動到另一個元素的位置,多用於TableView的MoveCell。

- (void)swipeUp;
- (void)swipeDown;
- (void)swipeLeft;
- (void)swipeRight;
上下左右滑動的手勢。

- (void)pinchWithScale \:(CGFloat)scale velocity :(CGFloat)velocity;
Pinch的手勢。

- (void)rotate \:(CGFloat)rotation withVelocity :(CGFloat)velocity;
旋轉的手勢。

- (void)adjustToNormalizedSliderPosition :(CGFloat)normalizedSliderPosition;
設定一個Slider當前的Value值,設定的值的範圍在[0 , 1]。

@property (readonly) CGFloat normalizedSliderPosition;
返回一個Slider當前Value的值,值的範圍在[0 , 1]。

 

- (void)adjustToPickerWheelValue :(NSString *)pickerWheelValue;
設定一個PikerView的值為多少。

3. XCUIElementAttributes
/*! The accessibility identifier. */@property (readonly) NSString *identifier;/*! The frame of the element in the screen coordinate space. */@property (readonly) CGRect frame;/*! The raw value attribute of the element. Depending on the element, the actual type can vary. */@property (readonly, nullable) id value;/*! The title attribute of the element. */@property (readonly, copy) NSString *title;/*! The label attribute of the element. */@property (readonly, copy) NSString *label;/*! The type of the element. /seealso XCUIElementType. */@property (readonly) XCUIElementType elementType;/*! Whether or not the element is enabled for user interaction. */@property (readonly, getter = isEnabled) BOOL enabled;/*! The horizontal size class of the element. */@property (readonly) XCUIUserInterfaceSizeClass horizontalSizeClass;/*! The vertical size class of the element. */@property (readonly) XCUIUserInterfaceSizeClass verticalSizeClass;/*! The value that is displayed when the element has no value. */@property (readonly, nullable) NSString *placeholderValue;/*! Whether or not the element is selected. */@property (readonly, getter = isSelected) BOOL selected;#if TARGET_OS_TV/*! Whether or not the elment has UI focus. */@property (readonly) BOOL hasFocus;
4. XCUIElementTypeQueryProvider協議
@property (readonly, copy) XCUIElementQuery *touchBars;@property (readonly, copy) XCUIElementQuery *groups;@property (readonly, copy) XCUIElementQuery *windows;@property (readonly, copy) XCUIElementQuery *sheets;@property (readonly, copy) XCUIElementQuery *drawers;@property (readonly, copy) XCUIElementQuery *alerts;@property (readonly, copy) XCUIElementQuery *dialogs;@property (readonly, copy) XCUIElementQuery *buttons;@property (readonly, copy) XCUIElementQuery *radioButtons;@property (readonly, copy) XCUIElementQuery *radioGroups;@property (readonly, copy) XCUIElementQuery *checkBoxes;@property (readonly, copy) XCUIElementQuery *disclosureTriangles;@property (readonly, copy) XCUIElementQuery *popUpButtons;@property (readonly, copy) XCUIElementQuery *comboBoxes;@property (readonly, copy) XCUIElementQuery *menuButtons;@property (readonly, copy) XCUIElementQuery *toolbarButtons;@property (readonly, copy) XCUIElementQuery *popovers;@property (readonly, copy) XCUIElementQuery *keyboards;@property (readonly, copy) XCUIElementQuery *keys;@property (readonly, copy) XCUIElementQuery *navigationBars;@property (readonly, copy) XCUIElementQuery *tabBars;@property (readonly, copy) XCUIElementQuery *tabGroups;@property (readonly, copy) XCUIElementQuery *toolbars;@property (readonly, copy) XCUIElementQuery *statusBars;@property (readonly, copy) XCUIElementQuery *tables;@property (readonly, copy) XCUIElementQuery *tableRows;@property (readonly, copy) XCUIElementQuery *tableColumns;@property (readonly, copy) XCUIElementQuery *outlines;@property (readonly, copy) XCUIElementQuery *outlineRows;@property (readonly, copy) XCUIElementQuery *browsers;@property (readonly, copy) XCUIElementQuery *collectionViews;@property (readonly, copy) XCUIElementQuery *sliders;@property (readonly, copy) XCUIElementQuery *pageIndicators;@property (readonly, copy) XCUIElementQuery *progressIndicators;@property (readonly, copy) XCUIElementQuery *activityIndicators;@property (readonly, copy) XCUIElementQuery *segmentedControls;@property (readonly, copy) XCUIElementQuery *pickers;@property (readonly, copy) XCUIElementQuery *pickerWheels;@property (readonly, copy) XCUIElementQuery *switches;@property (readonly, copy) XCUIElementQuery *toggles;@property (readonly, copy) XCUIElementQuery *links;@property (readonly, copy) XCUIElementQuery *images;@property (readonly, copy) XCUIElementQuery *icons;@property (readonly, copy) XCUIElementQuery *searchFields;@property (readonly, copy) XCUIElementQuery *scrollViews;@property (readonly, copy) XCUIElementQuery *scrollBars;@property (readonly, copy) XCUIElementQuery *staticTexts;@property (readonly, copy) XCUIElementQuery *textFields;@property (readonly, copy) XCUIElementQuery *secureTextFields;@property (readonly, copy) XCUIElementQuery *datePickers;@property (readonly, copy) XCUIElementQuery *textViews;@property (readonly, copy) XCUIElementQuery *menus;@property (readonly, copy) XCUIElementQuery *menuItems;@property (readonly, copy) XCUIElementQuery *menuBars;@property (readonly, copy) XCUIElementQuery *menuBarItems;@property (readonly, copy) XCUIElementQuery *maps;@property (readonly, copy) XCUIElementQuery *webViews;@property (readonly, copy) XCUIElementQuery *steppers;@property (readonly, copy) XCUIElementQuery *incrementArrows;@property (readonly, copy) XCUIElementQuery *decrementArrows;@property (readonly, copy) XCUIElementQuery *tabs;@property (readonly, copy) XCUIElementQuery *timelines;@property (readonly, copy) XCUIElementQuery *ratingIndicators;@property (readonly, copy) XCUIElementQuery *valueIndicators;@property (readonly, copy) XCUIElementQuery *splitGroups;@property (readonly, copy) XCUIElementQuery *splitters;@property (readonly, copy) XCUIElementQuery *relevanceIndicators;@property (readonly, copy) XCUIElementQuery *colorWells;@property (readonly, copy) XCUIElementQuery *helpTags;@property (readonly, copy) XCUIElementQuery *mattes;@property (readonly, copy) XCUIElementQuery *dockItems;@property (readonly, copy) XCUIElementQuery *rulers;@property (readonly, copy) XCUIElementQuery *rulerMarkers;@property (readonly, copy) XCUIElementQuery *grids;@property (readonly, copy) XCUIElementQuery *levelIndicators;@property (readonly, copy) XCUIElementQuery *cells;@property (readonly, copy) XCUIElementQuery *layoutAreas;@property (readonly, copy) XCUIElementQuery *layoutItems;@property (readonly, copy) XCUIElementQuery *handles;@property (readonly, copy) XCUIElementQuery *otherElements;

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.