No information about DevExpress controls in automation app - c#

i'm writing because I have some hard times trying to get any automation-useful information about DevExpress controls. I do not have ability to see source code of application I'm testing, but UISpy and all other UI verifiers out there don't provide any information, including name, automationID and so on. The only thing that is available is info such as runtimeID, dynamically-assigned automationID and control type. Is there any chance to recognize these controls to get their unique properties? I know it must be some way since Visual Studio does that..

White is a wrapper for Microsoft's UI Automation Framework. As such, it uses Conditions on AutomationElemements' properties in order to find the appropriate element. UISpy is basically a visual reflection of what the UIA 'sees'. There are no other 'low level' properties.
Unfortunately, many developers and control vendors don't pay attention to setting a unique and indicative value for the AutomationID or Name properties, and thus make it hard to get the element you need.
The best solution I could give you is to create a helper method that works directly with UIA rather than with White, which gives you more flexibility in searching for your control. For example, if you have a DevExpress GridView, you could get all its child elements and query every single one of them for their relative position on the screen.

You could try with UI Automation Verify (UIA Verify). It will help you obtain the automationID.

Related

Is it possible to read data from Pane control type?

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.

Identifying a WPF Control with White UI Automation using search criteria as an "OR" statement

I'm currently trying to automate the testing of a WPF application, and have several controls where the automationID is determined at run time (currently the problem is a toggle button that has been morphed into a drop down menu, where the text of the toggle button is the selected item)
To solve this I believe I could add all the available selections as search criteria and tell the search function of TestStack.White that I wish to use the OrSearchCondition property; however, I am not able to find any documentation of how to use this feature and cannot figure it out by reading through the source code.
Additionally, I have found one relevant question to this problem on GitHub, although it remains unanswered.
Since the SearchCriteria(SearchCondition searchCondition) constructor is marked as private I don't believe their is any means for you to create a SearchCriteria using the OrSearchCondition. It seems like some helper methods need to be added to SearchCriteria for allowing the user create SearchCriteria with OrConditions.
You can work around this by using SearchCriteria.All then using linq to iterate over all the automation elements you get back for the property you are looking for. Although I do recommend using caching if you use this approach to prevent a ton of cross process calls.

UIA Verify shows no name property for buttons

I need to automate a workflow and tried to rely on teststack white and UIA Verify to find the buttons in another application.
However when I try to identify the buttons I was greeted with just empty name properties for the controls inside the window I need to control (see attached screenshot).
The controls are apparently of type Custom.
I want to be able to press buttons and enter text into textboxes as well as check a checkbox.
Is there a way? Can I access them via for example an index (e.g. button = third control in window)?
Edit: As requested a screenshot from inspect.exe
Would you mind taking a look at those controls with Inspect.exe and posting a screen shot of the properites? You might be able to find another unique property on them to identify it with. Inspect.exe can be found C:\Program Files (x86)\Windows Kits\8.1\bin\x64\inspect.exe.
With White you wont be able to get a collection of all the buttons but with raw ui-automation you will be able to get a collection of the AutomationElements using FindAll.
Here is an example of how to get all controls of a certain type.
Retrieve Multiple UIItems ByClassName
Edit:
So after looking at the updated image from inspect I am afraid the application you are trying to automate didn't expose their application to ui-automation properly. I was certain that it wasn't exposed properly before but I was hoping they may have accidentally exposed some properties. I have seen this before with some 3rd party controls for VB6. It would be possible using the technique I linked above to get all the controls with a name of "" but then you would have to use the bounding rectangle property to move your mouse to the correct position and click (if that property is reporting the correct position) since I would wagger the invoke pattern is not supported. If you have access to the source code you could implement these properties and pattern.

Is it possible to detect what template(s) have been applied to a PowerPoint presentation?

I'm trying to write an add-in that checks user presentations for overall consistency against a series of business rules that I'm expecting largely to be defined in a number of masters style the slides a user might be working on. This should work fine if the user has applied a template, but if they have not, I'm unsure how to detect it.
Looking at the object model, neither Slide.CustomLayout nor Presentation.SlideMaster seem to have a property that mentions the original filename of the master currently in use (the name property is identical both before and after a business template has been applied).
Can anyone think of a good way to detect if a template is in use (so I can flag to the user that the first thing they might want to do is use one), or at least find if the template in use is the default one...
Writing the addin in C#, but I suspect this kind of thing will be the same in more or less any office automation language...
Suppose there's a shape of a known name or (better) tagged with a known value on the master slide of the template. That shape should then appear on the master slide of a presentation once the template containing the master slide has been applied.

Web Browser Hooking and Automation

I am starting some research on a project that involves navigating the web with speech feedback from SAPI. This application will be used by the blind and visually impaired to navigate the web with full speech feedback of current selected object and the ability to read the entire page and fill out forms. I have a mass amount of experience in SAPI and the accessibility word, however I'm not so familiar with HTML and the best approach on taking on this project and i would like to ask for guidance from someone that may have experience in this area. The basic concepts, which I've already explained a little is to enable a blind user to use this standalone product without a screen reader and have the ability to navigate the web page with a keyboard and receive speech feedback from a synthesizer i have created. I can use the Accessibility API's built into windows to display location for low vision users.
Thank you!
IE supports all accessibility interfaces (I believe all other browsers do too - sample on SO ).
There are 2 parts - code access using IAccessible and related interfaces and good HTML (i.e. correct use of semantic tags like UL/LI) markup with possible use of additional CSS accessibility aria-XXXX attributes (i.e. aria-expanded)
Possible starting link - What's New for Accessibility in IE8
I have come to the conclusion in order to get a talking web browser i actually had to hook an instance of the WebBrowser Control with Set setwindowshookex. In my setwindowshookex callback i monitor for the event: OB_FOCUS (focus changed, could be keyboard or mouse) i then pass the object instance that has focus to the AccessibleObjectFromEvent API. Next, i get the IAccessible interface to this object and then enumerate any children if present and compare them against a known object list that relates to HTML/Web objects to use the proper class that will parse this field and announce text if available, if the user is in an editable field, focused buttons, etc... I also use the IAccessible class to get the objects location and present location to the user by drawing a rectangle on the current focused object. I have also created a class that extracts just link, text, removes images and more to make for an easier, more enjoyable web experience for people with visual impairments. I still have some quarks to work out, but progress is moving forward!

Categories