gpt4 book ai didi

react-native - Appium React Native 尚未准备好进行文本输入

转载 作者:行者123 更新时间:2023-12-04 08:58:34 24 4
gpt4 key购买 nike

我最近切换到 Appium + webdriverIO 进行 E2E 测试。除了一个与文本输入相关的测试用异常(exception),一切都运行良好。
基本上,被测组件是一个使用 redux-form 进行表单管理的登录屏幕。我不断收到错误 "'"login-field" Other' is not ready for a text input. Neither the accessibility element itself nor its accessible descendants have the input focus" .组件如下:SignInScreen.tsx

export class SignInScreen extends React.Component<any> {
render() {
const { handleSubmit, submitting, style } = this.props;
return (
<View style={style}>
<View>
<View>
<Field
name="login"
component={Input}
accessibilityLabel="login-field"
testID="login-field"
/>
<Field
secureTextEntry
name="password"
component={Input}
accessibilityLabel="password-field"
testID="password-field"
/>
</View>
</View>
</View>
);
}
}
Input.tsx
export class Input extends React.Component {
render() {
const {
input,
meta: { error, active, focused },
accessibilityLabel,
testID
} = this.props;

const showError = !active && !!error && !focused;
const errorText = "ERROR!"

return (
<View style={[style, styles.container]}>
<TextInput
autoCapitalize="none"
value={input.value}
onChangeText={input.onChange}
onFocus={input.onFocus}
onBlur={input.onBlur}
accessibilityLabel={accessibilityLabel},
testID={testID}
/>

<View style={{height: 30}}>
{showError && (
<Text>{errorText}</Text>
)}
</View>
</View>
);
}
}
SignInScreen.test.ts
describe('Sign In Screen Test', () => {
let client;

beforeAll(async () => {
// set up code
});

afterAll(async () => {
// tear down code
});

it('Can login', async () => {
const loginField = await client.$('~login-field');
await loginField.setValue('test@gmail.com'); // error here

const passwordField = await client.$('~password-field');
await passwordField.set('password' + '\n');
});
});
当我添加一个额外的 <TextInput /> 时,我确实意识到测试用例可以工作。在现有 <TextInput /> 之上 Input.tsx 中的组件组件如下: Input.tsx
export class Input extends React.Component {
render() {
const {
input,
meta: { error, active, focused },
accessibilityLabel,
testID
} = this.props;

const showError = !active && !!error && !focused;
const errorText = "ERROR!"

return (
<View style={[style, styles.container]}>
<TextInput />
<TextInput
autoCapitalize="none"
value={input.value}
onChangeText={input.onChange}
onFocus={input.onFocus}
onBlur={input.onBlur}
accessibilityLabel={accessibilityLabel},
testID={testID}
/>

<View style={{height: 30}}>
{showError && (
<Text>{errorText}</Text>
)}
</View>
</View>
);
}
}
或者我删除 View 中的固定高度嵌套错误消息的组件如下: Input.tsx
export class Input extends React.Component {
render() {
const {
input,
meta: { error, active, focused },
accessibilityLabel,
testID
} = this.props;

const showError = !active && !!error && !focused;
const errorText = "ERROR!"

return (
<View style={[style, styles.container]}>
<TextInput
autoCapitalize="none"
value={input.value}
onChangeText={input.onChange}
onFocus={input.onFocus}
onBlur={input.onBlur}
accessibilityLabel={accessibilityLabel},
testID={testID}
/>

<View>
{showError && (
<Text>{errorText}</Text>
)}
</View>
</View>
);
}
}
那么什么给呢?我真的不知道是什么导致 Appium 在没有进行上述调整的情况下无法获取输入焦点。

最佳答案

我相信这是 Appium 最近的一个错误 - https://github.com/appium/java-client/issues/1386

关于react-native - Appium React Native 尚未准备好进行文本输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63683916/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com