xxxxxxxxxx
// Click on button with name On inside div
const btn = await page.locator('div').getByRole('button', { name: 'On' });
xxxxxxxxxx
await page.getByLabel('Title').click();
// Otherwise if desired to ensure element is enabled follow may help
if (await page.locator('modal-selector').isEnabled()) {
await page.click('button1')
} else {
//do something
}