PrettyRawRepresentable

public protocol PrettyRawRepresentable : RawRepresentable where Self.RawValue == String

MARK: - pretty RawRepresentable as a keypath string of object

NOTE: the priority level

DefineRawValue > FollowPrettyProtocolButNotDefineRawValue > NoProtocolAndNoDefine

check the result as follow case:

struct AccessibilityID {
   enum Home1: String {
       case setting = "HomeSetting1"
   }
   enum Home2: String, PrettyRawRepresentable {
       case setting
   }
   enum Home3: String, PrettyRawRepresentable {
       case setting = "HomeSetting3"
   }
}

let path1 = AccessibilityID.Home1.setting.rawValue
// "HomeSetting1"

let path2_1 = AccessibilityID.Home2.setting.rawValue
// "setting"

let path2_2 = AccessibilityID.Home2.setting.prettyRawValue
// "AccessibilityID_Home2_setting"

let path3 = AccessibilityID.Home3.setting.prettyRawValue
// "HomeSetting3"
  • prettyRawValue Default implementation

    Default Implementation

    Declaration

    Swift

    var prettyRawValue: RawValue { get }
  • element Extension method

    get the element from app’s ui hierarchy with prettyRawValue

    Declaration

    Swift

    var element: XCUIElement { get }
  • query Extension method

    query elements from prettyRawValue

    Declaration

    Swift

    var query: XCUIElementQuery { get }
  • count Extension method

    count of prettyRawValue identifier

    Declaration

    Swift

    var count: Int { get }
  • subscript(_:) Extension method

    Specify the element with the subscript

    Declaration

    Swift

    subscript(i: Int) -> XCUIElement { get }

    Parameters

    i

    index

  • queryFor(identifier:) Extension method

    get the query from app’s ui hierarchy with prettyRawValue

    Declaration

    Swift

    func queryFor(identifier: Self) -> XCUIElementQuery

    Parameters

    identifier

    rawValue to convert to ID for search

    Return Value

    query result