Home > Enterprise >  Element doesn't have inner text in DOM, how to get that value?
Element doesn't have inner text in DOM, how to get that value?

Time:06-18

That's an example of such element

How is it possible to get that 99 value during testing? I'm using playwright and anything like innerText(), textContent(),

await expect(page.locator(element)).toHaveText('99')  //OR
await expect(page.locator(element).innerText()).toBe('99')

don't work at all, and its fully logically, I think these methods should get the value from elements like that

CodePudding user response:

You have to check the presence of value for this.

await expect(page.locator(element)).toHaveValue('99')
  • Related