Skip to content
Advertisement

How to locate a changing element in playwright? [closed]

I am filling a input-box with verification code, but the text which can locate the input-box is keeping changing, just like “30 seconds later, you can get a new verification code”. The number of seconds is keeping changing. I don’t want to wait the text turn to “Youu can get a new verification code now”.

How can I locate the input-box?

Thanks for your answers.

Advertisement

Answer

You could use a regular expression for your locator:

page.locator(text=/d{1,2}sseconds?slater/i)
Advertisement