'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.



Solution 1:[1]

You could use a regular expression for your locator:

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christian Baumann