Cannot move slider to any position using sendKeys("0.x");

I cannot move slider to any position using sendKeys(“0.x”);

Appium Server - 1.3.1
Java -client - 2.0
x-code - 6.1

slider is being found by appium, however, it’s value is represented by an element itself.

Here is the server log:

info: [debug] [INST] 2014-11-12 22:57:15 +0000 Debug: Lookup returned [object UIASlider] with the name “pageSlider” (id: 328).
info: [debug] [INST] 2014-11-12 22:57:15 +0000 Debug: responding with:
info: [debug] Socket data received (40 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“ELEMENT”:“328”}}
info: [debug] Responding to client with success: {“status”:0,“value”:{“ELEMENT”:“328”},“sessionId”:“bedfc20a-c036-4380-bacd-869b1eb05fab”}
info: <-- POST /wd/hub/session/bedfc20a-c036-4380-bacd-869b1eb05fab/element 200 3943.397 ms - 89 {“status”:0,“value”:{“ELEMENT”:“328”},“sessionId”:“bedfc20a-c036-4380-bacd-869b1eb05fab”}
info: --> POST /wd/hub/session/bedfc20a-c036-4380-bacd-869b1eb05fab/element/328/value {“id”:“328”,“value”:[“0.2”]}
info: [debug] Pushing command to appium work queue: “au.getElement(‘328’).setValueByType(‘0.2’)”
info: [debug] Sending command to instruments: au.getElement(‘328’).setValueByType(‘0.2’)
info: [debug] [INST] 2014-11-12 22:57:15 +0000 Debug: Running system command #76: /Users/bzayats/local/bin/node /Users/Bzayats/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“ELEMENT”:“328”}}…
info: [debug] [INST] 2014-11-12 22:57:16 +0000 Debug: Got new command 76 from instruments: au.getElement(‘328’).setValueByType(‘0.2’)
info: [debug] [INST] 2014-11-12 22:57:16 +0000 Debug: evaluating au.getElement(‘328’).setValueByType(‘0.2’)
info: [debug] [INST] 2014-11-12 22:57:16 +0000 Debug: target.frontMostApp().elements()[0].elements()[26].dragToValue(“0.2”)
info: [debug] [INST] 2014-11-12 22:57:16 +0000 Debug: Unexpected error in -[UIASlider_0x15532210 dragToValue : ], /SourceCache/UIAutomation/UIAutomation-430/Framework/UIAItemElements.m line 626

Is there more to the log? This is happening within the UIAutomation code, which is unusual. It’s definitely trying to move the slider
target.frontMostApp().elements()[0].elements()[26].dragToValue("0.2"). You might check iOS Simulator.log and see if you can find more info.

You might also try setValue and see if that works.

@0x1mason I’m currently trying to move slider as follows: mySlider().sendKeys(“0.2”);
where mySlider() returns WebElement representing slider I’m trying to move. My question is how to use your setValue() as you recommended?

Thanks

@Shrey_Mehta You can use mySlider().setValue(newStringValue) or try the desired capability sendKeyStrategy set to setValue. Try the former first.

@0x1mason Thanks for recommendations. WebElement does not have a method to setValue() (mySlider() is a WebElement object), but I will try to play around with sendKeyStrategy capability. Thanks again !!

1 Like

Yw! Let us know if it works for you.

did you get it working?

Thanks,i got this working for UIASlider. My values were 10%,20% so my code was something like this:
iDriver.findElement(by.xpath("//UIASlider[1]")).sendKeys(“0.2”); for 20%.

Thanks Again…!

2 Likes