Not able to enter complete text in text field in IOS

Hi,

I am testing IOS browser app by automation testing using python appium .

I am facing problem in entering text in a text field where I have to enter expiry date in debit card payment method. For example, I want to enter “02/23” in expiry date text box, what happens when manually done is, when i write “02” after that automatically slash is coming and then i am entering “23”. But when doing the same through automation, I am able to enter “02” after that slash is coming but after that i am not able to enter “23” in the text field. The step is passing without any error, but it is not entering the complete value because of which the test case is failing.

Appium Version: 1.15.1
IOS Simuator Version: 11.0

Things I have tried:

  1. I have tried giving some wait after entering “02” , but that is not working.
  2. Tried using “set_value” instead of “send_keys”, not working.

Below is the screenshot:

Capture

Appium Log:

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5050/click

[HTTP] {“id”:“5050”,“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.click() with args: [“5050”,“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘click’[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5050/click

[HTTP] {“id”:“5050”,“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.click() with args: [“5050”,“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘click’

[RemoteDebugger] Executing atom ‘click’

[RemoteDebugger] Executing ‘click’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 114)

[RemoteDebugger] Received data response from send (id: 114): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 58ms

[RemoteDebugger] Received result for atom ‘click’ execution: null

[MJSONWP (3813596c)] Responding to client with driver.click() result: null

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5050/click 200 65 ms - 76

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element

[HTTP] {“using”:“xpath”,“value”:"//input[@placeholder=‘xxxx-xxxx-xxxx-xxxx’]",“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.findElement() with args: [“xpath”,"//input[@placeholder=‘xxxx-xxxx-xxxx-xxxx’]",“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘findElement’

[BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id

[BaseDriver] Waiting up to 0 ms for condition

[RemoteDebugger] Executing atom ‘find_element’

[RemoteDebugger] Executing ‘find_element’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var k=this;functi…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 115)

[RemoteDebugger] Received data response from send (id: 115): ‘{“status”:0,“value”:{“ELEMENT”:":wdc:1581678201878"}}’

[RemoteDebugger] Sending to Web Inspector took 515ms

[RemoteDebugger] Received result for atom ‘find_element’ execution: {“ELEMENT”:":wdc:1581678201878"}

[MJSONWP (3813596c)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“5051”,“ELEMENT”:“5051”}

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element 200 523 ms - 135

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5051/value

[HTTP] {“text”:“123456788999”,“value”:[“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“8”,“9”,“9”,“9”],“id”:“5051”,“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.setValue() with args: [[“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“8”,“9”,“9”,“9”],“5051”,“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘setValue’

[RemoteDebugger] Executing atom ‘click’

[RemoteDebugger] Executing ‘click’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 116)

[RemoteDebugger] Received data response from send (id: 116): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 87ms

[RemoteDebugger] Received result for atom ‘click’ execution: null

[RemoteDebugger] Executing atom ‘type’

[RemoteDebugger] Executing ‘type’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 117)

[RemoteDebugger] Received data response from send (id: 117): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 98ms

[RemoteDebugger] Received result for atom ‘type’ execution: null

[MJSONWP (3813596c)] Responding to client with driver.setValue() result: null

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5051/value 200 194 ms - 76

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element

[HTTP] {“using”:“xpath”,“value”:"//input[@placeholder=‘MM/YY’]",“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.findElement() with args: [“xpath”,"//input[@placeholder=‘MM/YY’]",“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘findElement’

[BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id

[BaseDriver] Waiting up to 0 ms for condition

[RemoteDebugger] Executing atom ‘find_element’

[RemoteDebugger] Executing ‘find_element’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var k=this;functi…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 118)

[RemoteDebugger] Received data response from send (id: 118): ‘{“status”:0,“value”:{“ELEMENT”:":wdc:1581678201879"}}’

[RemoteDebugger] Sending to Web Inspector took 95ms

[RemoteDebugger] Received result for atom ‘find_element’ execution: {“ELEMENT”:":wdc:1581678201879"}

[MJSONWP (3813596c)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“5052”,“ELEMENT”:“5052”}

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element 200 100 ms - 135

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/appium/element/5052/value

[HTTP] {“id”:“5052”,“value”:[“20”],“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.setValueImmediate() with args: [[“20”],“5052”,“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘setValueImmediate’

[XCUITest] There is currently no way to bypass typing using XCUITest. Setting value through keyboard

[RemoteDebugger] Executing atom ‘click’

[RemoteDebugger] Executing ‘click’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 119)

[RemoteDebugger] Received data response from send (id: 119): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 82ms

[RemoteDebugger] Received result for atom ‘click’ execution: null

[RemoteDebugger] Executing atom ‘type’

[RemoteDebugger] Executing ‘type’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 120)

[RemoteDebugger] Received data response from send (id: 120): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 52ms

[RemoteDebugger] Received result for atom ‘type’ execution: null

[MJSONWP (3813596c)] Responding to client with driver.setValueImmediate() result: null

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/appium/element/5052/value 200 149 ms - 76

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element

[HTTP] {“using”:“xpath”,“value”:"//input[@placeholder=‘e.g. Neha Sharma’]",“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.findElement() with args: [“xpath”,"//input[@placeholder=‘e.g. Neha Sharma’]",“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘findElement’

[BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id

[BaseDriver] Waiting up to 0 ms for condition

[RemoteDebugger] Executing atom ‘find_element’

[RemoteDebugger] Executing ‘find_element’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var k=this;functi…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 121)

[RemoteDebugger] Received data response from send (id: 121): ‘{“status”:0,“value”:{“ELEMENT”:":wdc:1581678201880"}}’

[RemoteDebugger] Sending to Web Inspector took 41ms

[RemoteDebugger] Received result for atom ‘find_element’ execution: {“ELEMENT”:":wdc:1581678201880"}

[MJSONWP (3813596c)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“5053”,“ELEMENT”:“5053”}

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element 200 45 ms - 135

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5053/value

[HTTP] {“text”:“XYZ”,“value”:[“X”,“Y”,“Z”],“id”:“5053”,“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.setValue() with args: [[“X”,“Y”,“Z”],“5053”,“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘setValue’

[RemoteDebugger] Executing atom ‘click’

[RemoteDebugger] Executing ‘click’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 122)

[RemoteDebugger] Received data response from send (id: 122): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 79ms

[RemoteDebugger] Received result for atom ‘click’ execution: null

[RemoteDebugger] Executing atom ‘type’

[RemoteDebugger] Executing ‘type’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 123)

[RemoteDebugger] Received data response from send (id: 123): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 45ms

[RemoteDebugger] Received result for atom ‘type’ execution: null

[MJSONWP (3813596c)] Responding to client with driver.setValue() result: null

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5053/value 200 135 ms - 76

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element

[HTTP] {“using”:“xpath”,“value”:"//input[@placeholder=‘xxxx’]",“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.findElement() with args: [“xpath”,"//input[@placeholder=‘xxxx’]",“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘findElement’

[BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id

[BaseDriver] Waiting up to 0 ms for condition

[RemoteDebugger] Executing atom ‘find_element’

[RemoteDebugger] Executing ‘find_element’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var k=this;functi…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 124)

[RemoteDebugger] Received data response from send (id: 124): ‘{“status”:0,“value”:{“ELEMENT”:":wdc:1581678201881"}}’

[RemoteDebugger] Sending to Web Inspector took 45ms

[RemoteDebugger] Received result for atom ‘find_element’ execution: {“ELEMENT”:":wdc:1581678201881"}

[MJSONWP (3813596c)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“5054”,“ELEMENT”:“5054”}

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element 200 51 ms - 135

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5054/value

[HTTP] {“text”:“678”,“value”:[“6”,“7”,“8”],“id”:“5054”,“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.setValue() with args: [[“6”,“7”,“8”],“5054”,“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘setValue’

[RemoteDebugger] Executing atom ‘click’

[RemoteDebugger] Executing ‘click’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 125)

[RemoteDebugger] Received data response from send (id: 125): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 57ms

[RemoteDebugger] Received result for atom ‘click’ execution: null

[RemoteDebugger] Executing atom ‘type’

[RemoteDebugger] Executing ‘type’ atom in default context

[RemoteDebugger] Sending javascript command: ‘(function(){return function(){var h,aa=this;fun…’

[RemoteDebugger] Sending ‘_rpc_forwardSocketData:’ message to app ‘PID:742’, page ‘1’, target ‘page-6’ (id: 126)

[RemoteDebugger] Received data response from send (id: 126): ‘{“status”:0,“value”:null}’

[RemoteDebugger] Sending to Web Inspector took 71ms

[RemoteDebugger] Received result for atom ‘type’ execution: null

[MJSONWP (3813596c)] Responding to client with driver.setValue() result: null

[HTTP] <-- POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element/5054/value 200 143 ms - 76

[HTTP]

[HTTP] --> POST /wd/hub/session/3813596c-a5f1-45ed-b54a-dfab15e61bce/element

[HTTP] {“using”:“xpath”,“value”:"//div[3]//button[1]",“sessionId”:“3813596c-a5f1-45ed-b54a-dfab15e61bce”}

[MJSONWP (3813596c)] Calling AppiumDriver.findElement() with args: [“xpath”,"//div[3]//button[1]",“3813596c-a5f1-45ed-b54a-dfab15e61bce”]

[XCUITest] Executing command ‘findElement’

Can anyone tell, how to make it work.

Thanks

Try to switch to the native context, locate the corresponding numeric buttons on the native keyboard and tap them

try also TAP on this field before sending input value

Hi @mykola-mokhnach,

I have used below code and it is not working:

driver.context(“NATIVE_APP”)
driver.find_element_by_xpath("//[@text=‘0’]").click()
driver.find_element_by_xpath("//
[@text=‘2’]").click()
driver.find_element_by_xpath("//[@text=‘2’]").click()
driver.find_element_by_xpath("//
[@text=‘3’]").click()
driver.context(“NATIVE_APP_INSTRUMENTED”)

is it correct?

Hi @Aleksei,

I have tried below code:

element=driver.find_element_by_xpath("//input[@placeholder=‘MM/YY’]")
touch_actions=TouchActions(driver)
touch_actions.tap(element).perform()
element.send_keys(“20”)
touch_actions=TouchActions(driver)
touch_actions.tap(element).perform()
element.send_keys(“23”)

It is not working.

did keyboard appeared after tap? it is important cause “sendKeys” uses REAL keyboard.

No @Aleksei, Keyboard did not appear after tap.

Actually keyboard is not appearing in any of the text entering step, but all steps are passing except this expiry date.

in your situation i will try to solve it:

  1. make tap to appear keyboard. by element / by X,Y / … somehow to appear keyboard
  2. with keyboard:
driver.getKeyboard().sendKeys("text");

this is pure 100% like user does behavior.

After setting ‘connectHardwareKeyboard’ capability to ‘false’, keyboard is appearing.

Then I tried:
driver.getKeyboard().sendKeys(“text”);…but still it is not working.

I tried with set_value also but it is not working.

In normal text box, I am able to enter text, but in expiry date text field , one slash is coming automatically , because of that only first two digits are getting inserted not the last two.

maybe it needed tap “Next” or “Done” button on keyboard to switch next…

@Aleksei., how to do getKeyboard() in python ?