This method runs after every test completes. Be careful if a subclass of BaseCase overrides setUp(). If so, add the following line to the subclass's tearDown() method: super().tearDown()
(self)
| 17265 | stopTestRun() |
| 17266 | |
| 17267 | def tearDown(self): |
| 17268 | """This method runs after every test completes. |
| 17269 | Be careful if a subclass of BaseCase overrides setUp(). |
| 17270 | If so, add the following line to the subclass's tearDown() method: |
| 17271 | super().tearDown() """ |
| 17272 | if not hasattr(self, "_using_sb_fixture") and self.__called_teardown: |
| 17273 | # This test already called tearDown() |
| 17274 | return |
| 17275 | if getattr(self, "recorder_mode", None): |
| 17276 | page_actions._reconnect_if_disconnected(self.driver) |
| 17277 | try: |
| 17278 | self.__process_recorded_actions() |
| 17279 | except Exception as e: |
| 17280 | print("\n (Recorder) Code-generation exception:") |
| 17281 | if hasattr(e, "msg"): |
| 17282 | print("\n" + str(e.msg)) |
| 17283 | else: |
| 17284 | print(e) |
| 17285 | self.__called_teardown = True |
| 17286 | self.__called_setup = False |
| 17287 | try: |
| 17288 | is_pytest = self.is_pytest # This fails if overriding setUp() |
| 17289 | if is_pytest: |
| 17290 | with_selenium = self.with_selenium |
| 17291 | except Exception: |
| 17292 | sub_class_name = ( |
| 17293 | str(self.__class__.__bases__[0]).split(".")[-1].split("'")[0] |
| 17294 | ) |
| 17295 | sub_file_name = str(self.__class__.__bases__[0]).split(".")[-2] |
| 17296 | sub_file_name = sub_file_name + ".py" |
| 17297 | class_name = str(self.__class__).split(".")[-1].split("'")[0] |
| 17298 | file_name = str(self.__class__).split(".")[-2] + ".py" |
| 17299 | class_name_used = sub_class_name |
| 17300 | file_name_used = sub_file_name |
| 17301 | if sub_class_name == "BaseCase": |
| 17302 | class_name_used = class_name |
| 17303 | file_name_used = file_name |
| 17304 | message = ( |
| 17305 | "You're overriding SeleniumBase's BaseCase setUp() " |
| 17306 | "method with your own setUp() method, which breaks " |
| 17307 | "SeleniumBase. You can fix this by going to your " |
| 17308 | "%s class located in %s, and adding the " |
| 17309 | "following line AT THE BEGINNING of your " |
| 17310 | "setUp() method:\nsuper().setUp()\n\n" |
| 17311 | "Also make sure the following line is AT THE END " |
| 17312 | "of your tearDown() method:\nsuper().tearDown()\n" |
| 17313 | % (class_name_used, file_name_used) |
| 17314 | ) |
| 17315 | raise Exception(message) |
| 17316 | # *** Start tearDown() officially *** |
| 17317 | if hasattr(self.driver, "_already_quit") and self.driver._already_quit: |
| 17318 | logging.warning( |
| 17319 | " The driver was already quit in a mode" |
| 17320 | " that quits the driver automatically." |
| 17321 | ) |
| 17322 | page_actions._reconnect_if_disconnected(self.driver) |
| 17323 | self.__slow_mode_pause_if_active() |
| 17324 | has_exception = self.__has_exception() |
no test coverage detected