Moving slider on iOS

Hi there! Need help on moving sliders specifically on iOS. I already tried using Mobile.setSliderValue and even changed the object from the slider bar to the slider thumb, but nothing worked. Also tried using range and percentage. Any ideas?

1 Like

Did you try to move slider using touch action class?

Can you try this -

And please let me know if it worked

@Keyword
void swipeSlider(String sliderValue, int index) {
TouchAction touchAction = new TouchAction(MobileDriverFactory.getDriver())
Dimension mobileDimension = MobileDriverFactory.getDriver().manage().window().getSize()

	int xAxisForDefaultValue = (int) Integer.parseInt(SliderValueData.getValue(ColumnName.X_AXIS_DEFAULT_VALUE.getValue(), index))
	int yAxisForDefaultValue = (int) Integer.parseInt(SliderValueData.getValue(ColumnName.Y_AXIS_DEFAULT_VALUE.getValue(), index))
	int defaultSliderValue = (int) Integer.parseInt(SliderValueData.getValue(ColumnName.DEFAULT_SLIDER_VALUE.getValue(), index))
	int offsetBetweenTwoValues = (int) Integer.parseInt(SliderValueData.getValue(ColumnName.OFFSET_BETWEEN_TWO_VALUES.getValue(), index))
	if(mobileDimension.getHeight() >= 1776) {
		PointOption paFive = PointOption.point(xAxisForDefaultValue, yAxisForDefaultValue)
		xAxisForDefaultValue = xAxisForDefaultValue + ((Integer.parseInt(sliderValue) - defaultSliderValue) * offsetBetweenTwoValues)
		PointOption paToMove = PointOption.point(xAxisForDefaultValue, yAxisForDefaultValue)
		touchAction.press(paFive).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3))).moveTo(paToMove).release().perform()
	}
	else {
		KeywordUtil.markError('Expected height of device must be greate than::: '+mobileDimension.getHeight().toString())
		KeywordUtil.markError('Actual device height is::: ' +mobileDimension.getHeight().toString())
	}
}