Try-except doesn't work as intended (failing my try on purpes but it doesnt do the except) #2173
-
| I'm not sure if this problem is a SB problem but I'll try anyway. I have this code:             try: and I fail on purpes this line self.send_keys(fn.FieldsNames.department_html, random_department) instead of random_department I wrote "fail test" but my code doesnt fail (or raising exception) so it kinda passes above the except and continues to run the code. what could be the problem. | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| That looks like a Python question and not a SeleniumBase one. (Also, your code should be formatted as code with proper line indentation so that it makes sense.) Here's how a try/except block works: try:
    raise Exception("Fail!")
except Exception:
    print("Caught!")After the exception is caught in the  | 
Beta Was this translation helpful? Give feedback.
That looks like a Python question and not a SeleniumBase one. (Also, your code should be formatted as code with proper line indentation so that it makes sense.)
Here's how a try/except block works:
After the exception is caught in the
tryblock, the program continues from theexceptblock.