# UiAutomatorTestCase

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/UiAutomatorTestCase.java+class:androidx.test.uiautomator.UiAutomatorTestCase) Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

*** ** * ** ***


```
public class UiAutomatorTestCase extends InstrumentationTestCase
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | junit.framework.Assert ||||
|   | ↳ | junit.framework.TestCase |||
|   |   | ↳ | [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html) ||
|   |   |   | ↳ | [androidx.test.uiautomator.UiAutomatorTestCase](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase) |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> It is no longer necessary to extend UiAutomatorTestCase. You can use `https://developer.android.com/reference/androidx/test/uiautomator/UiDevice#getInstance(android.app.Instrumentation)` from any test class as long as you have access to an `https://developer.android.com/reference/android/app/Instrumentation.html` instance.

UI Automator test case that is executed on the device.

## Summary

| ### Public constructors |
|---|
| `[UiAutomatorTestCase](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#UiAutomatorTestCase())()` **This method is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/IAutomationSupport` | `[getAutomationSupport](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#getAutomationSupport())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/app/Instrumentation.html#sendStatus(int, android.os.Bundle)` instead <br /> |
| `https://developer.android.com/reference/android/os/Bundle.html` | `[getParams](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#getParams())()` **This method is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/androidx/test/uiautomator/UiDevice` | `[getUiDevice](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#getUiDevice())()` **This method is deprecated.** Deprecated in Java |
| `void` | `[sleep](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#sleep(long))(long ms)` **This method is deprecated.** Use `https://developer.android.com/reference/android/os/SystemClock.html#sleep(long)` instead. <br /> |

### Inherited methods

From [android.test.InstrumentationTestCase](https://developer.android.com/reference/android/test/InstrumentationTestCase.html) `https://developer.android.com/reference/android/app/Instrumentation.html` `[getInstrumentation](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#getInstrumentation())()`

**This method is deprecated.**
`void` `[injectInsrumentation](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#injectInsrumentation(android.app.Instrumentation))(https://developer.android.com/reference/android/app/Instrumentation.html instrumentation)`

**This method is deprecated.**
`void` `[injectInstrumentation](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#injectInstrumentation(android.app.Instrumentation))(https://developer.android.com/reference/android/app/Instrumentation.html instrumentation)`

**This method is deprecated.**
`final T` `<T extends https://developer.android.com/reference/android/app/Activity.html> [launchActivity](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#launchActivity(java.lang.String, java.lang.Class&lt;T&gt;, android.os.Bundle))(
https://developer.android.com/reference/java/lang/String.html pkg,
https://developer.android.com/reference/java/lang/Class.html<T> activityCls,
https://developer.android.com/reference/android/os/Bundle.html extras
)`

**This method is deprecated.**
`final T` `<T extends https://developer.android.com/reference/android/app/Activity.html> [launchActivityWithIntent](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#launchActivityWithIntent(java.lang.String, java.lang.Class&lt;T&gt;, android.content.Intent))(
https://developer.android.com/reference/java/lang/String.html pkg,
https://developer.android.com/reference/java/lang/Class.html<T> activityCls,
https://developer.android.com/reference/android/content/Intent.html intent
)`

**This method is deprecated.**
`void` `[runTest](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#runTest())()`

**This method is deprecated.**
`void` `[runTestOnUiThread](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#runTestOnUiThread(java.lang.Runnable))(https://developer.android.com/reference/java/lang/Runnable.html r)`

**This method is deprecated.**
`void` `[sendKeys](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#sendKeys(int...))(int[] keys)`

**This method is deprecated.**
`void` `[sendRepeatedKeys](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#sendRepeatedKeys(int...))(int[] keys)`

**This method is deprecated.**
`void` `[tearDown](https://developer.android.com/reference/android/test/InstrumentationTestCase.html#tearDown())()`

**This method is deprecated.**
From junit.framework.TestCase `static void` `assertEquals(https://developer.android.com/reference/java/lang/String.html message, https://developer.android.com/reference/java/lang/Object.html expected, https://developer.android.com/reference/java/lang/Object.html actual)`

**This method is deprecated.** Deprecated in Java
`static void` `assertFalse(https://developer.android.com/reference/java/lang/String.html message, boolean condition)`

**This method is deprecated.** Deprecated in Java
`static void` `assertNotNull(https://developer.android.com/reference/java/lang/Object.html object)`

**This method is deprecated.** Deprecated in Java
`static void` `assertNotSame(https://developer.android.com/reference/java/lang/String.html message, https://developer.android.com/reference/java/lang/Object.html expected, https://developer.android.com/reference/java/lang/Object.html actual)`

**This method is deprecated.** Deprecated in Java
`static void` `assertNull(https://developer.android.com/reference/java/lang/Object.html object)`

**This method is deprecated.** Deprecated in Java
`static void` `assertSame(https://developer.android.com/reference/java/lang/String.html message, https://developer.android.com/reference/java/lang/Object.html expected, https://developer.android.com/reference/java/lang/Object.html actual)`

**This method is deprecated.** Deprecated in Java
`static void` `assertTrue(https://developer.android.com/reference/java/lang/String.html message, boolean condition)`

**This method is deprecated.** Deprecated in Java
`int` `countTestCases()`

**This method is deprecated.** Deprecated in Java
`junit.framework.TestResult` `createResult()`

**This method is deprecated.** Deprecated in Java
`static void` `fail(https://developer.android.com/reference/java/lang/String.html message)`

**This method is deprecated.** Deprecated in Java
`static void` `failNotEquals(https://developer.android.com/reference/java/lang/String.html message, https://developer.android.com/reference/java/lang/Object.html expected, https://developer.android.com/reference/java/lang/Object.html actual)`

**This method is deprecated.** Deprecated in Java
`static void` `failNotSame(https://developer.android.com/reference/java/lang/String.html message, https://developer.android.com/reference/java/lang/Object.html expected, https://developer.android.com/reference/java/lang/Object.html actual)`

**This method is deprecated.** Deprecated in Java
`static void` `failSame(https://developer.android.com/reference/java/lang/String.html message)`

**This method is deprecated.** Deprecated in Java
`static https://developer.android.com/reference/java/lang/String.html` `format(https://developer.android.com/reference/java/lang/String.html message, https://developer.android.com/reference/java/lang/Object.html expected, https://developer.android.com/reference/java/lang/Object.html actual)`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/java/lang/String.html` `getName()`

**This method is deprecated.** Deprecated in Java
`junit.framework.TestResult` `run()`

**This method is deprecated.** Deprecated in Java
`void` `run(junit.framework.TestResult result)`

**This method is deprecated.** Deprecated in Java
`void` `runBare()`

**This method is deprecated.** Deprecated in Java
`void` `setName(https://developer.android.com/reference/java/lang/String.html name)`

**This method is deprecated.** Deprecated in Java
`void` `setUp()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/java/lang/String.html` `toString()`

**This method is deprecated.** Deprecated in Java

## Public constructors

### UiAutomatorTestCase

Added in 2.2.0 Deprecated in 2.2.0

```
public [UiAutomatorTestCase](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#UiAutomatorTestCase())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

## Public methods

### getAutomationSupport

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
public IAutomationSupport [getAutomationSupport](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#getAutomationSupport())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/app/Instrumentation.html#sendStatus(int, android.os.Bundle)` instead

Provides support for running tests to report interim status

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/IAutomationSupport` | IAutomationSupport |

### getParams

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
public Bundle [getParams](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#getParams())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Get command line parameters. On the command line when passing `-e key value` pairs, the `https://developer.android.com/reference/android/os/Bundle.html` will have the key value pairs conveniently available to the tests.

### getUiDevice

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
public UiDevice [getUiDevice](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#getUiDevice())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Get current instance of `https://developer.android.com/reference/androidx/test/uiautomator/UiDevice`. Works similar to calling the static `https://developer.android.com/reference/androidx/test/uiautomator/UiDevice#getInstance()` from anywhere in the test classes.

### sleep

Added in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0) Deprecated in [2.2.0](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.2.0)

```
public void [sleep](https://developer.android.com/reference/androidx/test/uiautomator/UiAutomatorTestCase#sleep(long))(long ms)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/os/SystemClock.html#sleep(long)` instead.

Calls `https://developer.android.com/reference/android/os/SystemClock.html#sleep(long)` to sleep

| Parameters |
|---|---|
| `long ms` | is in milliseconds. |