Rayrun
← Back to Discord Forum

Created a form fill test that passed, but no new data has been created. [SOLVED]

I wrote this test using the vscode extension. it passed the test, but no data has been posted, which i would expect to be the result. I'm confused at what I'm doing wrong here.

import { test, expect } from '@playwright/test';

test('test', async ({ page }) => {
  await page.goto('http://localhost:8080/');
  await page.getByRole('button', { name: '+ Create New' }).click();
  await page.getByPlaceholder('“Enter the street name”').click();
  await page.getByPlaceholder('“Enter the street name”').fill('Testing');
  await page.getByPlaceholder('“Enter description”').click();
  await page.getByPlaceholder('“Enter description”').fill('Lorem Ipsum.');
  await page.getByRole('button', { name: 'Post' }).click();

});

This thread is trying to answer question "Why is no new data created even though the form fill test passed?"

12 replies

Created a form fill test that passed, but no new data has been created.

ibrahim.bektas
ibrahim.bektas

in headed mode you see that PW enters all the Input and click on the "Post" button but after the test the data should appear in UI but it isnt? The your wrote seems legit. It does not have any expectation that means if Playwright finds all the Inputs Buttons etc it will passed. You can add validation like if you click on the Post the new data will posted .

yes, i just found out i had to let the page process before closing the test to actually make the form submit. with the following line, i listen to a class to be rendered in the DOM.

await page.waitForSelector('.mild-notice');

the form submission actually gets processed now before it closes the test.

ibrahim.bektas
ibrahim.bektas

and do not forget to write expectations. 🙂 like await expect( page.locator(yourLocator)).isVisible() etc.

cserby_02195

I'd suggest await expect(page.locator('.mild-notice')).toBeVisible()

yes, i figured the right method from the initial mention. thanks for clarifying for others to get it right.

Just wondering if there may not be a bug or in your hast to write the test... Maybe you didn't mention it, User feedback/confirmation 'x' has been saved to the user/web page.... Should trip off of that remove the guess work...

i don't really comprehend your question. but so far the test is complete with addition to the code mentioned in the latter post here.

Assumed from the title "no new data has been created" would assume a submit was sent and data shoudl be saved?

yes, this has been clarified to be working as intended and the additional code, makes the test "complete", i.e. the form data get the time to process, instead of being cut off early.

in other words, the problem has been solved.

Created a form fill test that passed, but no new data has been created. [SOLVED]

Related Discord Threads

TwitterGitHubLinkedIn
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.