How to check the toast message in Playwright?

204 Views Asked by At

I am a newbie for automation tool, having no coding skills so please guide me as clearly as you can.

I am using Playwright (Typescript) to perform automation testing for a basic website and I have trouble to verify the "toast message".

enter image description here

  1. I need to know the way to get Xpath of toast message for Playwright Typescript. Currently, the Developer gave me this: //ngb-alert//pre/text()'

But how to make sure that it is correct?

  1. Was it exact when I used the assertion "toContainText" to check the toast message? If not, which one should be use for this case ?

enter image description here

1

There are 1 best solutions below

7
Ketan Pardeshi On

You are comparing locator with string. You need to use locator.innerText() to get text from the control and then need to verify.

await expect(locator.innerText()).toContainText('"Ikariam" was created successfully.');