Skip to content
CodeKruPro

Clear Fields and Get Inner HTML

20/70

Clear Fields and Get Inner HTML

locator.clear() clears the contents of an input field. locator.innerHTML() returns the inner HTML markup of an element.

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Get the pre-filled field (ID: preFilledTextField)
  3. Print its value
  4. Clear the field
  5. Print its value after clearing
  6. Get the innerHTML of the page heading h2

Expected output:

Before clear: Codekru
After clear: 
Heading HTML: Text Fields