【发布时间】:2019-07-19 11:21:32
【问题描述】:
我在我的 react-native 项目中使用 Detox,并想在登录屏幕上输入一个名称,但 detox 无法识别 textInput。 这是我的文本代码
describe('SCA', () => {
beforeEach(async () => {
await device.reloadReactNative();
});
it('should have splash screen', async () => {
await expect(element(by.id('splash'))).toBeVisible();
});
it('should show login screen', async () => {
await waitFor(element(by.id('login'))).toBeVisible();
});
it('test login screen name input', async () => {
await element(by.id('name')).typeText('Liam')
});
});
文本输入代码:
<TextInput
testID="name"
style={styles.input}
onChangeText={value => this.setState({ name: value }) }
placeholder={'Name ... '}
placeholderTextColor='white'
value={name} />
这是我得到的错误:
● SCA › test login screen name input
Failed: [Error: Error: Cannot find UI element.
Exception with Action: {
"Action Name": "Type 'Liam'",
"Element Matcher": "((!(kindOfClass('RCTScrollView')) && (respondsToSelector(accessibilityIdentifier) && accessibilityID('name'))) || (((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches(kindOfClass('RCTScrollView'))) && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches((respondsToSelector(accessibilityIdentifier) && accessibilityID('name'))))))",
"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"
}
]
【问题讨论】:
标签: javascript ios react-native jestjs detox