# DrawerActions

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/DrawerActions.java+class:androidx.test.espresso.contrib.DrawerActions)

*** ** * ** ***


```
public final class DrawerActions
```

<br />

*** ** * ** ***

Espresso actions for using a `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout`.

See [Navigation drawer design guide](http://developer.android.com/design/patterns/navigation-drawer.html)

## Summary

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/test/espresso/ViewAction` | `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#close()()` Creates an action which closes the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` with gravity START. |
| `static https://developer.android.com/reference/androidx/test/espresso/ViewAction` | `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#close(int)(int gravity)` Creates an action which closes the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` with the gravity. |
| `static void` | `[closeDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#closeDrawer(int))(int drawerLayoutId)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#close()` with `perform` after matching a view. <br /> |
| `static void` | `[closeDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#closeDrawer(int,int))(int drawerLayoutId, int gravity)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open(int)` with `perform` after matching a view. <br /> |
| `static https://developer.android.com/reference/androidx/test/espresso/ViewAction` | `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open()()` Creates an action which opens the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` drawer with gravity START. |
| `static https://developer.android.com/reference/androidx/test/espresso/ViewAction` | `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open(int)(int gravity)` Creates an action which opens the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` drawer with the gravity. |
| `static void` | `[openDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#openDrawer(int))(int drawerLayoutId)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open()` with `perform` after matching a view. <br /> |
| `static void` | `[openDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#openDrawer(int,int))(int drawerLayoutId, int gravity)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open(int)` with `perform` after matching a view. <br /> |
| `static https://developer.android.com/reference/androidx/test/espresso/ViewAction` | `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#waitForClose()()` Creates an action that will wait for the drawer to close. |

## Public methods

### close

```
public static ViewAction close()
```

Creates an action which closes the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` with gravity START. This method blocks until the drawer is fully closed. No operation if the drawer is already closed.

### close

```
public static ViewAction close(int gravity)
```

Creates an action which closes the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` with the gravity. This method blocks until the drawer is fully closed. No operation if the drawer is already closed.

### closeDrawer

```
public static void [closeDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#closeDrawer(int))(int drawerLayoutId)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#close()` with `perform` after matching a view. This method will be removed in the next release.

### closeDrawer

```
public static void [closeDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#closeDrawer(int,int))(int drawerLayoutId, int gravity)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open(int)` with `perform` after matching a view. This method will be removed in the next release.

### open

```
public static ViewAction open()
```

Creates an action which opens the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` drawer with gravity START. This method blocks until the drawer is fully open. No operation if the drawer is already open.

### open

```
public static ViewAction open(int gravity)
```

Creates an action which opens the `https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout` drawer with the gravity. This method blocks until the drawer is fully open. No operation if the drawer is already open.

### openDrawer

```
public static void [openDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#openDrawer(int))(int drawerLayoutId)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open()` with `perform` after matching a view. This method will be removed in the next release.

### openDrawer

```
public static void [openDrawer](https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#openDrawer(int,int))(int drawerLayoutId, int gravity)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/test/espresso/contrib/DrawerActions#open(int)` with `perform` after matching a view. This method will be removed in the next release.

### waitForClose

```
public static ViewAction waitForClose()
```

Creates an action that will wait for the drawer to close. Use this in cases where the closing of the drawer is implicit, such as selecting an item in the drawer. No operation if the drawer is closed. This uses an idling resource to wait for close, so it will fail if it does not close within the idling resource timeout.