5

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

Barak
  • 654
  • 13
  • 30
  • Did you find any solution for this? – SGR Oct 28 '20 at 13:22
  • @SGR Yes, I gave to other View the testID and then It works, so if you have other Views try to give them and see the result, another option is to try to give more height and width to the elements I don't know why but it helps him to make it visible. Make sure you get the right index, some time you try to get the wrong 'atIndex' Good Luck :) – Barak Oct 28 '20 at 13:28
  • I am struggling with the same error for very simple test. Locally it works, but it does not work on Circle CI. What emulator do you use ? – Piotr Badura Apr 06 '21 at 13:26
  • @Piotr Badura , device: { type: 'iPhone 11', }, iOS 13.5 but the latest version of iOS works for my team also – Barak Apr 11 '21 at 07:50

2 Answers2

0

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.

Piotr Badura
  • 1,574
  • 1
  • 13
  • 17
0

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.)

badsyntax
  • 9,394
  • 3
  • 49
  • 67