Modify DOM with JavaScript
page.evaluate can modify the DOM. You can change styles, content, or attributes from Node.js.
Task:
- Navigate to
https://testkru.com/Elements/TextFields - Use
page.evaluateto change the value of#lastNameWithPlaceholderto "Modified" - Read the value back using Playwright's
inputValue() - Use evaluate to change the h2 heading text to "Changed Title"
- Print the new heading text
Expected output:
Modified value: Modified New heading: Changed Title
TestKru