Access iOS UIATextField that is hidden under onscreen keyboard

Hi,

I’ve a screen, on which there is onscreen keyboard enabled all the time. Behind keyboard there is UIATextField, where users enters some code and after it’s validated. Appium inspector finds that element, when I check “Show invisible”. I can also access this element, when I run app using arc command, and then execute find_element, with providing correct xpath (and send_keys(“1111”) on it). However, problem occurs when I want to send_keys to that UIATextField from test, I wrote. It works randomly, sometimes it does, sometimes it doesn’t. I put that command in wait {find_element(:xpath, "path").send_keys("1111")}. I’ve checked server log (which I run using node . command). When it runs correctly there is following stack:

info: [debug] Pushing command to appium work queue: “au.getElement(‘8’).setValueByType(‘1234’)”
info: [debug] Sending command to instruments: au.getElement(‘8’).setValueByType(‘1234’)
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: Got new command 24 from instruments: au.getElementByIndexPath(‘/0/1/39’)
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: evaluating au.getElementByIndexPath(‘/0/1/39’)
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: responding with:
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: Running system command #25: /usr/local/Cellar/node/0.12.0/bin/node /Users/radek/development/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“8”}}…
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: Got new command 25 from instruments: au.getElement(‘8’).setValueByType(‘1234’)
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: evaluating au.getElement(‘8’).setValueByType(‘1234’)
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: target.frontMostApp().keyboard().typeString(“1”)
info: [debug] [INST] 2015-03-30 07:45:23 +0000 Debug: target.frontMostApp().keyboard().typeString(“2”)
info: [debug] [INST] 2015-03-30 07:45:24 +0000 Debug: target.frontMostApp().keyboard().typeString(“3”)
info: [debug] [INST] 2015-03-30 07:45:24 +0000 Debug: target.frontMostApp().keyboard().typeString(“4”)
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:“”}
info: [debug] Responding to client with success: {“status”:0,“value”:“”,“sessionId”:“ba8c2512-b6b6-4e8f-a26a-3c141a67d162”}

when it’s not working stack is following

info: [debug] Pushing command to appium work queue: “au.getElement(‘8’).setValueByType(‘1234’)”
info: [debug] Sending command to instruments: au.getElement(‘8’).setValueByType(‘1234’)
info: [debug] [INST] 2015-03-30 07:47:04 +0000 Debug: Got new command 25 from instruments: au.getElement(‘8’).setValueByType(‘1234’)
info: [debug] [INST] 2015-03-30 07:47:04 +0000 Debug: evaluating au.getElement(‘8’).setValueByType(‘1234’)
info: [debug] [INST] 2015-03-30 07:47:04 +0000 Debug: target.frontMostApp().elements()[1].elements()[31].tap()
info: [debug] [INST] 2015-03-30 07:47:04 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-03-30 07:47:04 +0000 Debug: responding with:
info: [debug] [INST] 2015-03-30 07:47:04 +0000 Debug: Running system command #26: /usr/local/Cellar/node/0.12.0/bin/node /Users/radek/development/appium/submodules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:“”}…
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:“”}
info: [debug] Responding to client with success: {“status”:0,“value”:“”,“sessionId”:“95b6ad99-4c52-4d2d-a98a-208a26834683”}

and I got following error

Failure/Error: newcard.enter_card_details_button.click
Selenium::WebDriver::Error::UnknownError:
elementId 9 could not be tapped
# ./spec/navigation_spec.rb:31:in `block (2 levels) in <top (required)>’

newcard.enter_card_details_button.click is just next step in test scenario, that required next screen so obviously appium can’t tap that button. However, I’m surprised it does not throw an error regarding my current step, which I’m having trouble with. Do you have idea what am I doing wrong or where to look for an error?

Ok, got it working - basically put thread to sleep for couple of seconds. I thought problem is somewhere else.