Detox at least 75 percent of the view's area is displayed to the user

Viewed 2438

I tried to check with detox if the element is visible with android emulator. I scroll my page and see the element but when I check with detox if the element is visible I get this error:

 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}"

I tried to scroll more to put the element in the middle of the screen, but there is no difference.

await expect(element(by.id('test1')).atIndex('2')).toBeVisible();

I use react-native so it's the same code.., and It works perfectly with iOS but in android, I get the Error that I mention.

*detox is e2e testing library for react-native that use android-espresso

2 Answers

In my case, it turned out, that locally I had bigger device than CI had. So when I did a failing screenshot using --take-screenshots failing I noticed, that tested view was beneath the absolute view and it was covered. IDK, if it is related to above issue, but maybe it will help someone else.

Although not the same scenario as the OP, I was getting this error on Android because I was calling device.reloadReactNative before each test which resulted in "at least 75 percent of the view's area is displayed to the user." errors.

This is what i was doing in my jest setup file that caused the errors:

beforeEach(async () => {
  await device.reloadReactNative();
});

Removing that fixes my tests.

(Note I was only getting this error when run in CI (devops pipelines) and not local, and my theory is the error occurs due to a slow virtual machine as the app doesn't become "stable" quick enough.)

Related