7
7
from selenium .webdriver .remote .errorhandler import NoAlertPresentException
8
8
from selenium .webdriver .remote .errorhandler import NoSuchFrameException
9
9
from selenium .webdriver .remote .errorhandler import NoSuchWindowException
10
+ from seleniumbase .common .exceptions import NoSuchFileException
11
+ from seleniumbase .common .exceptions import TimeLimitExceededException
10
12
from seleniumbase import config as sb_config
11
13
12
14
@@ -15,27 +17,48 @@ def format_exc(exception, message):
15
17
Formats an exception message to make the output cleaner.
16
18
"""
17
19
if exception == Exception :
18
- pass
20
+ exc = Exception
21
+ return exc , message
19
22
elif exception == ElementNotVisibleException :
20
- message = "ElementNotVisibleException: %s" % message
23
+ exc = ElementNotVisibleException
24
+ elif exception == "ElementNotVisibleException" :
25
+ exc = ElementNotVisibleException
21
26
elif exception == NoSuchElementException :
22
- message = "NoSuchElementException: %s" % message
27
+ exc = NoSuchElementException
28
+ elif exception == "NoSuchElementException" :
29
+ exc = NoSuchElementException
23
30
elif exception == NoAlertPresentException :
24
- message = "NoAlertPresentException: %s" % message
31
+ exc = NoAlertPresentException
32
+ elif exception == "NoAlertPresentException" :
33
+ exc = NoAlertPresentException
25
34
elif exception == NoSuchFrameException :
26
- message = "NoSuchFrameException: %s" % message
35
+ exc = NoSuchFrameException
36
+ elif exception == "NoSuchFrameException" :
37
+ exc = NoSuchFrameException
27
38
elif exception == NoSuchWindowException :
28
- message = "NoSuchWindowException: %s" % message
39
+ exc = NoSuchWindowException
40
+ elif exception == "NoSuchWindowException" :
41
+ exc = NoSuchWindowException
42
+ elif exception == "NoSuchFileException" :
43
+ exc = NoSuchFileException
29
44
elif type (exception ) is str :
45
+ exc = Exception
30
46
message = "%s: %s" % (exception , message )
47
+ return exc , message
31
48
else :
32
- pass
49
+ exc = Exception
50
+ return exc , message
51
+ message = _format_message (message )
52
+ return exc , message
53
+
54
+
55
+ def _format_message (message ):
56
+ message = "\n " + message
33
57
return message
34
58
35
59
36
60
def __time_limit_exceeded (message ):
37
- raise Exception (
38
- "TimeLimitExceeded: %s" % message )
61
+ raise TimeLimitExceededException (message )
39
62
40
63
41
64
def check_if_time_limit_exceeded ():
@@ -52,4 +75,5 @@ def check_if_time_limit_exceeded():
52
75
message = (
53
76
"This test has exceeded the time limit of %s second%s!"
54
77
"" % (display_time_limit , plural ))
78
+ message = _format_message (message )
55
79
__time_limit_exceeded (message )
0 commit comments