Optimize driver quit method

This commit is contained in:
zhaoyafan 2025-02-11 22:45:42 +08:00
parent dcc743a3c4
commit b506ac1554
2 changed files with 67 additions and 34 deletions

View File

@ -38,7 +38,7 @@ end;
AppId={{225A7526-BAB4-4DBE-B5F6-9CE1BEACCB36} AppId={{225A7526-BAB4-4DBE-B5F6-9CE1BEACCB36}
AppName={#MyAppName} AppName={#MyAppName}
AppVersion={#MyAppVersion} AppVersion={#MyAppVersion}
AppVerName={#MyAppName} version {#MyAppVersion} AppVerName={#MyAppName} {#MyAppVersion}
VersionInfoProductName={#MyAppName} VersionInfoProductName={#MyAppName}
VersionInfoProductTextVersion={#MyAppVersion} VersionInfoProductTextVersion={#MyAppVersion}
VersionInfoProductVersion={#MyAppVersion} VersionInfoProductVersion={#MyAppVersion}
@ -53,6 +53,8 @@ Compression=lzma
SolidCompression=yes SolidCompression=yes
WizardStyle=modern WizardStyle=modern
CloseApplications=yes CloseApplications=yes
%DISABLEX64%ArchitecturesAllowed=x64compatible
%DISABLEX64%ArchitecturesInstallIn64BitMode=x64compatible
[UninstallRun] [UninstallRun]
Filename: "cmd.exe"; Parameters: "/C taskkill /IM {#MyAppExec}.exe /F"; Flags: runhidden Filename: "cmd.exe"; Parameters: "/C taskkill /IM {#MyAppExec}.exe /F"; Flags: runhidden

View File

@ -769,6 +769,24 @@ class Browser(InspectRequestsMixin, DriverCommonMixin, Chrome):
""" """
Exit the browser. Exit the browser.
""" """
try:
tab_handles = list(self.window_handles)
tab_current = self.current_window_handle
tab_current in tab_handles and tab_handles.remove(tab_current)
tab_handles.append(tab_current)
for tab in tab_handles:
try:
self.switch_to.window(tab)
for _ in range(5):
try:
self.current_alert.dismiss()
except Exception:
break
self.close()
except NoSuchWindowException:
pass
except Exception:
pass
try: try:
super().quit() super().quit()
except Exception: except Exception:
@ -1227,6 +1245,34 @@ class BrowserPluginMultTextTest(BrowserPluginParent):
param.message(param.requirements) param.message(param.requirements)
class BrowserPluginLoggingTest(BrowserPluginParent):
name = '在线日志输出测试'
requirements = [
{
'type': 'text-mult',
'html': '输入内容'
}
]
@staticmethod
def running(param):
param.logging(param.requirements[0])
class BrowserPluginMessageTest(BrowserPluginParent):
name = '在线消息弹窗测试'
requirements = [
{
'type': 'text-mult',
'html': '输入内容'
}
]
@staticmethod
def running(param):
param.message(param.requirements[0])
class BrowserPluginFileCommandDebug(BrowserPluginParent): class BrowserPluginFileCommandDebug(BrowserPluginParent):
name = '上传脚本进行调试' name = '上传脚本进行调试'
requirements = [ requirements = [
@ -1257,34 +1303,6 @@ class BrowserPluginTextCommandDebug(BrowserPluginParent):
code and exec(code) code and exec(code)
class BrowserPluginLoggingTest(BrowserPluginParent):
name = '在线日志输出测试'
requirements = [
{
'type': 'text-mult',
'html': '输入内容'
}
]
@staticmethod
def running(param):
param.logging(param.requirements[0])
class BrowserPluginMessageTest(BrowserPluginParent):
name = '在线消息弹窗测试'
requirements = [
{
'type': 'text-mult',
'html': '输入内容'
}
]
@staticmethod
def running(param):
param.message(param.requirements[0])
class BrowserManagerDataStorage(dict): class BrowserManagerDataStorage(dict):
def __init__(self, file: str): def __init__(self, file: str):
self._data_file = os.path.abspath(file) self._data_file = os.path.abspath(file)
@ -2026,7 +2044,7 @@ class WebServer:
manager_data_file=os.path.join(data, 'manager.json'), manager_data_file=os.path.join(data, 'manager.json'),
browser_data_home=os.path.join(data, 'users'), browser_data_home=os.path.join(data, 'users'),
browser_init_home=os.path.join(root, 'initialize'), browser_init_home=os.path.join(root, 'initialize'),
use_selenium_wire=0 use_selenium_wire=1
) )
self.browser_manager.load_plugins(default_plugins, is_external=0) self.browser_manager.load_plugins(default_plugins, is_external=0)
self.browser_manager.load_plugins_from_external_module() self.browser_manager.load_plugins_from_external_module()
@ -2199,10 +2217,10 @@ class MainRunner:
BrowserPluginTextTest, BrowserPluginTextTest,
BrowserPluginMultFileTest, BrowserPluginMultFileTest,
BrowserPluginMultTextTest, BrowserPluginMultTextTest,
BrowserPluginFileCommandDebug,
BrowserPluginTextCommandDebug,
BrowserPluginLoggingTest, BrowserPluginLoggingTest,
BrowserPluginMessageTest BrowserPluginMessageTest,
BrowserPluginFileCommandDebug,
BrowserPluginTextCommandDebug
] ]
def _copy_files_and_directories(self, src, dst): def _copy_files_and_directories(self, src, dst):
@ -2291,7 +2309,20 @@ class MainRunner:
file=sys.stderr) file=sys.stderr)
return None return None
Path(compile_file).write_text( Path(compile_file).write_text(
Path(compile_template).read_text().replace('%APPNAME%', self.app_name).replace('%APPEXEC%', os.path.splitext(os.path.basename(__file__))[0]).replace('%APPVERSION%', self.app_version)) Path(compile_template).read_text().replace(
'%APPNAME%',
self.app_name
).replace(
'%APPEXEC%',
os.path.splitext(os.path.basename(__file__))[0]
).replace(
'%APPVERSION%',
self.app_version
).replace(
'%DISABLEX64%',
'' if platform.architecture()[0] == '64bit' else '; '
)
)
subprocess.run([compiler, compile_file]) subprocess.run([compiler, compile_file])
def _handle_interrupt(self, _signal, _frame): def _handle_interrupt(self, _signal, _frame):