FBElementUtils.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <Foundation/Foundation.h>
  10. #import <WebDriverAgentLib/FBElement.h>
  11. @protocol FBXCAccessibilityElement;
  12. NS_ASSUME_NONNULL_BEGIN
  13. /*! Notification used to notify about unknown attribute name */
  14. extern NSString *const FBUnknownAttributeException;
  15. @interface FBElementUtils : NSObject
  16. /**
  17. Returns property name defined by FBElement protocol for the given WebDriver Spec property name.
  18. Check the FBElement protocol to get list of supported attributes.
  19. This method also supports shortcuts, like wdName == name, wdValue == value.
  20. In case the corresponding attribute has a getter defined then the name of the getter witll be returned instead,
  21. which makes this method compatible with KVO lookup
  22. @param name WebDriver Spec property name
  23. @return the corresponding property name
  24. @throws FBUnknownAttributeException if there is no matching attribute defined in FBElement protocol
  25. */
  26. + (NSString *)wdAttributeNameForAttributeName:(NSString *)name;
  27. /**
  28. Collects all the unique element types from an array of elements.
  29. @param elements array of elements
  30. @return set of unique element types (XCUIElementType items) or an empty set in case the input is empty
  31. */
  32. + (NSSet<NSNumber *> *)uniqueElementTypesWithElements:(NSArray<id<FBElement>> *)elements;
  33. /**
  34. Returns mapping of all possible FBElement protocol properties aliases
  35. @return dictionary of matching property aliases with their real names as values or getter method names if exist
  36. for KVO lookup
  37. */
  38. + (NSDictionary<NSString *, NSString *> *)wdAttributeNamesMapping;
  39. /**
  40. Gets the unique identifier of the particular XCAccessibilityElement instance in form of UUIDv4.
  41. @param element accessiblity element instance
  42. @return the unique element identifier or nil if it cannot be retrieved
  43. */
  44. + (nullable NSString *)uidWithAccessibilityElement:(id<FBXCAccessibilityElement>)element;
  45. /**
  46. Gets the unique identifier of the particular XCAccessibilityElement instance.
  47. @param element accessiblity element instance
  48. @return the unique element identifier or nil if it cannot be retrieved
  49. */
  50. + (unsigned long long)idWithAccessibilityElement:(id<FBXCAccessibilityElement>)element;
  51. /**
  52. Retrieves the list of required instance methods of the given protocol
  53. @param protocol target protocol reference
  54. @return set of selector names
  55. */
  56. + (NSSet<NSString *> *)selectorNamesWithProtocol:(Protocol *)protocol;
  57. @end
  58. NS_ASSUME_NONNULL_END