XCUIElementAttributes API

协议类,XCUIElement遵守的协议

属性

identifier

字符串类型

frame

控件的矩形区域

value

title

标题,String类型

label

标签值,String类型

elementType

控件类型

enabled

是否可见,BOOL类型

horizontalSizeClass

verticalSizeClass

实例

Swift

func testXCUIElementAttributes(){
        let app = XCUIApplication()
        //id
        let id = app.identifier
        print(id)
        //frame
        let frame = app.frame
        //value
        let value = app.value
        //title
        let title = app.title
        //label
        let label = app.label
        //elementType
        let elementType = app.elementType
        //enabled
        let enabled = app.enabled
        //horizontalSizeClass
        let horizontalSizeClass = app.horizontalSizeClass
        //verticalSizeClass

        let verticalSizeClass = app.verticalSizeClass

    }

这里写图片描述

OC

-(void)testXCUIElementAttributes{
    XCUIApplication *app = [[XCUIApplication alloc] init];
    //id
    NSString *identifier = [app identifier];
    //frame
    CGRect frame = [app frame];
    //value
    id value = [app value];
    //title
    NSString *title = [app title];
    //label
    NSString *label = [app label];
    //elementType
    XCUIElementType *elementType = [app elementType];
    //enabled
    BOOL *isEnabled = [app isEnabled];
    //horizontalSizeClass
    XCUIUserInterfaceSizeClass *horizontalSizeClass = [app horizontalSizeClass];
    //verticalSizeClass
    XCUIUserInterfaceSizeClass *verticalSizeClass = [app verticalSizeClass];

}

这里写图片描述

对比

从OC和Swift的显示的信息中可以看出来,二者的差别还是很大的,有些属性的值在两者的表现上是不同的,不知道这又作何解释呢?所以劝大家还是使用swift版本的为好。

源码

Swift

protocol XCUIElementAttributes {

    /*! The accessibility identifier. */
    var identifier: String { get }

    /*! The frame of the element in the screen coordinate space. */
    var frame: CGRect { get }

    /*! The raw value attribute of the element. Depending on the element, the actual type can vary. */
    var value: AnyObject? { get }

    /*! The title attribute of the element. */
    var title: String { get }

    /*! The label attribute of the element. */
    var label: String { get }

    /*! The type of the element. /seealso XCUIElementType. */
    var elementType: XCUIElementType { get }

    /*! Whether or not the element is enabled for user interaction. */
    var enabled: Bool { get }

    /*! The horizontal size class of the element. */
    var horizontalSizeClass: XCUIUserInterfaceSizeClass { get }

    /*! The vertical size class of the element. */
    var verticalSizeClass: XCUIUserInterfaceSizeClass { get }
}

OC


@protocol 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;

@end
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值