I'm trying to automate retrieving form values from an already filled out form with puppeteer and xpath.
I've already automated FILLING a text input field as follows, but doing the reverse with .evaluate() doesn't work:
[fieldHandle] = await page.$x("//label[text() = 'My Label']/../following-sibling::td[1]//input")
await page.evaluate((x, y) => x.value = y, fieldHandle, 'newValue')
This is my most recent attempt - still no success...
let [fieldHandle] = await page.$x("//label[text() = 'My Label']/../following-sibling::td[1]//input")
let fieldRaw = await fieldHandle.getProperty('textContent')
let fieldValue = await fieldRaw.jsonValue()
Hopefully someone out there knows how to achieve this!