Search code examples
androidandroid-uiautomator

Parameters to uiAutomator test class


I am new to uiAutomator. I tried passing the parameters to method, it run but just ignores anything passed to it. Just wondering whether we can pass any arguments to test class or test method in uiAutomator?


Solution

  • Reference

    You can send in parameters via command line:

    adb shell am insrument -e <NAME> <VALUE> <package/runner>
    

    You can access the value using the bundle that is available if you override the onCreatemethod of the InstrumentationTestRunner.

    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      value = (String) savedInstanceState.get("name");
    }