Module: Frank::Cucumber::KeyboardHelper
- Included in:
- FrankHelper
- Defined in:
- lib/frank-cucumber/keyboard_helper.rb
Instance Method Summary collapse
-
#type_into_keyboard(text_to_type, options = {}) ⇒ Object
Ask Frank to press a sequence of keys on the iOS keyboard.
-
#type_shortcut(*args) ⇒ Object
Type a keyboard shortcut (Mac only).
Instance Method Details
#type_into_keyboard(text_to_type, options = {}) ⇒ Object
The keyboard must be fully visible on the device before calling this method.
Ask Frank to press a sequence of keys on the iOS keyboard.
The “/b” control character is interpreted as a request to press the ‘Delete’ key.
An implicit return is appended to the key sequence, unless you explicitly specify otherwise by setting the :append_return option to false.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/frank-cucumber/keyboard_helper.rb', line 29 def type_into_keyboard(text_to_type, = {}) = { :append_return => true }.merge() if( [:append_return] ) text_to_type = text_to_type+"\n" unless text_to_type.end_with?("\n") end res = frank_server.send_post( 'type_into_keyboard', :text_to_type => text_to_type ) Frank::Cucumber::Gateway.evaluate_frankly_response( res, "typing the following into the keyboard '#{text_to_type}'" ) end |
#type_shortcut(*args) ⇒ Object
Type a keyboard shortcut (Mac only)
This function takes as arguments either a single string, or an array of strings, with each string representing a different key to press. Modifier keys are represented by the strings “command”, “shift”, “option”, and “control”.
For example, to sent a keyboard shortcut to quit the app, you would call
type shortcut “command”, “q”
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/frank-cucumber/keyboard_helper.rb', line 53 def type_shortcut(*args) if args[0].kind_of?(Array) return type_shortcut(*args) else key = args.pop res = frank_server.send_post( 'type_into_keyboard', :text_to_type => key, :modifiers => args ) Frank::Cucumber::Gateway.evaluate_frankly_response(res, "typing the following shortcut into the keyboard '#{key}' with modifiers #{args}") end end |