i have the following block of code that checks if the field with id=streetNumber contains either the values 23 or 45 and adds a value depending on what it finds
async function replace(page: Page) {
if (await page.locator('id=streetNumber'), { hasText: "23"}) {
await page.locator('id=streetNumber').fill('45');
}
else {
await page.locator('id=streetNumber').fill('23');
}
}
My problem is that every time it fills in 45, even if instructed to fill in 45 only if 23 is already there and to fill in 23 if anything else is there. What is going wrong here ?