Changing iOS slider values

Hi, I am trying to test a React Native (iOS) app that has some sliders. Based on Appium docs, I tried setting a slider value using $('~slider-red').sendKeys(['0']). However I am getting the following error:

invalid element state: Error Domain=com.facebook.WebDriverAgent Code=1 “The on-screen keyboard must be present to send keys”

Has anybody gotten this to work?

  • My stack consists of WebdriverIO sending commands to Appium
  • My project/test code is available here

I’m getting the same error. I’m using Appium inspector, found the element (type
XCUIElementTypeTextField), Tap is working, sendKeys() fails with:
[WD Proxy] Got response with status 400: {“value”:{“error”:“invalid element state”,“message”:“Error Domain=com.facebook.WebDriverAgent Code=1 “The on-screen keyboard must be present to send keys” UserInfo={NSLocalizedDescription=The on-screen keyboard must be present to send keys}”,“traceback”:""},“sessionId”:“38489C90-E812-427E-94AB-64923EBA6C59”}

[2020-04-30 01:11:26][W3C] Matched W3C error code ‘invalid element state’ to InvalidElementStateError

[2020-04-30 01:11:26][MJSONWP (5c6fbd68)] Encountered internal error running command: InvalidElementStateError: Error Domain=com.facebook.WebDriverAgent Code=1 “The on-screen keyboard must be present to send keys” UserInfo={NSLocalizedDescription=The on-screen keyboard must be present to send keys}

The “fix” for this issue is actually quite simple.
Select the iOS Simulator to be your active window, then in the top menu if „Connect Hardware Keyboard“ is checked, uncheck it. If it’s already unchecked, check it, then uncheck it. Then it should work.
The option can be found here:

However this is more a workaround than a real “fix” in my opinion. It would be great if Appium did that by default before starting a test.

@martinfrancois : in my case, I use a real device, not simulator.

I am facing the same issue, tap action works fine but send keys fails but I got the response code 200. I have observed one thing that when there is only one slider on the screen it is working fine but if the slider is inside a table view it’s not working. Has anybody fixed the issue?