QA Wolf logo

QA Wolf

/

Star

2.8k

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("https://www.qawolf.com/playground/editable-list");
// store existing item value
var value = await getValue(page, '[aria-label="grocery-2"] p');
// edit item value
await page.click('[aria-label="edit item 2"]');
var editedValue = "Gummy bears";
await page.fill('[placeholder="Edited item"]', editedValue);
await page.click('[aria-label="Save"]');
// 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' });