IOS hide keyboard

2,856 views
Skip to first unread message

James McMahon

unread,
May 3, 2013, 1:11:59 AM5/3/13
to calaba...@googlegroups.com

Is there a simple way to hide the native keyboard?

I'm completing a web form in an IOS web app using touch("webView css:'##{label}'") When I've completed the form, I would like to hide the keyboard and click submit rather than use 'done' or the keyboard 'search/go' etc. functionality.

I've used a range of queries in the console and can't seem to find the keyboard keys (looked at views like UIKBKeyplaneView, UIKeyboardCornerView etc etc), let alone the actual keyboard.

The specific key that I'm after actually has an accessibility label 'Hide keyboard' (see screen shot) but using the predefined step "Then I touch "accLabel" using Hide keyboard doesn't find it.

Error:
(::) failed steps (::)
playback failed because: query view marked:'Hide keyboard' found no views. Is accessibility enabled?
 (RuntimeError)
features/contactus_name_invalid.feature:20:in `Then I touch "Hide keyboard"'

Any help would be much appreciated!
keyboardHide.png

James McMahon

unread,
May 3, 2013, 1:33:24 AM5/3/13
to calaba...@googlegroups.com

I found it. This one is quite handy.

keyboard_enter_char("Dismiss")

Mayank Jain

unread,
May 3, 2013, 2:16:53 AM5/3/13
to calaba...@googlegroups.com
Thanks for sharing.


--
You received this message because you are subscribed to the Google Groups "calabash-ios" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calabash-ios...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Regards,
Mayank.

Krukow

unread,
May 3, 2013, 8:31:49 AM5/3/13
to calaba...@googlegroups.com
Good! For reference, docs for keyboard_enter_char (https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API
state the following possible special values:

'Dictation'
'Shift'
'Delete'
'Return'
'International'
'More'

Maksym Grebenets

unread,
May 6, 2013, 11:16:58 PM5/6/13
to calaba...@googlegroups.com
Those docs are still not complete.

Here are two more hints I found out by poking around:
To tap the button that has "," and "!" you need to use ",!" value for keyboard_enter_char.
Unexpected, right? Not "," or "!", but both of them in this particular order.
Same goes for ".?"

But I still have 1 button I have no idea how to tap using scripts.
It's the "more, symbols" button with "#+=" title, the one you see when going from letters pane to numbers pane.

Anyone knows what's the reference value for that button?

Krukow

unread,
May 7, 2013, 3:22:11 AM5/7/13
to calaba...@googlegroups.com
Thanks, I've updated the docs to cover this case.

The "#+=" is actually "Shift", a bit surprising, but it is in the same physical position.

- Karl

John Bateman

unread,
May 14, 2013, 8:08:09 PM5/14/13
to calaba...@googlegroups.com
keyboard_enter_char("Dismiss")
This seems simple enough, but when I attempted to enter it via the console (with the keyboard present), the system returned the following message:

RuntimeError: Keyboard enter failed failed because: Found no key: Dismiss
from /<path omitted>/gems/calabash-cucumber-0.9.144/lib/calabash-cucumber/tests_helpers.rb:56:in `screenshot_and_raise'
from /<path omitted>/gems/calabash-cucumber-0.9.144/lib/calabash-cucumber/keyboard_helpers.rb:32:in `keyboard_enter_char'
    from (irb):

I got the same result when running as an excuted step.

What might be different for my setup? Why doesn't this command dismiss the keyboard ?

Helpful (??) info:
rvm gemset list returns:

gemsets for ruby-1.9.3-p385 (found in /Users/apple/.rvm/gems/ruby-1.9.3-p385)
   (default)
   calabash
   frank
   global
   rails3tutorial2ndEd

Maksym Grebenets

unread,
May 14, 2013, 11:53:34 PM5/14/13
to calaba...@googlegroups.com
Just to confirm. Are you sure you're trying this on iPad device or simulator?
As I understand "Dismiss" maps to the "hide keyboard" button, which is available only on iPad, but not on iPhone.
iPhone keyboard does not have this button and normally keyboard is dismissed when you tap "return" (or whatever way it's implemented in your app).


--
You received this message because you are subscribed to a topic in the Google Groups "calabash-ios" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/calabash-ios/MmDZ8EQEMY4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to calabash-ios...@googlegroups.com.

John Bateman

unread,
May 17, 2013, 12:54:44 AM5/17/13
to calaba...@googlegroups.com
Ah, when you say simulator you mean iPad simulator not iphone simulator. I was trying it on iOS 5.2 SIMULATOR.


--
You received this message because you are subscribed to the Google Groups "calabash-ios" group.
To unsubscribe from this group and stop receiving emails from it, send an email to calabash-ios...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Sincerely,

John Bateman
415.652.8322

Maksym Grebenets

unread,
May 17, 2013, 4:30:19 AM5/17/13
to calaba...@googlegroups.com
Right, I meant iPad device and iPad simulator.
"Dismiss" does nothing for iPhone keyboard.

Shuker

unread,
Oct 28, 2014, 4:21:17 AM10/28/14
to calaba...@googlegroups.com
Try with
send_app_to_background 0.5


Reply all
Reply to author
Forward
0 new messages