Skip to content
CodeKruPro

Fix a locator that does not exist

Automation taskEasyPython onlyAsked in: Accenture, TCS, Wipro

A common live task: "Here is a script that fails. Fix it." Read the traceback (the error report Python prints) from the bottom, see that the id is not on the page, and use the real one. Retrying or waiting longer for a wrong locator never helps.

Fix a Locator That Does Not Exist

Fix a Locator That Does Not Exist

A locator that matches nothing raises NoSuchElementException and the script stops. finally still quits the browser. Change the id to one that is on the page.

Task:

  1. Run the starter and read the traceback
  2. Replace missingField with preFilledTextField
  3. Print the field value

The starter looks up an id that is not on the page. The fix is the real id, not a second try of the same missing id.

Print the lines below exactly.

Expected output:

Value: Codekru