XCUIElement+FBScrolling.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <WebDriverAgentLib/XCUIElement.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. /**
  12. Defines directions in which scrolling is possible.
  13. */
  14. typedef NS_ENUM(NSUInteger, FBXCUIElementScrollDirection) {
  15. FBXCUIElementScrollDirectionUnknown,
  16. FBXCUIElementScrollDirectionVertical,
  17. FBXCUIElementScrollDirectionHorizontal,
  18. };
  19. #if !TARGET_OS_TV
  20. @interface XCUIElement (FBScrolling)
  21. /**
  22. Scrolls receiver up by one screen height
  23. @param distance Normalized <0.0 - 1.0> scroll distance distance
  24. */
  25. - (void)fb_scrollUpByNormalizedDistance:(CGFloat)distance;
  26. /**
  27. Scrolls receiver down by one screen height
  28. @param distance Normalized <0.0 - 1.0> scroll distance distance
  29. */
  30. - (void)fb_scrollDownByNormalizedDistance:(CGFloat)distance;
  31. /**
  32. Scrolls receiver left by one screen width
  33. @param distance Normalized <0.0 - 1.0> scroll distance distance
  34. */
  35. - (void)fb_scrollLeftByNormalizedDistance:(CGFloat)distance;
  36. /**
  37. Scrolls receiver right by one screen width
  38. @param distance Normalized <0.0 - 1.0> scroll distance distance
  39. */
  40. - (void)fb_scrollRightByNormalizedDistance:(CGFloat)distance;
  41. /**
  42. Scrolls parent scroll view till receiver is visible.
  43. @param error If there is an error, upon return contains an NSError object that describes the problem.
  44. @return YES if the operation succeeds, otherwise NO.
  45. */
  46. - (BOOL)fb_scrollToVisibleWithError:(NSError **)error;
  47. /**
  48. Scrolls parent scroll view till the current element is visible.
  49. This call is fast as it uses a native XCTest implementation.
  50. The element must be hittable.
  51. @param error If there is an error, upon return contains an NSError object that describes the problem.
  52. @return YES if the operation succeeds, otherwise NO.
  53. */
  54. - (BOOL)fb_nativeScrollToVisibleWithError:(NSError **)error;
  55. /**
  56. Scrolls parent scroll view till receiver is visible. Whenever element is invisible it scrolls by normalizedScrollDistance
  57. in its direction. E.g. if normalizedScrollDistance is equal to 0.5, each step will scroll by half of scroll view's size.
  58. @param normalizedScrollDistance single scroll step normalized (0.0 - 1.0) distance
  59. @param error If there is an error, upon return contains an NSError object that describes the problem.
  60. @return YES if the operation succeeds, otherwise NO.
  61. */
  62. - (BOOL)fb_scrollToVisibleWithNormalizedScrollDistance:(CGFloat)normalizedScrollDistance error:(NSError **)error;
  63. /**
  64. Scrolls parent scroll view till receiver is visible. Whenever element is invisible it scrolls by normalizedScrollDistance
  65. in its direction. E.g. if normalizedScrollDistance is equal to 0.5, each step will scroll by half of scroll view's size.
  66. @param normalizedScrollDistance single scroll step normalized (0.0 - 1.0) distance
  67. @param scrollDirection the direction in which the scroll view should be scrolled, or FBXCUIElementScrollDirectionUnknown
  68. to attempt to determine it automatically
  69. @param error If there is an error, upon return contains an NSError object that describes the problem.
  70. @return YES if the operation succeeds, otherwise NO.
  71. */
  72. - (BOOL)fb_scrollToVisibleWithNormalizedScrollDistance:(CGFloat)normalizedScrollDistance scrollDirection:(FBXCUIElementScrollDirection)scrollDirection error:(NSError **)error;
  73. @end
  74. #endif
  75. NS_ASSUME_NONNULL_END