Skip to content
CodeKruPro

Type into a text field and read the value back

Automation taskEasyAsked in: Accenture, Capgemini

"Type a name into the field and prove it is there." Typed text is stored in the field's current value, not in its visible text, so read the value attribute. Reading the text of an input gives an empty string.

Type Text with sendKeys()

Type Text with sendKeys()

The sendKeys() method types text into input fields. Use getAttribute("value") to read back what was typed.

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Find the first name field (ID: firstName)
  3. Type Selenium using sendKeys()
  4. Read the value back and print it

Expected output:

Entered: Selenium
Read full tutorial on Codekru