FBAlert.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. @class XCUIApplication;
  11. @class XCUIElement;
  12. NS_ASSUME_NONNULL_BEGIN
  13. /**
  14. Alert helper class that abstracts alert handling
  15. */
  16. @interface FBAlert : NSObject
  17. /**
  18. Creates alert helper for given application
  19. @param application The application that contains the alert
  20. */
  21. + (instancetype)alertWithApplication:(XCUIApplication *)application;
  22. /**
  23. Creates alert helper for given application
  24. @param element The element which represents the alert
  25. */
  26. + (instancetype)alertWithElement:(XCUIElement *)element;
  27. /**
  28. Determines whether alert is present
  29. */
  30. - (BOOL)isPresent;
  31. /**
  32. Gets the labels of the buttons visible in the alert
  33. */
  34. - (nullable NSArray *)buttonLabels;
  35. /**
  36. Returns alert's title and description separated by new lines
  37. */
  38. - (nullable NSString *)text;
  39. /**
  40. Accepts alert, if present
  41. @param error If there is an error, upon return contains an NSError object that describes the problem.
  42. @return YES if the operation succeeds, otherwise NO.
  43. */
  44. - (BOOL)acceptWithError:(NSError **)error;
  45. /**
  46. Dismisses alert, if present
  47. @param error If there is an error, upon return contains an NSError object that describes the problem.
  48. @return YES if the operation succeeds, otherwise NO.
  49. */
  50. - (BOOL)dismissWithError:(NSError **)error;
  51. /**
  52. Clicks on an alert button, if present
  53. @param label The label of the button on which to click.
  54. @param error If there is an error, upon return contains an NSError object that describes the problem.
  55. @return YES if the operation suceeds, otherwise NO.
  56. */
  57. - (BOOL)clickAlertButton:(NSString *)label error:(NSError **)error;
  58. /**
  59. XCUElement that represents alert
  60. */
  61. - (nullable XCUIElement *)alertElement;
  62. /**
  63. Types a text into an input inside the alert container, if it is present
  64. @param text the text to type
  65. @param error If there is an error, upon return contains an NSError object that describes the problem.
  66. @return YES if the operation succeeds, otherwise NO.
  67. */
  68. - (BOOL)typeText:(NSString *)text error:(NSError **)error;
  69. @end
  70. NS_ASSUME_NONNULL_END