Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to check the presence of value for this.

await expect(page.locator(element)).toHaveValue('99')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading