microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.89k stars 3.59k forks source link

[BUG] Bootstrap 'toggle' switch is not checkable #22993

Closed vomc closed 1 year ago

vomc commented 1 year ago

System info

Source code

I have a basic bootstrap 'switch' toggle element that is not 'checkable' using PW. It looks like this when it renders and comes out of a CustomInput provided by react-strap which uses Bootstrap4

Screenshot 2023-05-12 at 14 31 28

The underlying HTML for it ends up being this

<input type="checkbox" id="foo" name="someName" class="custom-control-input">

I have tried the following below but PW times out after trying for 50 times to check the toggle

await page.locator('#foo').setChecked(true)
await page.locator('#foo').check()
await page.locator('#foo').click()

If I change the toggle to become not a switch but a regular checkbox, then the HTML changes to

<input id="foo" name="someName" label="My Label" type="checkbox" class="form-check-input">

Then PW has no problem checking the checkbox.

Is it possible to also use PW to 'check' toggle elements (that are just checkboxes under the hood) or is that not supported?

vomc commented 1 year ago

Found a different way to do this

Ralkage commented 8 months ago

Found a different way to do this

How did you figure this one out? I'm currently having troubles interacting with Bootstrap checkboxes :/