gpt4 book ai didi

testing - 排毒 - 启用时点击按钮

转载 作者:行者123 更新时间:2023-11-28 20:50:44 26 4
gpt4 key购买 nike

在使用 Detox 进行测试时,我在按钮上执行 tap() 时遇到问题。

<Button style={this._loginButtonDisabled() ? {} : styles.loginButtonActive}
disabled={this._loginButtonDisabled()}
onPress={this.logInClick}
testID='logInButton'>
<Text style={styles.loginButtonText}>Log In</Text>
</Button>

我们的测试看起来像这样:

const emailInput = element(by.id('emailInput'));
await emailInput.replaceText('idontexist@myeatclub.com');

const passwordInput = element(by.id('passwordInput'));
await passwordInput.replaceText('password');

await element(by.id('logInButton')).tap();

按钮始终可见,但只有在表单字段中输入文本后才会启用(“可点击”)。所以上面的代码在按钮启用之前点击按钮,导致没有实际操作。我想做的是等到按钮启用,然后执行点击。

处理此类情况的建议方法是什么?我在文档中找不到任何好的示例。

最佳答案

我认为这是因为您正在使用 replaceText

尝试使用 typeText

像这样:

const emailInput = element(by.id('emailInput'));
await emailInput.replaceText('idontexist@myeatclub.com');

const passwordInput = element(by.id('passwordInput'));
// \n is used to press the return key on keyboard
await passwordInput.typeText('password\n');

await element(by.id('logInButton')).tap();

关于testing - 排毒 - 启用时点击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48308169/

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