# RecyclerViewActions.PositionableRecyclerViewAction

# RecyclerViewActions.PositionableRecyclerViewAction

Artifact:[androidx.test.espresso:espresso-contrib](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/contrib/RecyclerViewActions.java+class:androidx.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction "View this page in Java")

<br />

```
interface RecyclerViewActions.PositionableRecyclerViewAction : ViewAction
```

<br />

*** ** * ** ***

Most RecyclerViewActions are given a matcher to select a particular view / viewholder within the RecyclerView. In this case the default behaviour is to expect that the matcher matches 1 and only one item within the RecyclerView.

This interface gives users the ability to override that type of behaviour and explicitly select an item in the RecyclerView at a given position. This is similar to on the onData(...).atPosition() api for AdapterViews.

## Summary

|                                                                                   ### Public functions                                                                                    |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [RecyclerViewActions.PositionableRecyclerViewAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction)`!` | [atPosition](https://developer.android.com/reference/kotlin/androidx/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction#atPosition(int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns a new ViewAction which will cause the ViewAction to operate upon the position-th element which the matcher has selected. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.test.espresso.ViewAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction) |----------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Matcher](https://junit.org/junit4/javadoc/4.12/org/hamcrest/Matcher.html)`<`[View](https://developer.android.com/reference/android/view/View.html)`!>!` | [getConstraints](https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction#getConstraints())`()` A mechanism for ViewActions to specify what type of views they can operate on.                                                                                                                                                                                                     | | [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`                                                                     | [getDescription](https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction#getDescription())`()` Returns a description of the view action.                                                                                                                                                                                                                                          | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                            | [perform](https://developer.android.com/reference/kotlin/androidx/test/espresso/ViewAction#perform(androidx.test.espresso.UiController,android.view.View))`(uiController: `[UiController](https://developer.android.com/reference/kotlin/androidx/test/espresso/UiController)`!, view: `[View](https://developer.android.com/reference/android/view/View.html)`!)` Performs this action on the given view. | |

## Public functions

### atPosition

```
fun atPosition(position: Int): RecyclerViewActions.PositionableRecyclerViewAction!
```

Returns a new ViewAction which will cause the ViewAction to operate upon the position-th element which the matcher has selected.  

|                                       Parameters                                        |
|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | a 0-based index into the list of matching elements within the RecyclerView. |

|                                                                                          Returns                                                                                          |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| [RecyclerViewActions.PositionableRecyclerViewAction](https://developer.android.com/reference/kotlin/androidx/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction)`!` | PositionableRecyclerViewAction a new ViewAction focused on a particular position. |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|------------------|
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if position \<0. |