From 67ae66ce2cd8b325f448b04004805be6823e0fae Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Wed, 13 Sep 2023 14:39:02 -0400 Subject: [PATCH] Add UI automation property identifier constants (#100) --- .../WinAppDriver+Attributes.swift | 85 +++++++++++++++++++ Tests/WinAppDriverTests/RequestsTests.swift | 4 +- 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 Sources/WinAppDriver/WinAppDriver+Attributes.swift diff --git a/Sources/WinAppDriver/WinAppDriver+Attributes.swift b/Sources/WinAppDriver/WinAppDriver+Attributes.swift new file mode 100644 index 0000000..e78e962 --- /dev/null +++ b/Sources/WinAppDriver/WinAppDriver+Attributes.swift @@ -0,0 +1,85 @@ +extension WinAppDriver { + public enum Attributes { + // Automation Identifiers from UIAutomationCoreApi.h + public static let boundingRectangle = "BoundingRectangle" + public static let processId = "ProcessId" + public static let controlType = "ControlType" + public static let localizedControlType = "LocalizedControlType" + public static let name = "Name" + public static let acceleratorKey = "AcceleratorKey" + public static let accessKey = "AccessKey" + public static let hasKeyboardFocus = "HasKeyboardFocus" + public static let isKeyboardFocusable = "IsKeyboardFocusable" + public static let isEnabled = "IsEnabled" + public static let automationId = "AutomationId" + public static let className = "ClassName" + public static let helpText = "HelpText" + public static let clickablePoint = "ClickablePoint" + public static let culture = "Culture" + public static let isControlElement = "IsControlElement" + public static let isContentElement = "IsContentElement" + public static let labeledBy = "LabeledBy" + public static let isPassword = "IsPassword" + public static let newNativeWindowHandle = "NewNativeWindowHandle" + public static let itemType = "ItemType" + public static let isOffscreen = "IsOffscreen" + public static let orientation = "Orientation" + public static let frameworkId = "FrameworkId" + public static let isRequiredForForm = "IsRequiredForForm" + public static let itemStatus = "ItemStatus" + public static let ariaRole = "AriaRole" + public static let ariaProperties = "AriaProperties" + public static let isDataValidForForm = "IsDataValidForForm" + public static let controllerFor = "ControllerFor" + public static let describedBy = "DescribedBy" + public static let flowsTo = "FlowsTo" + public static let providerDescription = "ProviderDescription" + public static let optimizeForVisualContent = "OptimizeForVisualContent" + public static let isDockPatternAvailable = "IsDockPatternAvailable" + public static let isExpandCollapsePatternAvailable = "IsExpandCollapsePatternAvailable" + public static let isGridItemPatternAvailable = "IsGridItemPatternAvailable" + public static let isGridPatternAvailable = "IsGridPatternAvailable" + public static let isInvokePatternAvailable = "IsInvokePatternAvailable" + public static let isMultipleViewPatternAvailable = "IsMultipleViewPatternAvailable" + public static let isRangeValuePatternAvailable = "IsRangeValuePatternAvailable" + public static let isScrollPatternAvailable = "IsScrollPatternAvailable" + public static let isScrollItemPatternAvailable = "IsScrollItemPatternAvailable" + public static let isSelectionItemPatternAvailable = "IsSelectionItemPatternAvailable" + public static let isSelectionPatternAvailable = "IsSelectionPatternAvailable" + public static let isTablePatternAvailable = "IsTablePatternAvailable" + public static let isTableItemPatternAvailable = "IsTableItemPatternAvailable" + public static let isTextPatternAvailable = "IsTextPatternAvailable" + public static let isTogglePatternAvailable = "IsTogglePatternAvailable" + public static let isTransformPatternAvailable = "IsTransformPatternAvailable" + public static let isValuePatternAvailable = "IsValuePatternAvailable" + public static let isWindowPatternAvailable = "IsWindowPatternAvailable" + public static let isLegacyIAccessiblePatternAvailable = "IsLegacyIAccessiblePatternAvailable" + public static let isItemContainerPatternAvailable = "IsItemContainerPatternAvailable" + public static let isVirtualizedItemPatternAvailable = "IsVirtualizedItemPatternAvailable" + public static let isSynchronizedInputPatternAvailable = "IsSynchronizedInputPatternAvailable" + public static let isObjectModelPatternAvailable = "IsObjectModelPatternAvailable" + public static let isAnnotationPatternAvailable = "IsAnnotationPatternAvailable" + public static let isTextPattern2Available = "IsTextPattern2Available" + public static let isTextEditPatternAvailable = "IsTextEditPatternAvailable" + public static let isCustomNavigationPatternAvailable = "IsCustomNavigationPatternAvailable" + public static let isStylesPatternAvailable = "IsStylesPatternAvailable" + public static let isSpreadsheetPatternAvailable = "IsSpreadsheetPatternAvailable" + public static let isSpreadsheetItemPatternAvailable = "IsSpreadsheetItemPatternAvailable" + public static let isTransformPattern2Available = "IsTransformPattern2Available" + public static let isTextChildPatternAvailable = "IsTextChildPatternAvailable" + public static let isDragPatternAvailable = "IsDragPatternAvailable" + public static let isDropTargetPatternAvailable = "IsDropTargetPatternAvailable" + public static let isStructuredMarkupPatternAvailable = "IsStructuredMarkupPatternAvailable" + public static let isPeripheral = "IsPeripheral" + public static let positionInSet = "PositionInSet" + public static let sizeOfSet = "SizeOfSet" + public static let level = "Level" + public static let annotationTypes = "AnnotationTypes" + public static let annotationObjects = "AnnotationObjects" + public static let landmarkType = "LandmarkType" + public static let localizedLandmarkType = "LocalizedLandmarkType" + public static let fullDescription = "FullDescription" + public static let headingLevel = "HeadingLevel" + public static let isDialog = "IsDialog" + } +} \ No newline at end of file diff --git a/Tests/WinAppDriverTests/RequestsTests.swift b/Tests/WinAppDriverTests/RequestsTests.swift index a37e9da..2c1c09d 100644 --- a/Tests/WinAppDriverTests/RequestsTests.swift +++ b/Tests/WinAppDriverTests/RequestsTests.swift @@ -37,7 +37,7 @@ class RequestsTests: XCTestCase { } func testAttributes() throws { - try XCTAssertEqual(app.findWhatEditBox.getAttribute(name: "ClassName"), "Edit") + try XCTAssertEqual(app.findWhatEditBox.getAttribute(name: WinAppDriver.Attributes.className), "Edit") } func testElementClickGivesKeyboardFocus() throws { @@ -78,6 +78,6 @@ class RequestsTests: XCTestCase { } private static func hasKeyboardFocus(_ element: Element) throws -> Bool { - try XCTUnwrap(element.getAttribute(name: "HasKeyboardFocus")).lowercased() == "true" + try XCTUnwrap(element.getAttribute(name: WinAppDriver.Attributes.hasKeyboardFocus)).lowercased() == "true" } }