I am investigating automated testing of an old Win32 application that used ActiveX controls. I am spiking use White (from Thougthworks) that uses Microsoft UIAutomation. I can find the AutomationElement related to the control, but how do I interact with it?
Spy++ sees the grid control as a single window, so I can't talk to rows, columns, or cells directly. How do I talk to the SSUltraGrid control from my test code?
Cheers
Nigel
The basic problem with some ActiveX and other custom controls like SSUltraGrid is what you mentioned, they're presented as just one window. So unless they've provided an API that makes them "friendly" to your GUI automation tool, you'll always face this challenge. Of course many companies offer newer versions of their products that are friendlier to UI Automation than before... perhaps upgrading the control is worthwhile...
Failing that... what the test engineers at my job have told me is that when they encounter that situation, if there are well known keystrokes to invoke the activity they desire, they send keystrokes to the control window. If they're lucky enough to have things in a fixed location, they might even be able to get away with sending mouse events. However, that's dicey at best.
Related
I've started using FlaUI for Automating my thick client .net application. The application is Windows Form based. The start was good and Login Form was identified and I could Login, but after that came the dead end and I found that almost everything in the application is developed as Pane control type.
So, there is grid, table etc. but they all just appear as Pane type when I see the object hierarchy using Inspect.exe or FLAUInspect tools. And nothing really appears in thier property, so it seems that nothing could be read. But before giving up I just wanted to check with experienced audience on this forum if there is really any way to get the data from Pane objects.
Please suggest if there is any way, even that means using other libraries like UIAutomation, TestStack.White, etc.
UPDATE: I now understand little more about this. So, the objects that are there in the pane are developed in syncfusion and devexpress. Is it possible to identify objects developed in syncfusion and devexpress using FlaUI or UIAutomation or TestStack.White, etc ?
I don't know if you have already tried the following steps. Have you add automationId's to your objects in xaml code with:
AutomationProperties.AutomationId="AnyID"
In the testcode, first initialize the main window of the application.
MainWindow = fApplication.GetMainWindow(fAutomation, null)?.AsWindow()
After that you can find your objects by the automationId's, like:
MainWindow .FindFirstDescendant(cf => cf.ByAutomationId(AnyID))
I did it this way, and don't have to know the hierarchy of my application. Maybe this will work?
Most UI Frameworks nowadays fully support UI Automation. So first make sure that you have a recent version of your framework (syncfusion, devexpress). In addition, some frameworks provide settings to enable UI Automation. Like for devexpress, you need to set
ClearAutomationEventsHelper.IsEnabled = false;
at the start of your application to test so it exposes way more things (like tabs) to FlaUI.
I want to develop a tool for test automation.
I have source code of the application under test, so I have the privilege to add some custom logic inside the app.
One part of the custom logic is to detect the content change, analyze the change and finally report the result outside to the test tool, such as: a message "the login window is ready" followed by locations of user_id and password control.
By using VisualTreeHelper and LogicalTreeHelper class, I can know the current status of the window, but I do not know WHEN to walk through the tree.
I found a similar question but this is for 3rd party window, I guess there may be better solution for app that I have access to source code.
In win32, I can hook WM_PAINT to detect window content change.
Do you have any hint about how to do this in WPF?
By the way, although I would like to add custom logic to the app, I also want to change the app logic as little as possible.
I am new to WPF, sorry if anything totally wrong.
You might want to specify exactly what you want to achieve, like describing an examlpe of what you want to do.
Are you aware of the VisualTreeHelper class? https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.visualtreehelper
Based on what you said you wanted to achieve. I would probably subscribe to some "ready" or "loaded" event of a UI element. You should be able to get access to the UI element through the VisualTreeHelper.
You should also be able to interact with the UI elements through it, eg. click and enter information. And you could also run tests based on the state of the UI (I think).
I'm also sure there are plenty of Automated UI Testing frameworks for WPF, just Google: "automated UI Testing frameworks for WPF".
Hope this helps.
I am developing an automation testing suite for one of our applications that was developed in WinForms 2000. I have been able to more or less work with every control except for a WinTable. When i use the Coded UI Test Builder, I am unable to identify the table. The only object being identified is the parent control which is of control type Client.
I would like any suggestions or workarounds that i could use.
I did read that one workaround to get this to work, is to create a custom control and implement the required accessibility. I have not been able to achieve this though.
I would gladly appreciate any help.
Cheers.
Short version: what is the preferred approach for embedding controls in a PowerPoint slide that send events back to an application-level add-in? The controls need to work in slide show mode and in design mode.
Long version:
I recently was brought into development on a legacy add-in for PowerPoint that (in a nutshell) pulls data from remote data sources and draws corresponding charts on slides. The add-in is managed code (C#), but is NOT built with VSTO - it uses custom wrappers and a COM shim.
The charts periodically need to be refreshed, and our add-in has a Refresh button in the toolbar for this purpose. In cases where a chart can't render at all until refreshed, we also embed a MSForms.CommandButton on the slide itself (as an OLE object). We have used this approach in a similar Excel add-in with success.
Unfortunately, it does not work in PowerPoint: the click event on the button does not seem to reach our add-in. I have found some information online that supports this observation. I have also tested it with a MSForms.ComboBox instead of a button and that worked--the combo box's change event reaches our add-in and the refresh succeeds.
So it seems that I need to find an alternative way to have the button communicate with our add-in. I can think of a few approaches and am wondering if there is a best practice:
Have the button (or a similar shape) run a macro that calls code in our add-in. I've heard that this might not work when the slide is viewed in Design Mode, but haven't tested yet to confirm.
Embed an MSForms form in the slide as well, to capture the click event and pass it on to our add-in. Again, this is just a theory and is untested as of yet.
Use something else entirely - something tells me there has to be a "modern" way of doing this, I'm just not familiar enough with Office development to know what that is.
I'll add that migrating to VSTO or a similar technology (such as NetOffice) is an option, but we'd prefer to avoid that if possible. Thanks!
I have an external windows application (no source code) that has a grid within it. This runs as a separate process. When the user selects a cell within the grid via mouse click, I need to be able to read the value within that cell. Can anyone provide some direction on what API's I would need to use to be able to trap and listen to the events?
You best option is UI Automation Overview or accessibility as older technology.
Also you could take a look at this Pinvoke SetFocus to a particular control on how to invoke things on another process (pretty much unrelated to automation, automation works w/o that)
UI Automation is the best tool for the job, however, the downside is that not every app supports that - so this very much depends on the app you're targeting. Some support only the legacy acessibility (IAccessible, IAccessible2 etc.), usually there is a 'combined' approach. Older techniques don't work very good any more but you could try traversing windows, child windows in the target window (for that direction you'll probably need the above technique sooner or later) and hoping you could get it from standard controls, windows text, via messages etc.