使用Sikuli测试后如何关闭应用程序的所有窗口?我正在使用sikulix 1.1.2版,要关闭窗口,我可以键入ALT + F4,它将关闭1个窗口,但是我需要关闭当前应用程序的所有现有窗口,我该如何解决?
答案 0 :(得分:0)
使用:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { StoreModule, ActionReducerMap, ActionReducer, MetaReducer } from '@ngrx/store';
import { storageSync } from '@larscom/ngrx-store-storagesync';
import * as fromAuth from './auth/reducer';
export const reducers: ActionReducerMap<ISomeState> = {
auth: fromAuth.reducer
};
export function storageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
return storageSync<ISomeState>({
features: [
// saves the auth state to sessionStorage
{ stateKey: 'auth' }
],
storage: window.sessionStorage
})(reducer);
}
const metaReducers: Array<MetaReducer<any, any>> = [storageSyncReducer];
@NgModule({
imports: [BrowserModule, StoreModule.forRoot(reducers, { metaReducers })]
})
export class AppModule {}
System.exit(0);
“ 0”让任何人调用您的程序都知道一切正常。但是,如果由于错误而要退出,则应使用System.exit(1);或另一个与特定错误相对应的非零数字。
答案 1 :(得分:0)
我认为您可以直接从Sikuli中的Python启动并杀死该应用程序。
Here is some code that works with Kandu,您可以适应Sikuli:
import sys
import os
import datetime
import subprocess
import time
def PlayAndWait(macro, timeout_seconds = 10, var1 = '-', var2 = '-', var3 = '-', path_downloaddir = None, path_autorun_html = None, browser_path = None):
assert os.path.exists(path_downloaddir)
assert os.path.exists(path_autorun_html)
assert os.path.exists(browser_path)
log = 'log_' + datetime.datetime.now().strftime('%m-%d-%Y_%H_%M_%S') + '.txt'
path_log = os.path.join(path_downloaddir, log)
args = r'file:///' + path_autorun_html + '?macro=' + macro + '&cmd_var1=' + var1 + '&cmd_var2=' + var2 + '&cmd_var3=' + var3 + '&closeKantu=0&direct=1&savelog=' + log
proc = subprocess.Popen([browser_path, args])
status_runtime = 0
print("Log File with show up at " + path_log)
while(not os.path.exists(path_log) and status_runtime < timeout_seconds):
print("Waiting for macro to finish, seconds=%d" % status_runtime)
time.sleep(1)
status_runtime = status_runtime + 1
if status_runtime < timeout_seconds:
with open(path_log) as f:
status_text = f.readline()
status_init = 1 if status_text.find('Status=OK') != -1 else -1
else:
status_text = "Macro did not complete withing the time given: %d" % timeout_seconds
status_init = -2
proc.kill()
print(status_text)
sys.exit(status_init)
if __name__ == '__main__':
#PlayAndWait('DemoAutofill', timeout_seconds = 35, path_downloaddir = r'F:\selenium\\', path_autorun_html = r'F:\selenium\cmdlinetest.html', browser_path=r'C:\Program Files\Mozilla Firefox\firefox.exe')
PlayAndWait('DemoAutofill', timeout_seconds = 35, path_downloaddir = r'C:\Downloads\\', path_autorun_html = r'F:\selenium\cmdlinetest.html', browser_path=r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')
第一
proc = subprocess.Popen([app_path, args])
然后
proc.kill()