On 08.03.11 17:45, Pete Hodgson wrote:
> When /^I use the keyboard to fill in the textfield marked "([^\"]*)" with
> "([^\"]*)"$/ do |text_field_mark, text_to_type|
> text_field_selector = "view marked:'#{text_field_mark}'"
> check_element_exists( text_field_selector )
> touch( text_field_selector )
> frankly_map( text_field_selector, 'setText:', text_to_type )
> frankly_map( text_field_selector, 'endEditing:', true )
> end
Ah, endEditing: is the trick :-)
Strange is that the touch doesn't do anything for me... but replacing the touch with
frankly_map 'becomeFirstResponder' does make it work. :-))
When /^I use the keyboard to fill in the textfield marked "([^\"]*)" with
"([^\"]*)"$/ do |text_field_mark, text_to_type|
text_field_selector = "view marked:'#{text_field_mark}'"
check_element_exists( text_field_selector )
# touch( text_field_selector )
frankly_map( text_field_selector, 'becomeFirstResponder' )
frankly_map( text_field_selector, 'setText:', text_to_type )
frankly_map( text_field_selector, 'endEditing:', true )
end
Thanks a lot,
Martin
# Ask Frank to press a sequence of keys on the iOS keyboard.
#
# @note The keyboard must be fully visible on the device before calling this method.
#
# 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.
#
# @example
# # press the X, -, Y, and z keys on the
# # iOS keyboard, then press return
# type_into_keyboard("X-Yz")
#
# # press the 1, 2, and 3 keys on the
# # iOS keyboard, but don't press return afterwards
# type_into_keyboard("123", :append_return => false)
#
# # press the 1, 2, and 3 keys on the
# # iOS keyboard, but don't press return afterwards
# type_into_keyboard("123", :append_return => false)
#
# # press Delete twice, then type "foo"
# type_into_keyboard("\b\bfoo")
#
def type_into_keyboard(text_to_type, options = {})
options = {
:append_return => true
}.merge(options)
if( options[: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