I solved it by making two functions to check different fields but I i'm not sure why it worked and I also don't like it , why make two functions when you can create one with the same functionality.
def checkTrapTransaction():
try:
logUtb(f, 'Checking if Transaction type is trapped, making payment with Transaction type as empty')
browser.find_by_id('submitBtn').first.click()
alert = browser.get_alert()
x = str(alert.text)
if x == 'Transaction Type is required.':
logUtb(f, 'Transaction Type input is trapped')
alert.accept()
logUtb(f, "")
except:
logUtbE(f, "Exception: Please recheck your code")
def checkTrapEmail():
try:
logUtb(f, 'Checking if email is a valid email')
browser.select('tranType','A')
browser.find_by_id('submitBtn').first.click()
alert = browser.get_alert()
x = str(alert.text)
if x == 'Please enter a valid email address.':
logUtb(f, 'Proper email format is trapped')
alert.accept()
logUtb(f, "")
except:
logUtbE(f, "Exception: Please recheck your code")
If you guys have other solutions to this problem, i'm open to suggestions as I don't like the fix I just made. Thanks