notifyiconwpf and GUI automation - automated-tests

I have an application that uses this application type that I need to automate. Unfortunately, the application window is invisible to my automation tools. Are there any suggested ways of working around this problem? I'm using pywinuto for automation. I can't even inspect the window data for this application.
EDIT:
from pywinauto import Application
from pywinauto import taskbar
app = Application().start("path/to/my/app")
#make the window visible
taskbar.ClickHiddenSystemTrayIcon("My App")
#When I query the number of windows the app has.
len(app.Windows())
#I get zero windows. There should be at least one window
#because the window is currently visible.
I've also tried the findwindow methods for which I can get a WindowSpecification but it is not connected to any window.

In order for this app to be automatable, the developer had to wrap the NotifyIconWPF in a standard window, conditionally, depending on command line switches. Once this was done, the windows for this application became accessible to pywinauto. It looks to me like Caliburn Micro, intentionally, disabled accessibility for this window class.

Related

How to make the top QWidget modal?

I'm developing an application in PyQT5 which has a QWidget object on the top. This application needs to be able to run in 'kiosk' mode, so my aim is to make that top QWidget modal and prevent any other running application of being focused.
The skeleton of the main class is below. Note that I'm calling the setWindowModality() method which in theory sets the behavior of the window to the chosen one:
class MyApp(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setWindowModality(3)
My main method is the following:
app = QApplication(sys.argv)
MyApp()
sys.exit(app.exec_())
As per the setWindowModality() method documentation:
Qt.NonModal 0 The window is not modal and does not block input to other windows.
Qt.WindowModal 1 The window is modal to a single window
hierarchy and blocks input to its parent window, all grandparent
windows, and all siblings of its parent and grandparent windows.
Qt.ApplicationModal 2 The window is modal to the application and
blocks input to all windows.
The problem is that the window is not modal at all, I can switch to a different application (say a Web browser), which is exactly what I want to prevent. I've also tried 1, 2, 3 as values and they produce the same behavior.
I'm afraid this could be a design restriction in order to avoid apps block other apps, but I'm not sure of it and I'm unable to confirm it.
Am I missing something obvious here? In case the problem is the design restriction, is there a way to still simulate a modal window?
Modality is only with respect to current application. If application has only one open top level window, then there's no difference between application and window modal. This modality has no effect on other applications, so you are not able to achieve what you want with it, there's no simple "desktop modal" flag.
You can use Qt to make the window full screen, but you have to use other means to prevent user from accessing the desktop, or closing the app (often bound to ALT-F4 keyboard shortcut). If your platform is Windows, then I don't know how to do that, but I'm sure there's a way. Under X11 (used on Linux usually), the most straightforward way to do that is not have a desktop at all, simply by just running the app without desktop. Look up nodm package for an easy way to do this.

Qt Activex MainWindow on TabWidget becomes unresponsive

I have a very strange problem. The application is based on Qt C++. There is a TabWidget whose tabs are created dynamically. The tab contains QtMainWindow in ActiveX widget. When multiple apps are started, the selected one works fine. But when another tab is selected, it becomes unresponsive.
When I minimize the Application and then maximize again then the tab starts working fine. I tried with setFocus, activateWindow, showNormal and setActiveWindow but nothing is working.
Can somebody help me in this issue?
The likeliest cause of the app becoming unresponsive is something that stalling the execution on the main thread. With running the project from/ or attaching to Visual Studio debugger (better debugger than the one used by Qt Creator) try to get your app in such unresponsive state. Now look at Main Thread in Threads view (select one), also look at Call Stack view. Where does the execution stall?
The log in Output View is also helping to recreate the context of how to get there. You can see Qt and your own debug output there.
While debugging I found that the App was not syncing because of missing WA_Mapped attribute. My problem was just opposite of the below issue. When I used to maximize after minimize, the App used to become responsive. Finally setting the attribute WA_Mapped at different places (trial n error) fixed the issue.
widgets freezing after minimise window
Thanks for #AlexanderVX response.

Ignore mouse mouvement in JavaFX GUI test

Is it possible to write tests for a JavaFX application, which do not fail upon mouse mouvement generated by the human user ?
I am a beginner in JavaFX and TestFX, and it seemed to me that TestFX stops everything as soon as it detects that the mouse has been moved.
In another project, which uses Eclipse RCP and SWTBot, this seemed to work out-of-the-box, as long as the application under test had the focus. Is there any way to get the same behaviour with TestFX, or any other test framework for JavaFX ?
As a workaround, on Linux, it's generally advised and useful to create another X session (using Xephyr for example) and to run tests in this X session by setting the right DISPLAY property.
With that, the event processing is isolated on both DISPLAYs so tests are not "polluted" by parallel human actions on the other DISPLAY and can run with less troubles.

Straightforward way to count number of windows up through PopUpManager?

I'm using the PopUpManager to bring a bunch of event windows up.
I want to make it so that only one window can be open at a time, but I don't see anywhere in the code that tracks open windows to set up a conditional. I guess it just creates the windows and then sets them free?
Thinking about a windowCount variable that increments when I add a window and decrements when I remove one, but since the PopupManager is called in different classes I'd have to start throwing events all over the place. I can do that, but I'm wondering if there's a more straightforward method?
The systemManager (rather than PopUpManager, go figure...) provides information on the currently opened popup windows.
If your popups are all model then you will be interested in 'systemManager.numModalWindows':
The number of modal windows. Modal
windows don't allow clicking in
another windows which would normally
activate the FocusManager in that
window. The PopUpManager modifies this
count as it creates and destroys modal
windows.
Otherwise try out 'systemManager.popUpChildren':
An list of the topMost (popup) windows
being parented by this ISystemManager.
An ISystemManager has various types of
children, such as the Application,
popups, tooltips, and custom cursors.
You can access the top-most windows
through the popUpChildren property.
The IChildList object has methods like
getChildAt() and properties like
numChildren. For example,
popUpChildren.numChildren gives the
number of topmost windows and you can
access them as
popUpChildren.getChildAt(i).
I see a few options:
1) Make all your windows modal; so that the application can't be used until the window is closed. This is a argument to the createPopUp method on the PopUpManager. Presumably you do not have Popups creating other popups.
2) Create your own Manager class, possibly an extension of the PopUpManager class that keeps track of all open windows. Then you'd have a single source of all PopUps and could maintain them that way.

