简体   繁体   中英

TestCafe Typescript - how to assert the value of a disabled html input element?

TestCafe Typescript - how to assert the value of a disabled HTML input element?

The element is disabled to avoid interaction by the end user. However, I would like to check that this element contains the expected value.

example
  public async checksomething(text: string) {
    const inputElement = this.inputSelector();
    await t
      .click(this.someDiv())
      .expect(inputElement().value)
      .contains(text);
  }

I tried to reproduce your usage scenario in the following sample:

<input type="text" value="12345" disabled="disabled"/>
async function checksomething (t, text) {
    const inputElement = Selector('input');
    await t
        .expect(inputElement().value)
        .contains(text);
}

test(`test`, async t => {
    await checksomething(t, '12345');
});

Everything works as expected. There is no error. Please take a look at the this.someDiv element. Check if it is visible. If it does not help, please share your sample to reproduce the issue on my machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM