Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Automated Test Script for Web Forms
00:00
5 left

Automated Test Script for Web Forms

EasyPython

Problem

Write a simple test script for validating a web form submission.

Implement validate_form_submission(form) to validate a form containing name, email, password, and terms_accepted. Return a list of error codes in the required order: name_required, email_invalid, password_invalid, and terms_required. Return an empty list when all fields are valid.

Rules: name must be non-empty after trimming, email must contain one @ with non-empty parts and a dot in the domain, password must be at least eight characters with an uppercase letter, lowercase letter, and digit, and terms_accepted must be True.

Constraints

  • form is a dictionary
  • The fields name, email, password, and terms_accepted may be missing
  • Return errors in the exact order: name, email, password, terms
  • Email validation only needs to enforce the stated structural rules, not full RFC email syntax

Function Signature

def validate_form_submission(form):
Interviewer

Your question is Automated Test Script for Web Forms. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.