QA Wolf logo

QA Wolf




Get a Value

In this example, we get an element value in our test with the getValue helper.

Feel free to copy and run this example yourself!

const { context } = await launch();
const page = await context.newPage();
await page.goto("");
// store existing item value
var value = await getValue(page, '[aria-label="grocery-2"] p');
// edit item value
await'[aria-label="edit item 2"]');
var editedValue = "Gummy bears";
await page.fill('[placeholder="Edited item"]', editedValue);
// store new item value
var value2 = await getValue(page, '[aria-label="grocery-2"] p');
// assert new value is different than original value
assert(value2 !== value);
// assert new value matches edited value
assert(value2 === editedValue);
// assert new value is present in list
await assertText(page, editedValue, { selector: '[aria-label="grocery-2"] p' });