reactjs - Testcafe - 单击按钮后如何获取更新状态值
问题描述
我是测试世界的新手。我正在使用 testcafe 进行自动化。我正在测试简单的计数器按钮。每当单击按钮时,计数器就会增加。现在我得到以前的值而不是更新值。
我将“超时”作为断言 api 中的选项传递
import { ReactSelector } from "testcafe-react-selectors";
export default class counterButton {
constructor() {
this.counterButton = ReactSelector("CardButton");
this.button = this.counterButton.find("button");
}
async clickButton(t) {
await t.click(this.button);
}
async checkingState(t) {
const button = this.counterButton;
const buttonReact = await button.getReact();
await this.clickButton(t);
await t.expect(buttonReact.state).eql(1,undefined,{timeout:50000});
}
}
我没有以前的状态值,我想从状态中更新值。
解决方案
如果没有证明问题的工作示例,很难给出准确的答案。从代码中,我看到您首先获得了按钮状态,然后才单击按钮。我想您只需要在单击后获取按钮状态。
推荐阅读
- javascript - 如何使用 Material UI React 显示菜单列表中的哪个项目被选中?
- emacs - Emacs 奇怪的行移动
- ruby-on-rails - 在 Rails 5 中使用不同的 redis 存储进行会话和缓存
- visualization - 如何可视化纵向数据?
- mysql - 无法在 Linux 上设置对 MySQL 服务器的远程访问
- python - 为什么当我复制网络权重时它在 Pytorch 中,它会在反向传播后自动更新?
- php - 如何从 URL 中删除 id
- python - python pandas情节系列matplotlib
- android - 在 Windows 上启动 Android 模拟器
- python-3.x - 使用 Python 3 脚本的建议