Flex-AIR: Make application with NO tab in taskbar?

I have an AIR app about half way done right now. I was informed by the client today that he does not want a tab to show up in his task bar. I already have this in place for new windows by making them lightweight. I do not know how to make the main window lightweight though. If there is not a way, is there a work around, like not not having a main window and just opening lightweight windows, don't know how that could be done either though? Anyone know how to do this?
Thanks!
Check this doc out. -- Yes, you can do this. In short, you have to hide the initial window - then display your application in a lightweight window.
Also - do note: On a Mac - the behavior is different. By convention, a window is not shown in the 'task bar' when it is displayed. When it is minimized it is in the bar. To hide the application when minimized on a Mac - you have to make the window 'invisible' instead of minimizing it. The doc mentioned above gives further details.
The key part of the doc for your case:
On the Windows operating system,
windows created with the types utility
or lightweight do not appear on the
taskbar. Invisible windows do not
appear on the taskbar, either.
Because the initial window is
necessarily of type, normal, in order
to create an application without any
windows appearing in the taskbar, you
must either close the inital window or
leave it invisible.
To close all
windows in your application without
terminating the application, set the
autoExit property of the
NativeApplication object to false
before closing the last window. To
simply prevent the intial window from
ever becoming visible, add
false to the
element of the
application descriptor file (and do
not set the visible property to true
or call the activate() method of the
window).
In new windows opened by the
application, set the type property of
the NativeWindowInitOption object
passed to the window constructor to
NativeWindowType.UTILITY or
NativeWindowType.LIGHTWEIGHT.

Resources