Skip to content
CodeKruPro

Assert the text you just read

Automation taskEasyPython only

Interviewers often say: "Your script prints the value. Where is the test?" A check needs an assert (a statement that fails the test when a condition is false) with a clear message when the text is wrong, so a failure explains itself in the report. Here you click a button, then assert that its new text is the expected one before printing it.

Assert the Text You Just Read

Assert the Text You Just Read

assert stops the script when a condition is false. Use it after you have read the text the page shows.

Task:

  1. Click #leftClick
  2. Assert that its text is I was left-clicked!
  3. Print that text

Print the lines below exactly.

Expected output:

After: I was left-clicked!