1

I have tried some functions in playwright js, such as innerText, textContent.

What I got is the plain text instead of the text in the text area.

I tried to find these innertext in browser inspect, and I cannot find any...

The following is the js code and the screenshot of my problem.

The Screenshot

What I got in the console

    console.log(await page.locator("(//div[@class='p-card p-component'])[1]").innerText())

Can anyone provide me with some inspirations? I've nearly found every ways but none of them can solve my problem.

YOMA LIM
  • 11
  • 1
  • 1
    *innerText* isn't a function, it's a property. Anyway, likely you need the value property as *textArea* elements don't have either *innerText* or *textContent* (which are more or less the same thing). [*This answer*](https://stackoverflow.com/a/19032002/257182) might help to clear things up. – RobG Jul 20 '23 at 09:23
  • @RobG Thank you for your reply! I am still a novice in JS. Then how do I see these text, now that they are neither innerText or textContent. – YOMA LIM Jul 20 '23 at 09:30
  • `.inputValue()` https://playwright.dev/docs/api/class-locator#locator-input-value – candre Jul 20 '23 at 20:36
  • I was commenting on the *innerText* and *textContent* properties of HTML elements. In Playwright, the *locator* object returned by *page.locator* has methods that return the value of similarly named DOM properties, so *locator(…).textContent()* returns the matched element's textContent. As @candre says, you can get the value of input, textArea and select elements with the *inputValue* method. – RobG Jul 21 '23 at 07:51

0 Answers0