我尝试使用 detox 检查该元素是否在 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 完美配合,但在 android 中,我得到了我提到的错误。*detox 是使用 android-espresso 的 react-native 的 e2e 测试库
最佳答案
就我而言,事实证明,我在本地拥有比 CI 更大的设备。因此,当我使用 --take-screenshots failing
截屏失败时我注意到,经过测试的 View 位于绝对 View 之下,并且被覆盖了。 IDK,如果它与上述问题有关,但也许它会帮助其他人。
关于android - Detox 至少 75% 的 View 区域显示给用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64278482/