← Back to Discord Forum

cypress to playwright

const items = await page.locator('input[data-cypress-id="FIELD"]').all()
for (const item of items) {
  await expect(item).toHaveAttribute('data-error', 'true');

This thread is trying to answer question "How can we clear and type into input fields using Playwright?"

5 replies

sorry to ask I'm new to playwright

cy.get('input[data-cypress-id="FIELD"]').each($el => { cy.wrap($el).should('be.empty'); }); cy.get('input[data-cypress-id="FIELD"]').each($el => { cy.wrap($el).type('0'); });

sorry to ask I'm new to playwright[09:50]using map function we can achieve this

const elements = await page.locator('input[data-cypress-id="FIELD"]').all(); await Promise.all(elements.map(async ($el) => $el.clear)); await Promise.all(elements.map(async ($el) => $el.type('0')));

Thankyou so much

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.