FBXPath.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 <XCTest/XCTest.h>
  10. #import <WebDriverAgentLib/FBElement.h>
  11. #import "FBXCElementSnapshot.h"
  12. #ifdef __clang__
  13. #pragma clang diagnostic push
  14. #pragma clang diagnostic ignored "-Wpadded"
  15. #endif
  16. #import <libxml/tree.h>
  17. #import <libxml/parser.h>
  18. #import <libxml/xpath.h>
  19. #import <libxml/xpathInternals.h>
  20. #import <libxml/encoding.h>
  21. #import <libxml/xmlwriter.h>
  22. #ifdef __clang__
  23. #pragma clang diagnostic pop
  24. #endif
  25. @class FBXMLGenerationOptions;
  26. NS_ASSUME_NONNULL_BEGIN
  27. @interface FBXPath : NSObject
  28. /**
  29. Returns an array of descendants matching given xpath query
  30. @param root the root element to execute XPath query for
  31. @param xpathQuery requested xpath query
  32. @return an array of descendants matching the given xpath query or an empty array if no matches were found
  33. @throws NSException if there is an unexpected internal error during xml parsing
  34. */
  35. + (NSArray<id<FBXCElementSnapshot>> *)matchesWithRootElement:(id<FBElement>)root
  36. forQuery:(NSString *)xpathQuery;
  37. /**
  38. Gets XML representation of XCElementSnapshot with all its descendants. This method generates the same
  39. representation, which is used for XPath search
  40. @param root the root element
  41. @param options Optional values that affect the resulting XML creation process
  42. @return valid XML document as string or nil in case of failure
  43. */
  44. + (nullable NSString *)xmlStringWithRootElement:(id<FBElement>)root
  45. options:(nullable FBXMLGenerationOptions *)options;
  46. @end
  47. NS_ASSUME_NONNULL_END