does anybody know, how to set a seekBar to a specific value or just a click on that view on Espresso UI Testing ?
I just get an exception: Error performing 'single click' on view with id...
onView(withId(R.id.FilterPriceMax)).perform(click());
You might want to give the following code a try:
First you could match the SeekBar
with its class name:
onView(withClassName(Matchers.equalTo(SeekBar.class.getName()))).perform(setProgress(progress));
where setProgress(final int progress) is a ViewAction you defined as:
public static ViewAction setProgress(final int progress) {
return new ViewAction() {
@Override
public void perform(UiController uiController, View view) {
SeekBar seekBar = (SeekBar) view;
seekBar.setProgress(progress);
}
@Override
public String getDescription() {
return "Set a progress on a SeekBar";
}
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(SeekBar.class);
}
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With