浓缩咖啡测试无法在某些设备上单击对话



我有一个用于验证显示的对话框的意式浓缩测试。它按下一个按钮以打开对话框,并应通过单击对话框的正按钮来将其予以忽略。对话框打开良好,但单击对话框的正按钮在两个三星 - 德维特(Samsung S6 Edge和Samsung S7)上失败,但在所有其他方面都可以使用。我尝试了以下解决方案:

通过应在按钮上的文本匹配按钮 onView(withText(R.string.changelog_ok_button)).perform(click())

通过Android OS分配给正面对话框按钮的ID匹配该按钮: onView(withId(android.R.id.button1)).perform(click())

这两种解决方案都在大多数设备上都可以使用,但说三星拒绝执行点击,以下错误:

android.support.test.espresso.PerformException: Error performing 'single click' on view 'with string from resource id: <2131755113>[changelog_ok_button] value: OK'.
[...]
Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
at least 90 percent of the view's area is displayed to the user.
Target view: "AppCompatButton{id=16908313, res-name=button1, visibility=VISIBLE, width=192, height=144, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@ab3a33, tag=null, root-is-layout-requested=false, has-input-connection=false, x=666.0, y=12.0, text=OK, input-type=0, ime-target=false, has-links=false}"

最令人困惑的是,当我使用布局检查器时,按钮的ID为R.id.button1,并且文本也与R.string.changelog_ok_button匹配。

三星对可能导致此的对话有什么不同?有人有同样的问题,找到了解决方案,或者有一些想法我如何才能工作?

基于错误描述很清楚:

Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints: at least 90 percent of the view's area is displayed to the user.

因此,我想有问题的设备的屏幕分辨率较小,其中剪切或隐藏了一个按钮视图,因此显示给用户的视图区域低于90%。

相关内容

最新更新