4

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

我正在使用这里描述的非常基本的设置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应该支持的元素有关。

任何帮助将非常感激。

4

0 回答 0