{"action":"opened","issue":{"url":"https://api.github.com/repos/googlesamples/android-testing/issues/21","labels_url":"https://api.github.com/repos/googlesamples/android-testing/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/googlesamples/android-testing/issues/21/comments","events_url":"https://api.github.com/repos/googlesamples/android-testing/issues/21/events","html_url":"https://github.com/googlesamples/android-testing/issues/21","id":71570115,"number":21,"title":"Ui Automator -> UiObject2.setText() fails on APK <= 19 if the current TextBox is empty","user":{"login":"marcosdiez","id":297498,"avatar_url":"https://avatars.githubusercontent.com/u/297498?v=3","gravatar_id":"","url":"https://api.github.com/users/marcosdiez","html_url":"https://github.com/marcosdiez","followers_url":"https://api.github.com/users/marcosdiez/followers","following_url":"https://api.github.com/users/marcosdiez/following{/other_user}","gists_url":"https://api.github.com/users/marcosdiez/gists{/gist_id}","starred_url":"https://api.github.com/users/marcosdiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcosdiez/subscriptions","organizations_url":"https://api.github.com/users/marcosdiez/orgs","repos_url":"https://api.github.com/users/marcosdiez/repos","events_url":"https://api.github.com/users/marcosdiez/events{/privacy}","received_events_url":"https://api.github.com/users/marcosdiez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-28T12:04:31Z","updated_at":"2015-04-28T12:04:31Z","closed_at":null,"body":"On Android APK <= 19, UiAutomator up to 2.1.0 fails with the when\r\n\r\nUiObject2 txtField = getEditTextByAnyMeans();\r\ntxtField.setText(\"blah\");\r\n\r\nthe reason is quite simple:\r\n\r\n    public void setText(String text) {\r\n        AccessibilityNodeInfo node = getAccessibilityNodeInfo();\r\n   ......\r\n            CharSequence currentText = node.getText();\r\n            if (!currentText.equals(text)) {\r\n\r\nnode.getText() is returning null and that is causing the app to creash.\r\n\r\n\r\nbellow is the stacktrace:\r\n\r\njava.lang.NullPointerException\r\nat android.support.test.uiautomator.UiObject2.setText(UiObject2.java:589)\r\nat com.connvision.farmforce.tests.ApplicationTest.setFieldValue(ApplicationTest.java:150)\r\nat com.connvision.farmforce.tests.ApplicationTest.testAddFarmer(ApplicationTest.java:129)\r\nat java.lang.reflect.Method.invokeNative(Native Method)\r\nat java.lang.reflect.Method.invoke(Method.java:515)\r\nat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)\r\nat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)\r\nat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)\r\nat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)\r\nat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)\r\nat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)\r\nat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)\r\nat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)\r\nat org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)\r\nat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)\r\nat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)\r\nat org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)\r\nat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)\r\nat org.junit.runners.ParentRunner.run(ParentRunner.java:300)\r\nat org.junit.runners.Suite.runChild(Suite.java:128)\r\nat org.junit.runners.Suite.runChild(Suite.java:24)\r\nat org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)\r\nat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)\r\nat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)\r\nat org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)\r\nat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)\r\nat org.junit.runners.ParentRunner.run(ParentRunner.java:300)\r\nat org.junit.runner.JUnitCore.run(JUnitCore.java:157)\r\nat org.junit.runner.JUnitCore.run(JUnitCore.java:136)\r\nat android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:270)\r\nat android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1741)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}