6
6
Usage --> ``with SB() as sb:``
7
7
Usage example -->
8
8
from seleniumbase import SB
9
- with SB() as sb: # Lots of args! ( Eg. headless=True )
9
+ with SB() as sb: # Many args! Eg. SB(browser="edge" )
10
10
sb.open("https://google.com/ncr")
11
11
sb.type('[name="q"]', "SeleniumBase on GitHub\n ")
12
12
sb.click('a[href*="github.com/seleniumbase"]')
@@ -109,10 +109,12 @@ def SB(
109
109
from seleniumbase import BaseCase
110
110
from seleniumbase import config as sb_config
111
111
from seleniumbase .config import settings
112
+ from seleniumbase .core import colored_traceback
112
113
from seleniumbase .fixtures import constants
113
114
from seleniumbase .fixtures import shared_utils
114
115
115
116
sb_config_backup = sb_config
117
+ sb_config ._do_sb_post_mortem = False
116
118
sys_argv = sys .argv
117
119
archive_logs = False
118
120
existing_runner = False
@@ -753,6 +755,7 @@ def SB(
753
755
sb .headless_active = False
754
756
test_name = None
755
757
terminal_width = shared_utils .get_terminal_width ()
758
+ colored_traceback .add_hook ()
756
759
if test :
757
760
import colorama
758
761
import os
@@ -787,6 +790,11 @@ def SB(
787
790
sb .setUp ()
788
791
test_passed = True # This can change later
789
792
teardown_exception = None
793
+ if "--trace" in sys_argv :
794
+ import pdb
795
+
796
+ pdb .set_trace () # Debug Mode
797
+ # Type "s" and press [Enter] to step into "yield sb".
790
798
try :
791
799
yield sb
792
800
except Exception as e :
@@ -803,8 +811,10 @@ def SB(
803
811
sb .cm_filename = filename
804
812
except Exception :
805
813
sb .cm_filename = None
806
- # Tests will raise an exception later if " raise_test_failure"
814
+ # Tests will raise an exception if raise_test_failure is True
807
815
finally :
816
+ if sb ._has_failure and "--pdb" in sys_argv :
817
+ sb_config ._do_sb_post_mortem = True
808
818
try :
809
819
sb .tearDown ()
810
820
except Exception as t_e :
@@ -821,7 +831,7 @@ def SB(
821
831
sb_config ._context_of_runner = True
822
832
if test_name :
823
833
result = "passed"
824
- if not test_passed :
834
+ if test and not test_passed :
825
835
result = "failed"
826
836
c1 = colorama .Fore .RED
827
837
end_text = (
@@ -840,7 +850,7 @@ def SB(
840
850
left_space = left_spaces * "="
841
851
right_spaces = remaining_spaces - left_spaces
842
852
right_space = right_spaces * "="
843
- if not test_passed :
853
+ if test and not test_passed :
844
854
print (the_traceback )
845
855
if not test_name .startswith ("runpy.py:" ):
846
856
print (
0 commit comments