我试着用排毒软件检查这个元素在android模拟器中是否可见。我滚动页面看到了元素,但是当我用detox检查元素是否可见时,我得到了这个错误:
Test Failed: 'at least 75 percent of the view's area is displayed to the user.' doesn't match the selected view.
Expected: at least 75 percent of the view's area is displayed to the user.
Got: "ReactViewGroup{id=1227, visibility=VISIBLE, width=250, height=250, 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.view.ViewGroup$LayoutParams@a376217, tag=test1, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=95.0, child-count=1}"我试着滚动更多,将元素放在屏幕的中间,但没有区别。
await expect(element(by.id('test1')).atIndex('2')).toBeVisible();我使用react-native,所以它是相同的代码,它在iOS上工作得很好,但在安卓中,我得到了我提到的错误。
*detox是使用android-espresso的e2e原生反应测试库
发布于 2021-04-12 16:14:37
在我的例子中,事实证明,我在本地拥有比CI更大的设备。因此,当我使用--take-screenshots failing进行失败的屏幕截图时,我注意到,测试的视图位于绝对视图的下方,并且被覆盖。IDK,如果它与上述问题相关,但可能会对其他人有所帮助。
发布于 2021-08-04 12:07:07
虽然与OP不是同一个场景,但我在Android上得到了这个错误,因为我在每次测试之前调用device.reloadReactNative,这导致“至少75 %的视图区域显示给用户”。错误。
这就是我在jest设置文件中执行的操作,它导致了错误:
beforeEach(async () => {
await device.reloadReactNative();
});移除它可以修复我的测试。
(注意,我只在CI (devops pipelines)中运行时才会收到这个错误,而不是在本地运行,我的理论是这个错误是由于虚拟机速度慢导致的,因为应用程序没有足够快地变得“稳定”。)
https://stackoverflow.com/questions/64278482
复制相似问题