Unable to set value in text field iOS

I’m using the appium_lib gem, and within it are several endpoint methods that are available for use to interact with the device. I’m trying to use set_immediate_value, but it crashes with the following error:
Selenium::WebDriver::Error::UnknownError: ERROR running Appium command: invalid json

Here’s my code snippet:

driver.set_immediate_value email_field, “#{username}”

def email_field
apm.driver.driver.find_element(:accessibility_id, ‘Email Field’)

The driver is able to find the email_field element fine, but crashes when executing set_immediate_value.

Anyone know how to fix this?


1 Like

It’s probably broken. That method was added by another dev and it has no tests. I’ve opened an issue.

Is there an alternative to use in the mean time for setting values?


You can invoke setValue via execute script as a work around.


Thanks for the reply. Unfortunately execute_script doesn’t work with Appium version 1.2.2, as it’s deprecated. Any other work arounds?

execute script works fine and it’s not deprecated.

Ahh, my mistake. :mobile methods have been deprecated. This work around works :slight_smile: Thank you

@bootstraponline how do we send an enter key with ‘type’ method above? ‘\n’ that works with send_keys doesn’t seem to work

type is just setValue + hide keyboard. I don’t think it’ll do enter.

hide keyboard fails for me with keyboard is nil, because in ios8 simulator, keyboard doesn’t show up when entering text (bug)

In theory set_immediate_value is an easy way to invoke setValue, you could use that instead of .type.