@@ -14010,6 +14010,9 @@ def __activate_standard_virtual_display(self):
1401014010 if not self.undetectable:
1401114011 sb_config._virtual_display = self._xvfb_display
1401214012 sb_config.headless_active = True
14013+ if self._reuse_session and hasattr(sb_config, "_vd_list"):
14014+ if isinstance(sb_config._vd_list, list):
14015+ sb_config._vd_list.append(self._xvfb_display)
1401314016
1401414017 def __activate_virtual_display(self):
1401514018 if self.undetectable and not (self.headless or self.headless2):
@@ -14034,6 +14037,9 @@ def __activate_virtual_display(self):
1403414037 self.__activate_standard_virtual_display()
1403514038 else:
1403614039 self.headless_active = True
14040+ if self._reuse_session and hasattr(sb_config, "_vd_list"):
14041+ if isinstance(sb_config._vd_list, list):
14042+ sb_config._vd_list.append(self._xvfb_display)
1403714043 except Exception as e:
1403814044 if hasattr(e, "msg"):
1403914045 print("\n" + str(e.msg))
@@ -14088,7 +14094,7 @@ def __activate_virtual_display_as_needed(self):
1408814094 """This is only needed on Linux.
1408914095 The "--xvfb" arg is still useful, as it prevents headless mode,
1409014096 which is the default mode on Linux unless using another arg."""
14091- if "linux" in sys.platform and (not self.headed or self.xvfb):
14097+ if is_linux and (not self.headed or self.xvfb):
1409214098 pip_find_lock = fasteners.InterProcessLock(
1409314099 constants.PipInstall.FINDLOCK
1409414100 )
@@ -16605,7 +16611,11 @@ def tearDown(self):
1660516611 # (Pynose / Behave / Pure Python) Close all open browser windows
1660616612 self.__quit_all_drivers()
1660716613 # Resume tearDown() for all test runners, (Pytest / Pynose / Behave)
16608- if hasattr(self, "_xvfb_display") and self._xvfb_display:
16614+ if (
16615+ hasattr(self, "_xvfb_display")
16616+ and self._xvfb_display
16617+ and not self._reuse_session
16618+ ):
1660916619 # Stop the Xvfb virtual display launched from BaseCase
1661016620 try:
1661116621 if hasattr(self._xvfb_display, "stop"):
@@ -16620,6 +16630,13 @@ def tearDown(self):
1662016630 hasattr(sb_config, "_virtual_display")
1662116631 and sb_config._virtual_display
1662216632 and hasattr(sb_config._virtual_display, "stop")
16633+ and (
16634+ not hasattr(sb_config, "reuse_session")
16635+ or (
16636+ hasattr(sb_config, "reuse_session")
16637+ and not sb_config.reuse_session
16638+ )
16639+ )
1662316640 ):
1662416641 # CDP Mode may launch a 2nd Xvfb virtual display
1662516642 try:
0 commit comments