FBKeyboard.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. NS_ASSUME_NONNULL_BEGIN
  11. @interface FBKeyboard : NSObject
  12. /**
  13. Types a string into active element. There must be element with keyboard focus; otherwise an
  14. error is raised.
  15. This API discards any modifiers set in the current context by +performWithKeyModifiers:block: so that
  16. it strictly interprets the provided text. To input keys with modifier flags, use -typeKey:modifierFlags:.
  17. @param text that should be typed
  18. @param error If there is an error, upon return contains an NSError object that describes the problem.
  19. @return YES if the operation succeeds, otherwise NO.
  20. */
  21. + (BOOL)typeText:(NSString *)text error:(NSError **)error;
  22. /**
  23. Waits until the keyboard is visible on the screen or a timeout happens
  24. @param app that should be typed
  25. @param timeout the maximum duration in seconds to wait until the keyboard is visible. If the timeout value is equal or less than zero then immediate visibility verification is going to be performed.
  26. @param error If there is an error, upon return contains an NSError object that describes the problem.
  27. @return YES if the keyboard is visible after the timeout, otherwise NO.
  28. */
  29. + (BOOL)waitUntilVisibleForApplication:(XCUIApplication *)app timeout:(NSTimeInterval)timeout error:(NSError **)error;
  30. /**
  31. Types a string into active element. There must be element with keyboard focus; otherwise an
  32. error is raised.
  33. This API discards any modifiers set in the current context by +performWithKeyModifiers:block: so that
  34. it strictly interprets the provided text. To input keys with modifier flags, use -typeKey:modifierFlags:.
  35. @param text that should be typed
  36. @param frequency Frequency of typing (letters per sec)
  37. @param error If there is an error, upon return contains an NSError object that describes the problem.
  38. @return YES if the operation succeeds, otherwise NO.
  39. */
  40. + (BOOL)typeText:(NSString *)text frequency:(NSUInteger)frequency error:(NSError **)error;
  41. @end
  42. NS_ASSUME_NONNULL_END