Skip to content
CodeKruPro

Modify DOM with JavaScript

61/70

Modify DOM with JavaScript

page.evaluate can modify the DOM. You can change styles, content, or attributes from Node.js.

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Use page.evaluate to change the value of #lastNameWithPlaceholder to "Modified"
  3. Read the value back using Playwright's inputValue()
  4. Use evaluate to change the h2 heading text to "Changed Title"
  5. Print the new heading text

Expected output:

Modified value: Modified
New heading: Changed Title