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());
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:where setProgress(final int progress) is a ViewAction you defined as:
I use a swipe-action to perform an actual swipe on the
SeekBar
. This makes sure the callback method (SeekBar.OnSeekBarChangeListener. onProgressChanged
) is called withfromUser
set to true. It is also more in the line of click testing.I have used this to do some basic testing on seekbar UI components if you don't require specific values. It assumes the 'check()' is based on a 0-100 percentage.
I have a custom Seekbar, and also I have multiple Seekbars in my View. I managed do my test with this code below:
and
In case you want to check the progress value