use setUpClass&tearDownClass #1240
              
                
                  
                  
                    Answered
                  
                  by
                    mdmintz
                  
              
          
                  
                    
                      c350147221
                    
                  
                
                  asked this question in
                Q&A
              
            -
| hi, class framework_test(BaseCase):  | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            mdmintz
          
      
      
        Mar 2, 2022 
      
    
    Replies: 2 comments 1 reply
-
| If you want to customize  Example: from seleniumbase import BaseCase
class BaseTestCase(BaseCase):
    def setUp(self):
        super(BaseTestCase, self).setUp()
        # <<< Run custom setUp() code for tests AFTER the super().setUp() >>>
    def tearDown(self):
        self.save_teardown_screenshot()
        if self.has_exception():
            # <<< Run custom code if the test failed. >>>
            pass
        else:
            # <<< Run custom code if the test passed. >>>
            pass
        # (Wrap unreliable tearDown() code in a try/except block.)
        # <<< Run custom tearDown() code BEFORE the super().tearDown() >>>
        super(BaseTestCase, self).tearDown()
    def login(self):
        # <<< Placeholder. Add your code here. >>>
        # Reduce duplicate code in tests by having reusable methods like this.
        # If the UI changes, the fix can be applied in one place.
        pass
    def example_method(self):
        # <<< Placeholder. Add your code here. >>>
        pass
class MyTests(BaseTestCase):
    def test_example(self):
        self.login()
        self.example_method() | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        mdmintz
-
| sir,I want to use this way to run case,How should I handle? class framework_test(driver_handler):  | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
If you want to customize
setUp()andtearDown(), do it like this:https://github.com/seleniumbase/SeleniumBase/blob/master/examples/boilerplates/base_test_case.py
Example: