rpa*_*abi 13 android android-testing android-espresso
我浪费了两天时间尝试在全屏活动上执行点击操作.
为活动写一个espresso测试以执行点击
public class FullscreenActivityTest
extends ActivityInstrumentationTestCase2<FullscreenActivity> {
public FullscreenActivityTest() {
super(FullscreenActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
getActivity();
}
public void testClickingOnLayout() {
onView(withId(R.id.fullscreen_content)).perform(click());
}
Run Code Online (Sandbox Code Playgroud)
}
android.support.test.espresso.PerformException:
Error performing 'click' on view 'with id: com.example.espressodefect:id/fullscreen_content'
...
Caused by: android.support.test.espresso.PerformException:
Error performing 'Send down montion event' on view 'unknown'.
...
Caused by: android.support.test.espresso.InjectEventSecurityException: java.lang.SecurityException:
Injecting to another application requires INJECT_EVENTS permission
Run Code Online (Sandbox Code Playgroud)
满堆栈在这里.
我试过以下没有运气:
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)<uses-permission> 对于INJECT_EVENTS在espresso测试中,如果我使用非全屏活动(例如使用空白活动创建的活动),则执行操作可以正常工作.全屏幕上的相同操作失败.
我正在使用Espresso 2.0和支持库.
我在这做错了什么?
Espresso dev证实这是缺陷.请参阅问题140.
这个错误在 Espresso 的最新版本中已得到解决:
Espresso 2.2.2,Runner/Rules 0.5(2016-02-22,静默发布)- https://google.github.io/android-testing-support-library/downloads/release-notes/index.html
在我的项目中,我将 /app/build.grandle 中的依赖项更改为:
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
到
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
在 AndroidStudio 中:Grandle Scripts => build.gradle 文件
| 归档时间: |
|
| 查看次数: |
3329 次 |
| 最近记录: |