I am making a login page in which I have to cover all the login test scenarios. I am am validating all type of input the user is putting, but the problem is when a while condition handles one test condition, that same while condition is not repeated if the same test condition occurs again if the user puts the same input after another. Here is my code:
import re
userDetails=[]
accountDetails= {"FirstName": "Ajay", "LastName": "Kumar","DateOfBirth":"24-07-1992","Account Number":"4242342345234","Balance Currency":"Rs","Balance Amount":"5000"}
specialCharacters = re.compile('[@_!#$%^&*()<>?/\|}{~:]')
firstName=str(input("Enter First Name"))
while True:
if firstName=="":
print("Name cannot be blank")
firstName=str(input("Enter First Name"))
while True:
if firstName.isdigit():
print("Name cannot be in digits")
firstName=str(input("Enter First Name"))
while True:
if specialCharacters.search(firstName) != None:
print("Please don't enter special characters")
firstName=str(input("Enter First Name"))
while True:
if firstName!=accountDetails.get("FirstName"):
print("The account does not exist with the given details, please try again")
print("Enter valid first name")
firstName=str(input("Enter First Name"))
else:
userDetails.append(firstName)
Aucun commentaire:
Enregistrer un commentaire