排毒未找到View元素 - 错误:找不到UI元素

时间:2018-04-16 15:37:19

标签: react-native detox

我遇到了排毒问题以找到我试图让它找到的任何元素。到目前为止,我无法找到任何东西。我已按照设置说明进行操作,但出于某种原因,它对我有用。

我正在使用此处所述的基本设置https://github.com/wix/detox/blob/master/docs/Introduction.GettingStarted.md,但出于某种原因,它似乎想为我工作。

组件:

render() {
    return (
        <View testID="MainView">...</View>
    )
}

测试:

describe('Example', () => {
  beforeEach(async () => {
    await device.reloadReactNative();
  });
  it('should have main view', async () => {
    await expect(element(by.id('MainView'))).toExist();
  });
})

错误:

Exception with Assertion: {
    "Assertion Criteria" : "assertWithMatcher:isNotNil",
    "Element Matcher" : "(((respondsToSelector(accessibilityIdentifier) && accessibilityID('MainView')) && !(kindOfClass('RCTScrollView'))) || (kindOfClass('UIScrollView') && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(((respondsToSelector(accessibilityIdentifier) && accessibilityID('MainView')) && kindOfClass('RCTScrollView'))))))",
    "Recovery Suggestion" : "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element."

}

Error Trace: [
    {
        "Description" : "Interaction cannot continue because the desired element was not found.",
        "Error Domain": "com.google.earlgrey.ElementInteractionErrorDomain",
        "Error Code" : "0",
        "File Name" : "GREYElementInteraction.m",
        "Function Name" : "-[GREYElementInteraction matchedElementsWithTimeout:error:]",
        "Line" : "124"
    }
]

我在其他帖子中看到过这个问题,但通常是尝试找到一个不支持testID的元素,但据我所知,View应该有支持。

非常感谢任何帮助。

0 个答案:

没有答案
相关问题