diff --git a/.swift-version b/.swift-version index bf77d54..819e07a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 +5.0 diff --git a/.travis.yml b/.travis.yml index 2b244e8..761f5a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10 +osx_image: xcode10.2 env: global: diff --git a/AutoMate.xcodeproj/project.pbxproj b/AutoMate.xcodeproj/project.pbxproj index 056ede7..7acf976 100644 --- a/AutoMate.xcodeproj/project.pbxproj +++ b/AutoMate.xcodeproj/project.pbxproj @@ -470,26 +470,27 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1000; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "PGS Software"; TargetAttributes = { E425D55C1CED928100A7CA03 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; E4EE41C01CFD7246004F0FFE = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; }; }; }; buildConfigurationList = E425D5571CED928100A7CA03 /* Build configuration list for PBXProject "AutoMate" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = E425D5531CED928100A7CA03; productRefGroup = E425D55E1CED928100A7CA03 /* Products */; @@ -649,6 +650,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -710,6 +712,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -782,7 +785,7 @@ PRODUCT_NAME = AutoMate; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -806,7 +809,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMate"; PRODUCT_NAME = AutoMate; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -817,7 +820,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMateTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -828,7 +831,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMateTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/AutoMate.xcodeproj/xcshareddata/xcschemes/AutoMate.xcscheme b/AutoMate.xcodeproj/xcshareddata/xcschemes/AutoMate.xcscheme index c471fb7..3cfc9b9 100644 --- a/AutoMate.xcodeproj/xcshareddata/xcschemes/AutoMate.xcscheme +++ b/AutoMate.xcodeproj/xcshareddata/xcschemes/AutoMate.xcscheme @@ -1,6 +1,6 @@ [Iterator.Element] { + func unique() -> [Iterator.Element] { var buffer: [Iterator.Element] = [] var added = Set() for element in self { diff --git a/AutoMate/LaunchArgumentProtocols.swift b/AutoMate/LaunchArgumentProtocols.swift index c2bc5d9..f3fb6fa 100644 --- a/AutoMate/LaunchArgumentProtocols.swift +++ b/AutoMate/LaunchArgumentProtocols.swift @@ -30,14 +30,14 @@ public protocol LaunchArgument: LaunchOption { public extension LaunchArgument { /// Unique value to use when comparing with other launch options. - public var uniqueIdentifier: String { + var uniqueIdentifier: String { return key } /// Launch environment variables provided by this option. /// /// Launch argument does not have to provide launch environments. - public var launchEnvironments: [String: String]? { + var launchEnvironments: [String: String]? { return nil } } diff --git a/AutoMate/LaunchEnvironmentProtocols.swift b/AutoMate/LaunchEnvironmentProtocols.swift index 8fed895..200a0e0 100644 --- a/AutoMate/LaunchEnvironmentProtocols.swift +++ b/AutoMate/LaunchEnvironmentProtocols.swift @@ -43,7 +43,7 @@ public extension LaunchEnvironmentProtocol { /// Launch arguments provided by this /// /// Launch environment does not have to provide launch arguments. - public var launchArguments: [String]? { + var launchArguments: [String]? { return nil } } @@ -77,12 +77,12 @@ public protocol LaunchEnvironmentWithSingleValue: LaunchEnvironmentProtocol { public extension LaunchEnvironmentWithSingleValue { /// Unique value to use when comparing with other launch options. - public var uniqueIdentifier: String { + var uniqueIdentifier: String { return key } /// Dictionary added to `XCUIApplication` `launchEnviroment`. - public var launchEnvironments: [String: String]? { + var launchEnvironments: [String: String]? { return [key: value.value] } } @@ -103,7 +103,7 @@ public extension LaunchEnvironmentWithSingleValue where Self: CleanableLaunchEnv /// /// ```swift /// ["LAUNCH_KEY": "AM_CLEAN_DATA_FLAG,PGS_WITH_LOVE"] - public var launchEnvironments: [String: String]? { + var launchEnvironments: [String: String]? { return shouldCleanBefore ? [key: "\(type(of: self).CleanFlag),\(value.value)"] : [key: value.value] } } @@ -178,7 +178,7 @@ public extension LaunchEnvironmentWithMultipleValues where Self: CleanableLaunch /// /// ```swift /// ["CleanableArrayLaunchEnvironment": "AM_CLEAN_DATA_FLAG,PGS_WITH_LOVE,PGS_WITH_LOVE"] - public var launchEnvironments: [String: String]? { + var launchEnvironments: [String: String]? { return shouldCleanBefore ? [uniqueIdentifier: "\(type(of: self).CleanFlag),\(valuesCollection.launchEnvironment)"] : [uniqueIdentifier: valuesCollection.launchEnvironment] } } @@ -210,7 +210,7 @@ public protocol CleanableLaunchEnvironment: LaunchEnvironmentProtocol { public extension CleanableLaunchEnvironment { /// Flag which is inserted at the beginning of launch enviroment value if `shouldCleanBefore` is set to true. - public static var CleanFlag: String { + static var CleanFlag: String { return "AM_CLEAN_DATA_FLAG" } } @@ -255,12 +255,12 @@ public extension CleanableLaunchEnvironmentWithMultipleValues { // MARK: Initialization /// Calls `init(shouldCleanBefore: Bool, valuesCollection: [Value])` with before clean turned off. - public init(valuesCollection: [Value]) { + init(valuesCollection: [Value]) { self.init(shouldCleanBefore: false, valuesCollection: valuesCollection) } /// Calls `init(shouldCleanBefore: Bool, valuesCollection: [Value])` with before clean turned off. - public init(arrayLiteral elements: Value...) { + init(arrayLiteral elements: Value...) { self.init(shouldCleanBefore: false, valuesCollection: elements) } } @@ -271,7 +271,7 @@ public extension CleanableLaunchEnvironmentWithMultipleValues where Self.Value = // MARK: Initialization /// Calls `init(shouldCleanBefore: Bool, valuesCollection: [Value])` with before clean turned off. - public init(shouldCleanBefore: Bool, resources: (fileName: String, bundleName: String?)...) { + init(shouldCleanBefore: Bool, resources: (fileName: String, bundleName: String?)...) { self.init(shouldCleanBefore: shouldCleanBefore, valuesCollection: resources.map(Value.init)) } } diff --git a/AutoMate/LaunchOptionProtocol.swift b/AutoMate/LaunchOptionProtocol.swift index 42a0e31..d1068ac 100644 --- a/AutoMate/LaunchOptionProtocol.swift +++ b/AutoMate/LaunchOptionProtocol.swift @@ -29,7 +29,7 @@ public protocol LaunchOption { public extension LaunchOption { /// Unique value to use when comparing with other launch options. - public var uniqueIdentifier: String { + var uniqueIdentifier: String { return "\(type(of: self))" } } diff --git a/AutoMate/LaunchOptionsSet.swift b/AutoMate/LaunchOptionsSet.swift index 6fd9498..a0d3310 100644 --- a/AutoMate/LaunchOptionsSet.swift +++ b/AutoMate/LaunchOptionsSet.swift @@ -82,7 +82,7 @@ extension LaunchOptionsSet: SetAlgebra { - returns: Removed element (or nil if it didn't exist). */ public mutating func remove(_ member: LaunchOption) -> LaunchOption? { - guard let index = options.index(where: { member.uniqueIdentifier == $0.uniqueIdentifier }) else { return nil } + guard let index = options.firstIndex(where: { member.uniqueIdentifier == $0.uniqueIdentifier }) else { return nil } return options.remove(at: index) } @@ -148,7 +148,7 @@ extension LaunchOptionsSet { - returns: Matching elements or nil if it doesn't exists in set. */ fileprivate func contains(andReturns member: LaunchOption) -> LaunchOption? { - guard let index = options.index(where: { $0.uniqueIdentifier == member.uniqueIdentifier }) else { + guard let index = options.firstIndex(where: { $0.uniqueIdentifier == member.uniqueIdentifier }) else { return nil } return options[index] diff --git a/AutoMate/Locator.swift b/AutoMate/Locator.swift index 913d714..e22d55e 100644 --- a/AutoMate/Locator.swift +++ b/AutoMate/Locator.swift @@ -32,7 +32,7 @@ public protocol Locator { public extension Locator where Self: RawRepresentable, Self.RawValue == String { /// Element identifier. - public var identifier: String { + var identifier: String { return rawValue } } diff --git a/AutoMate/PageObjects/HealthPermissionPage.swift b/AutoMate/PageObjects/HealthPermissionPage.swift index 7f81db4..02d5ddf 100644 --- a/AutoMate/PageObjects/HealthPermissionPage.swift +++ b/AutoMate/PageObjects/HealthPermissionPage.swift @@ -55,7 +55,7 @@ public extension HealthPermissionPage { /// Locators used in the HealthKit permission view. /// /// - `healthAccess`: Navigation bar identifier. - public enum Locators: String, Locator { + enum Locators: String, Locator { /// Navigation bar identifier. case healthAccess = "Health Access" } diff --git a/AutoMate/PageObjects/ModalPage.swift b/AutoMate/PageObjects/ModalPage.swift index eb2bdb1..11163f7 100644 --- a/AutoMate/PageObjects/ModalPage.swift +++ b/AutoMate/PageObjects/ModalPage.swift @@ -45,14 +45,14 @@ public extension ModalPage { /// /// - note: /// The button with "close" as `accessibilityIdentifier` is used. - public var closeButton: XCUIElement { + var closeButton: XCUIElement { return view.buttons[Locators.closeModalButton] } // MARK: Actions /// Close modal view by tapping on `closeButton` button. #if !os(tvOS) - public func closeModalPage() { + func closeModalPage() { #if os(iOS) closeButton.tap() #elseif os(macOS) diff --git a/AutoMate/PageObjects/PushedPage.swift b/AutoMate/PageObjects/PushedPage.swift index 5511709..e437be4 100644 --- a/AutoMate/PageObjects/PushedPage.swift +++ b/AutoMate/PageObjects/PushedPage.swift @@ -45,14 +45,14 @@ public extension PushedPage { /// /// - note: /// The button with "back" as `accessibilityIdentifier` is used. - public var backButton: XCUIElement { + var backButton: XCUIElement { return view.navigationBars.buttons.firstMatch } // MARK: Actions /// Pop view by tapping on `backButton` button. #if !os(tvOS) - public func goBack() { + func goBack() { #if os(iOS) backButton.tap() #elseif os(macOS) diff --git a/AutoMate/XCTest extensions/XCTestCase+Identifiable.swift b/AutoMate/XCTest extensions/XCTestCase+Identifiable.swift index 9998d1a..c7def12 100644 --- a/AutoMate/XCTest extensions/XCTestCase+Identifiable.swift +++ b/AutoMate/XCTest extensions/XCTestCase+Identifiable.swift @@ -51,7 +51,7 @@ public extension XCTestCase { /// - timeout: Waiting time (default: 10 seconds). /// - file: Current source file. /// - line: Current source line. - public func wait(forExistanceOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { + func wait(forExistanceOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { wait(forExistanceOf: element.identifingElement, timeout: timeout, file: file, line: line) } @@ -69,7 +69,7 @@ public extension XCTestCase { /// - timeout: Waiting time (default: 10 seconds). /// - file: Current source file. /// - line: Current source line. - public func wait(forVisibilityOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { + func wait(forVisibilityOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { wait(forVisibilityOf: element.identifingElement, timeout: timeout, file: file, line: line) } } diff --git a/AutoMate/XCTest extensions/XCTestCase.swift b/AutoMate/XCTest extensions/XCTestCase.swift index cb58a80..e42fb4b 100644 --- a/AutoMate/XCTest extensions/XCTestCase.swift +++ b/AutoMate/XCTest extensions/XCTestCase.swift @@ -34,7 +34,7 @@ public extension XCTestCase { /// - timeout: Waiting time in seconds (default: 10 seconds). /// - file: Current source file. /// - line: Current source line. - public func wait(forFulfillmentOf predicate: NSPredicate, + func wait(forFulfillmentOf predicate: NSPredicate, for element: XCUIElement, withFailingMessage message: String = "Failed to fulfill predicate %@ for %@ within %.2f seconds.", timeout: TimeInterval = XCTestCase.defaultTimeOut, @@ -67,7 +67,7 @@ public extension XCTestCase { /// - timeout: Waiting time in seconds (default: 10 seconds). /// - file: Current source file. /// - line: Current source line. - public func wait(forExistanceOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { + func wait(forExistanceOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { let existancePredicate = NSPredicate(format: "exists == true") wait(forFulfillmentOf: existancePredicate, for: element, withFailingMessage: "Failed to find %2$@ within %3$.2f seconds. Predicate was: %1$@.", timeout: timeout, file: file, line: line) } @@ -86,7 +86,7 @@ public extension XCTestCase { /// - timeout: Waiting time in seconds (default: 10 seconds). /// - file: Current source file. /// - line: Current source line. - public func wait(forVisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { + func wait(forVisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { let visibilityPredicate = NSPredicate(format: "exists == true && hittable == true") wait(forFulfillmentOf: visibilityPredicate, for: element, withFailingMessage: "Failed to find %2$@ as visible within %3$.2f seconds. Predicate was: %1$@.", timeout: timeout, file: file, line: line) } @@ -105,7 +105,7 @@ public extension XCTestCase { /// - timeout: Waiting time in seconds (default: 10 seconds). /// - file: Current source file. /// - line: Current source line. - public func wait(forInvisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { + func wait(forInvisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) { let invisibilityPredicate = NSPredicate(format: "hittable == false") wait(forFulfillmentOf: invisibilityPredicate, for: element, withFailingMessage: "Failed to find %2$@ as invisible within %3$.2f seconds. Predicate was: %1$@.", timeout: timeout, file: file, line: line) } diff --git a/AutoMate/XCTest extensions/XCUIApplication.swift b/AutoMate/XCTest extensions/XCUIApplication.swift index 384f5bd..34b4f23 100644 --- a/AutoMate/XCTest extensions/XCUIApplication.swift +++ b/AutoMate/XCTest extensions/XCUIApplication.swift @@ -76,7 +76,7 @@ public extension XCUIApplication { /// and iPhone6+ as iPhone 6. /// - note: /// iPhone XS Max and XR have the same size in points, outside of UI tests you could differenciate them by scale (3x for XS Max and 2x for XR). For this reason property returns `iPhone61` for both. - public var deviceType: DeviceType { + var deviceType: DeviceType { let window = windows.element(boundBy: 0) let size = window.frame.size let portraitSize = size.height > size.width ? size : CGSize(width: size.height, height: size.width) @@ -116,7 +116,7 @@ public extension XCUIApplication { /// button.tap() /// } /// ``` - public var isRunningOnIpad: Bool { + var isRunningOnIpad: Bool { switch deviceType { case .iPad, .iPadPro105, .iPadPro12: return true @@ -137,7 +137,7 @@ public extension XCUIApplication { /// button.tap() /// } /// ``` - public var isRunningOnIphone: Bool { + var isRunningOnIphone: Bool { switch deviceType { case .iPad, .iPadPro105, .iPadPro12: return false @@ -158,7 +158,7 @@ public extension XCUIApplication { /// print("Running on simulator") /// } /// ``` - public var isRunningOnSimulator: Bool { + var isRunningOnSimulator: Bool { #if targetEnvironment(simulator) return true #else @@ -192,7 +192,7 @@ public extension XCUIApplication { /// print("Detected iPhone 6 in zoom mode") /// } /// ``` - public var actualDeviceType: DeviceType { + var actualDeviceType: DeviceType { // Determine device type by checking machineIdentifier directly. switch machineIdentifier { case "iPhone7,1", "iPhone8,2": @@ -219,7 +219,7 @@ public extension XCUIApplication { /// /// - Parameter deviceType: Type of device to check for. /// - Returns: Boolean value indicating whether current device is of the expected type. - public func isRunningOn(_ deviceType: DeviceType) -> Bool { + func isRunningOn(_ deviceType: DeviceType) -> Bool { return self.deviceType == deviceType } } diff --git a/AutoMate/XCTest extensions/XCUIElement.swift b/AutoMate/XCTest extensions/XCUIElement.swift index 07157f3..b6c3957 100644 --- a/AutoMate/XCTest extensions/XCUIElement.swift +++ b/AutoMate/XCTest extensions/XCUIElement.swift @@ -21,7 +21,7 @@ public extension XCUIElement { /// button.tap() /// XCTAssertTrue(button.isVisible) /// ``` - public var isVisible: Bool { + var isVisible: Bool { // When accessing properties of XCUIElement, XCTest works differently than in a case of actions on elements // - there is no waiting for the app to idle and to finish all animations. // This can lead to problems and test flakiness as the test will evaluate a query before e.g. view transition has been completed. @@ -39,7 +39,7 @@ public extension XCUIElement { /// /// - note: /// It will fail if `value` is not a `String` type. - public var text: String { + var text: String { guard let text = value as? String else { preconditionFailure("Value: \(String(describing: value)) is not a String") } @@ -56,7 +56,7 @@ public extension XCUIElement { /// let textField = app.textFields.element /// textField.clearTextField() /// ``` - public func clearTextField() { + func clearTextField() { // Since iOS 9.1 the keyboard identifiers are available. // On iOS 9.0 the special character `\u{8}` (backspace) is used. if #available(iOS 9.1, *) { @@ -70,9 +70,9 @@ public extension XCUIElement { } } else { var previousValueLength = 0 - while self.text.characters.count != previousValueLength { + while self.text.count != previousValueLength { // Keep removing characters until text is empty, or removing them is not allowed. - previousValueLength = self.text.characters.count + previousValueLength = self.text.count typeText("\u{8}") } } @@ -93,7 +93,7 @@ public extension XCUIElement { /// ``` /// /// - Parameter text: Text to type after clearing old value. - public func clear(andType text: String) { + func clear(andType text: String) { tap() clearTextField() typeText(text) diff --git a/AutoMate/XCTest extensions/XCUIElementQuery+Locator.swift b/AutoMate/XCTest extensions/XCUIElementQuery+Locator.swift index 0711203..0bd976e 100644 --- a/AutoMate/XCTest extensions/XCUIElementQuery+Locator.swift +++ b/AutoMate/XCTest extensions/XCUIElementQuery+Locator.swift @@ -20,7 +20,7 @@ public extension XCUIElementQuery { /// ``` /// /// - Parameter locator: `Locator` used to find element - public subscript(locator: Locator) -> XCUIElement { + subscript(locator: Locator) -> XCUIElement { return self[locator.identifier] } @@ -41,7 +41,7 @@ public extension XCUIElementQuery { /// - locator: Locator to search for. /// - comparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that label matches given locator. - public func element(withLabelMatchingLocator locator: Locator, comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withLabelMatchingLocator locator: Locator, comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { return element(withLabelMatching: locator.identifier, comparisonOperator: comparisonOperator) } @@ -64,7 +64,7 @@ public extension XCUIElementQuery { /// - label: Label of element to search for. /// - labelComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifier and label match to given locators. - public func element(withLocator locator: Locator, label: Locator, labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withLocator locator: Locator, label: Locator, labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { return element(withLocator: locator, label: label.identifier, labelComparisonOperator: labelComparisonOperator) } @@ -87,7 +87,7 @@ public extension XCUIElementQuery { /// - label: Label of element to search for. /// - labelComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifier and label match to given locator and text. - public func element(withLocator locator: Locator, label: String, labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withLocator locator: Locator, label: String, labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { return element(withIdentifier: locator.identifier, label: label, labelComparisonOperator: labelComparisonOperator) } @@ -111,7 +111,7 @@ public extension XCUIElementQuery { /// - labels: Labels of element to search for. /// - labelComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifier and label match given texts. - public func element(withLocator locator: Locator, labels: [String], labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withLocator locator: Locator, labels: [String], labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { return element(withIdentifier: locator.identifier, labels: labels, labelComparisonOperator: labelComparisonOperator) } @@ -138,7 +138,7 @@ public extension XCUIElementQuery { /// - dictionary: Dictionary of locators and labels to search for. /// - labelsComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifiers and labels match to given locators and texts. - public func element (containingLabels dictionary: [LocatorItem: String], labelsComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element (containingLabels dictionary: [LocatorItem: String], labelsComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { let dict = dictionary.reduce([:]) { $0.union([$1.key.identifier: $1.value]) } return element(containingLabels: dict, labelsComparisonOperator: labelsComparisonOperator) } @@ -166,7 +166,7 @@ public extension XCUIElementQuery { /// - dictionary: Dictionary of locators and labels to search for. /// - labelsComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifiers and labels match to given locators and texts. - public func element (containingLabels dictionary: [LocatorItem: [String]], labelsComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element (containingLabels dictionary: [LocatorItem: [String]], labelsComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { let dict = dictionary.reduce([:]) { $0.union([$1.key.identifier: $1.value]) } return element(containingLabels: dict, labelsComparisonOperator: labelsComparisonOperator) } @@ -183,7 +183,7 @@ public extension XCUIElementQuery { /// /// - Parameter locator: Object conforming to Locator. /// - Returns: `XCUIElement` that label begins with given locator. - public func element(withLabelPrefixed locator: Locator) -> XCUIElement { + func element(withLabelPrefixed locator: Locator) -> XCUIElement { return element(withLabelPrefixed: locator.identifier) } @@ -198,7 +198,7 @@ public extension XCUIElementQuery { /// /// - Parameter locator: Object conforming to Locator. /// - Returns: `XCUIElement` that label contains given locator. - public func element(withLabelContaining locator: Locator) -> XCUIElement { + func element(withLabelContaining locator: Locator) -> XCUIElement { return element(withLabelContaining: locator.identifier) } } diff --git a/AutoMate/XCTest extensions/XCUIElementQuery+Predicate.swift b/AutoMate/XCTest extensions/XCUIElementQuery+Predicate.swift index 41a7eba..ad5e434 100644 --- a/AutoMate/XCTest extensions/XCUIElementQuery+Predicate.swift +++ b/AutoMate/XCTest extensions/XCUIElementQuery+Predicate.swift @@ -33,7 +33,7 @@ public extension XCUIElementQuery { /// - labels: Labels of element to search for. /// - labelComparisonOperator: Operation to use when performing comparison. /// - Returns: An predicate which matches element which identifier and label match given texts. - public class func predicate(withIdentifier identifier: String, labels: [String], labelComparisonOperator: StringComparisonOperator = .equals) -> NSPredicate { + class func predicate(withIdentifier identifier: String, labels: [String], labelComparisonOperator: StringComparisonOperator = .equals) -> NSPredicate { let identifierPredicate = NSPredicate(format: "identifier == %@", identifier) let labelsPredicates = labels.map { NSPredicate(format: "label \(labelComparisonOperator.rawValue) %@", $0) } let labelPredicate = NSCompoundPredicate(orPredicateWithSubpredicates: labelsPredicates) diff --git a/AutoMate/XCTest extensions/XCUIElementQuery.swift b/AutoMate/XCTest extensions/XCUIElementQuery.swift index 5ce36b4..98bfeaa 100644 --- a/AutoMate/XCTest extensions/XCUIElementQuery.swift +++ b/AutoMate/XCTest extensions/XCUIElementQuery.swift @@ -91,7 +91,7 @@ public extension XCUIElementQuery { /// - text: String to search for. /// - comparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that label matches to given text. - public func element(withLabelMatching text: String, comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withLabelMatching text: String, comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { return element(matching: NSPredicate(format: "label \(comparisonOperator.rawValue) %@", text)) } @@ -114,7 +114,7 @@ public extension XCUIElementQuery { /// - texts: List of labels. /// - comparisonOperator: Operation to use when performing comparison. /// - Returns: Array of `XCUIElement` elements. - public func elements(withLabelsMatching texts: [String], comparisonOperator: StringComparisonOperator = .equals) -> [XCUIElement] { + func elements(withLabelsMatching texts: [String], comparisonOperator: StringComparisonOperator = .equals) -> [XCUIElement] { return texts .compactMap({ element(withLabelMatching: $0, comparisonOperator: comparisonOperator) }) .filter { $0.exists } @@ -139,7 +139,7 @@ public extension XCUIElementQuery { /// - label: Label of element to search for. /// - labelComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifier and label match given texts. - public func element(withIdentifier identifier: String, label: String, labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withIdentifier identifier: String, label: String, labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { let predicate = NSPredicate(format: "identifier == %@ AND label \(labelComparisonOperator.rawValue) %@", identifier, label) return element(matching: predicate) } @@ -164,7 +164,7 @@ public extension XCUIElementQuery { /// - labels: Labels of element to search for. /// - labelComparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifier and label match given texts. - public func element(withIdentifier identifier: String, labels: [String], labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(withIdentifier identifier: String, labels: [String], labelComparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { let predicate = type(of: self).predicate(withIdentifier: identifier, labels: labels, labelComparisonOperator: labelComparisonOperator) return element(matching: predicate) } @@ -192,7 +192,7 @@ public extension XCUIElementQuery { /// - dictionary: Dictionary of identifiers and labels to search for. /// - comparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifiers and labels match given texts. - public func element(containingLabels dictionary: [String: String], labelsComparisonOperator comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(containingLabels dictionary: [String: String], labelsComparisonOperator comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { let predicateString = "identifier == %@ AND label \(comparisonOperator.rawValue) %@" var query = self for (identifier, label) in dictionary { @@ -226,7 +226,7 @@ public extension XCUIElementQuery { /// - dictionary: Dictionary of identifiers and labels to search for. /// - comparisonOperator: Operation to use when performing comparison. /// - Returns: `XCUIElement` that identifiers and labels match given texts. - public func element(containingLabels dictionary: [String: [String]], labelsComparisonOperator comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { + func element(containingLabels dictionary: [String: [String]], labelsComparisonOperator comparisonOperator: StringComparisonOperator = .equals) -> XCUIElement { var query = self for (identifier, labels) in dictionary { let predicate = type(of: self).predicate(withIdentifier: identifier, labels: labels, labelComparisonOperator: comparisonOperator) @@ -250,7 +250,7 @@ public extension XCUIElementQuery { /// /// - Parameter text: String to search for. /// - Returns: `XCUIElement` that label begins with given text. - public func element(withLabelPrefixed text: String) -> XCUIElement { + func element(withLabelPrefixed text: String) -> XCUIElement { return element(withLabelMatching: text, comparisonOperator: .beginsWith) } @@ -265,7 +265,7 @@ public extension XCUIElementQuery { /// /// - Parameter text: String to search for. /// - Returns: `XCUIElement` that label contains given text. - public func element(withLabelContaining text: String) -> XCUIElement { + func element(withLabelContaining text: String) -> XCUIElement { return element(withLabelMatching: text, comparisonOperator: .contains) } @@ -280,7 +280,7 @@ public extension XCUIElementQuery { /// /// - Parameter texts: List of labels. /// - Returns: Array of `XCUIElement` elements. - public func elements(withLabelsContaining texts: [String]) -> [XCUIElement] { + func elements(withLabelsContaining texts: [String]) -> [XCUIElement] { return elements(withLabelsMatching: texts, comparisonOperator: .contains) } @@ -295,7 +295,7 @@ public extension XCUIElementQuery { /// /// - Parameter texts: List of labels. /// - Returns: Array of `XCUIElement` elements. - public func elements(withLabelsLike texts: [String]) -> [XCUIElement] { + func elements(withLabelsLike texts: [String]) -> [XCUIElement] { return elements(withLabelsMatching: texts, comparisonOperator: .like) } } diff --git a/AutoMateExample/AutoMateExample.xcodeproj/project.pbxproj b/AutoMateExample/AutoMateExample.xcodeproj/project.pbxproj index e8ff6d7..d5ea556 100644 --- a/AutoMateExample/AutoMateExample.xcodeproj/project.pbxproj +++ b/AutoMateExample/AutoMateExample.xcodeproj/project.pbxproj @@ -559,7 +559,7 @@ TargetAttributes = { 1F98919D1D409547007CD2B0 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.HealthKit = { @@ -569,7 +569,7 @@ }; 1F9891B11D409547007CD2B0 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; TestTargetID = 1F98919D1D409547007CD2B0; }; @@ -581,11 +581,12 @@ }; buildConfigurationList = 1F9891991D409547007CD2B0 /* Build configuration list for PBXProject "AutoMateExample" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, pl, + Base, ); mainGroup = 1F9891951D409547007CD2B0; productRefGroup = 1F98919F1D409547007CD2B0 /* Products */; @@ -952,7 +953,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMateExample"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -967,7 +968,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMateExample"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -979,7 +980,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = test.AutoMateExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = AutoMateExample; }; name = Debug; @@ -991,7 +992,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = test.AutoMateExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = AutoMateExample; }; name = Release; diff --git a/AutoMateExample/AutoMateExample.xcodeproj/xcshareddata/xcschemes/AutoMateExample Video.xcscheme b/AutoMateExample/AutoMateExample.xcodeproj/xcshareddata/xcschemes/AutoMateExample Video.xcscheme index 1d1bcf1..7ae0d17 100644 --- a/AutoMateExample/AutoMateExample.xcodeproj/xcshareddata/xcschemes/AutoMateExample Video.xcscheme +++ b/AutoMateExample/AutoMateExample.xcodeproj/xcshareddata/xcschemes/AutoMateExample Video.xcscheme @@ -1,6 +1,6 @@