, adjustToNormalizedSliderPosition
.
import XCTest
extension XCUIElement {
open func adjust(toNormalizedSliderValue normalizedSliderValue: CGFloat) {
let start = coordinate(withNormalizedOffset: CGVector(dx: 0.0, dy: 0.0))
let end = coordinate(withNormalizedOffset: CGVector(dx: normalizedSliderValue, dy: 0.0))
start.press(forDuration: 0.05, thenDragTo: end)
}
}
Then you only need to call:
app.sliders["Your Slider Identifier"].adjust(toNormalizedSliderValue: 0.5)
Here you can find other useful tips for Xcode UITesting:
https://github.com/joemasilotti/UI-Testing-Cheat-Sheet
source
share