Getting all windows using UISpec4J

試著忘記壹切 提交于 2019-12-08 09:56:34

问题


I am trying to use UISpec4J in order to automate a Java Swing application. After adapter setup:

setAdapter(new MainClassAdapter(Main.class, new String[0]));

I am trying to obtain the main window:

Window mainWindow = getMainWindow();

Instead of a login dialog, I am getting a splash screen with logo of application. All my attempts to call this dialog manually have failed.

How can I get the list of opened dialogs/windows?


回答1:


It looks like MainClassAdapter is not designed to handle a sequence of windows. However you can implement your own adapter that ignores the splash screen and returns the subsequent window. Here is a sample taken from UISpec4J forums:

setAdapter(new UISpecAdapter() {
    public Window getMainWindow() {
        final Window[] result = new Window[1];
        WindowInterceptor.init(new MainClassTrigger(Main.class, new String[0]))
            .processTransientWindow()
            .process(new WindowHandler() {
                public Trigger process(Window window) throws Exception {
                result[0] = window;
                return Trigger.DO_NOTHING;
                }
            })
        .run();
        return result[0];
    }
});


来源:https://stackoverflow.com/questions/9539549/getting-all-windows-using-uispec4j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!