MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / setUp

Method setUp

seleniumbase/fixtures/base_case.py:15646–16242  ·  view source on GitHub ↗

This method runs before every test begins. Be careful if a subclass of BaseCase overrides setUp(). If so, add the following line to the subclass setUp() method: super().setUp()

(self, masterqa_mode=False)

Source from the content-addressed store, hash-verified

15644 ############
15645
15646 def setUp(self, masterqa_mode=False):
15647 """This method runs before every test begins.
15648 Be careful if a subclass of BaseCase overrides setUp().
15649 If so, add the following line to the subclass setUp() method:
15650 super().setUp() """
15651 if not hasattr(self, "_using_sb_fixture") and self.__called_setup:
15652 return # This test already called setUp()
15653 self.__called_setup = True
15654 self.__called_teardown = False
15655 self.is_pytest = None
15656 self.log_path = constants.Logs.LATEST
15657 self.masterqa_mode = masterqa_mode
15658 try:
15659 # This raises an exception if the test is not coming from pytest
15660 self.is_pytest = sb_config.is_pytest
15661 except Exception:
15662 # Not using pytest (could be pynose, behave, or raw python)
15663 self.is_pytest = False
15664 if self.is_pytest:
15665 # pytest-specific code
15666 test_id = self.__get_test_id()
15667 self.test_id = test_id
15668 self.is_behave = False
15669 if hasattr(self, "_using_sb_fixture"):
15670 self.test_id = sb_config._test_id
15671 if hasattr(sb_config, "_sb_pdb_driver"):
15672 sb_config._sb_pdb_driver = None
15673 self.browser = sb_config.browser
15674 self.account = sb_config.account
15675 self.data = sb_config.data
15676 self.var1 = sb_config.var1
15677 self.var2 = sb_config.var2
15678 self.var3 = sb_config.var3
15679 variables = sb_config.variables
15680 if variables and isinstance(variables, str) and len(variables) > 0:
15681 import ast
15682
15683 bad_input = False
15684 if (
15685 not variables.startswith("{")
15686 or not variables.endswith("}")
15687 ):
15688 bad_input = True
15689 else:
15690 try:
15691 variables = ast.literal_eval(variables)
15692 if not isinstance(variables, dict):
15693 bad_input = True
15694 except Exception:
15695 bad_input = True
15696 if bad_input:
15697 raise Exception(
15698 '\nExpecting a Python dictionary for "variables"!'
15699 "\nEg. --variables=\"{'KEY1':'VALUE', 'KEY2':123}\""
15700 )
15701 elif isinstance(variables, dict):
15702 pass # Already processed
15703 else:

Callers 1

SBFunction · 0.95

Calls 15

__get_test_idMethod · 0.95
__process_dashboardMethod · 0.95
get_current_urlMethod · 0.95
switch_to_windowMethod · 0.95
openMethod · 0.95
get_new_driverMethod · 0.95
set_time_limitMethod · 0.95
TestcaseManagerClass · 0.90

Tested by

no test coverage detected