UiDevice.getInstance因异常而失败

时间:2017-06-16 07:00:09

标签: android uiautomator

我想使用UiAutomator单击系统弹出窗口的按钮。所以我在下面的代码中加入了我的MainActivity类的一个函数。

array

但是在运行应用程序时,控制台报告:

  

没有注册仪器!必须在注册下运行   仪器仪表   在android.support.test.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)

哪个部分需要修复?我是仪器仪表的新手。感谢。

1 个答案:

答案 0 :(得分:1)

您需要从Android Studio或private void richTextBox1_TextChanged(object sender, EventArgs e) { var pos = richTextBox1.GetPositionFromCharIndex(richTextBox1.SelectionStart); Point locationOnForm = panel1.FindForm() .PointToClient(panel1.Parent.PointToScreen(panel1.Location)); Point newLocation = new Point(locationOnForm.X - 10, pos.Y + locationOnForm.Y - 13); button1.Location = newLocation; } 的测试运行中获取Instrumentation,而不是从正在运行的应用中获取。