Reactjs Testcafe-单击按钮后如何获取更新状态值

Reactjs Testcafe-单击按钮后如何获取更新状态值,reactjs,testing,automation,ui-automation,testcafe,Reactjs,Testing,Automation,Ui Automation,Testcafe,我是测试界的新手。我正在使用testcafe实现自动化。我正在测试简单的计数器按钮。无论何时单击按钮,计数器都会递增。现在我得到的是以前的值,而不是更新值 我在断言api中将“timeout”作为选项传递 import { ReactSelector } from "testcafe-react-selectors"; export default class counterButton { constructor() { this.counterButton = ReactSel

我是测试界的新手。我正在使用testcafe实现自动化。我正在测试简单的计数器按钮。无论何时单击按钮,计数器都会递增。现在我得到的是以前的值,而不是更新值

我在断言api中将“timeout”作为选项传递

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});
  }
}

我不需要状态的前一个值,我需要状态的更新值。

如果没有说明问题的工作示例,很难给出准确的答案。从代码中,我看到您首先获得按钮状态,然后单击按钮。我想您只需要在单击之后才能获得按钮状态。

如果没有演示该问题的工作示例,很难给出准确的答案。从代码中,我看到您首先获得按钮状态,然后单击按钮。我想您只需要在单击后获取按钮状态。

谢谢我知道我首先获取状态,这就是我没有获取更新值的原因。谢谢谢谢谢谢我知道我首先获取状态,这就是我没有获取更新值的原因。谢谢