I have an Input element with value like '123 456'.
How can I validate that the Input element contains '123' using an Expect?
input_locator = 'input[id="edition"]'
expect(self.page.locator(input_locator).first).
to_have_value('123', timeout=20 * 1000)
I got this error:
selector resolved to <input name="" readonly type="text" id="edition" placeh…/> unexpected value "123 456"
selector resolved to <input name="" readonly type="text" id="edition" placeh…/> unexpected value "123 456"
to_have_value
supports regular expressions. You can do something like this:
expect(self.page.locator(input_locator).first).
to_have_value(re.compile(r"123.+"), timeout=20 * 1000)