Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 浓缩咖啡测试无法在某些设备上单击对话框按钮_Android_Android Espresso - Fatal编程技术网

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

Android 浓缩咖啡测试无法在某些设备上单击对话框按钮,android,android-espresso,Android,Android Espresso,我有一个浓缩咖啡测试来验证正在显示的对话框。它按下一个按钮打开对话框,并应通过单击对话框的积极按钮将其关闭。对话框可以正常打开,但在两台三星设备(三星S6 Edge和三星S7)上单击对话框的正极按钮失败,但在所有其他设备上都可以工作。我尝试了以下解决方案: 按按钮上的文本匹配按钮 onView(使用文本(R.string.changelog\u ok\u按钮))。执行(单击()) 通过android操作系统分配给正面对话框按钮的ID匹配按钮: onView(带id(android.R.id.bu

我有一个浓缩咖啡测试来验证正在显示的对话框。它按下一个按钮打开对话框,并应通过单击对话框的积极按钮将其关闭。对话框可以正常打开,但在两台三星设备(三星S6 Edge和三星S7)上单击对话框的正极按钮失败,但在所有其他设备上都可以工作。我尝试了以下解决方案:

按按钮上的文本匹配按钮
onView(使用文本(R.string.changelog\u ok\u按钮))。执行(单击())

通过android操作系统分配给正面对话框按钮的ID匹配按钮:
onView(带id(android.R.id.button1))。执行(单击())

这两种解决方案都适用于大多数设备,但Samsungs表示拒绝执行点击操作,导致以下错误:

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}"
android.support.test.espresso.PerformException:使用资源id:[changelog\u ok\u button]中的字符串在视图上执行“单击”时出错。值:ok。
[...]
原因:java.lang.RuntimeException:将不执行操作,因为目标视图与以下一个或多个约束不匹配:
至少90%的视图区域显示给用户。
目标视图:“应用程序”按钮{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 focusable=false,is layout request=false,is selected=false,layout params=android.widget.LinearLayout$LayoutParams@ab3a33,tag=null,根是布局请求ed=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\u ok\u按钮匹配


三星是否对可能导致此问题的对话框采取了不同的措施?是否有人遇到了相同的问题并找到了解决方案,或者对如何使其正常工作有了一些想法?

根据错误描述可以清楚地看出:

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%。

我让设备在我的机器上本地进行测试。按钮完全可见并且可以手动点击(应该如此。对话框按钮永远不应该离开显示区域)。