'Playwright Test - Wait for checkbox / radio button state
I currently have an issue where I need to wait for a checkbox / radio button to be "checked" before I proceed with my testing.
If I assert the checkbox is checked the test fails because it doesn't have the checked state immediately after the action.
How does one go about this through playwright commands. Yes I can add a hardcoded timeout, but I feel like there is a better way.
Solution 1:[1]
It looks like in version 1.21.0 of playwright they have added a polling assertion:
// Poll the method until it returns an expected result.
await expect.poll(async () => {
const response = await page.request.get('https://api.example.com');
return response.status();
}).toBe(200);
Solution 2:[2]
page.isChecked(selector, {timeout:5000})
Maybe this can help.
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 | OrdinaryKing |
| Solution 2 | Gaj Julije |
