← Back to Discord Forum

Target Closed on edit

I'm testing a form in an application which gets redrawn whenever values are edited. The relevant code currently looks like this

await expect(page.locator('input[name="system\\.treason_stars\\.value"]')).toHaveValue('0');
    await page.locator('input[name="system\\.treason_stars\\.value"]').fill('');
    await page.locator('input[name="system\\.treason_stars\\.value"]').fill('5');
    await expect(page.locator('input[name="system\\.treason_stars\\.value"]')).toHaveValue('5');

however, when I do fill(), it redraws the application. this causes the next step to fail with "Target Closed". what's the best way to handle this?

This thread is trying to answer question "What is the best way to handle the 'Target Closed' error encountered after using the `fill()` function in an application that gets redrawn whenever values are edited?"

2 replies

any thoughts on what I'm doing wrong here?

it might be doing a navigation. do a wait for navigation after every fill

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.