I am trying to automate the testing of a WPF application using Windows UI Automation.
The application has a ContentControl with a data template that changes based on user interaction.
On initial load, I am able to get and click a button inside of the content control. This switches the data template (the sub-controls are removed and replaced with other ones).
However, when I look for the new controls in the automation element, they cannot be found.
I am using the wrapper FlaUI, but I've also tried White and they both have the same sort of result.
I am not using caching, but it seems like the window is somehow cached. Is there a way to reload the element or entire window so that I can retrieve the new controls.
Found the solution on FlaUI's FAQ.
When using DevExpress controls, some things (like tab content) are not
updated By default, DevExpress controls do not raise automation
events, as these events may decrease the application performance. To
make sure that the events are raised properly, set the
ClearAutomationEventsHelper.IsEnabled static property to false on
application startup (needs to be done in the application that is
automated with FlaUI):
ClearAutomationEventsHelper.IsEnabled = false;
Related
I've developed Windows Application using C# and .Net Framework 4.5
My application loads user control and takes input from users. There are probably more than 100 controls on that user control. It works fine when I am actively using my system.
Problem is when I keep my application open and toggle to other applications which are also running e.g. checking my email, browse internet or using excel. After returning to my program, I can see the frame of my program and few controls but not all of them and I can see through my program to the last application which I visited. Also title bar of my app will become black.
Please note that my app doesn't become inaccessible. It's just won't load my all controls. I've assigned shortcut key to reload user control by which I can reload my user control and then it works fine.
I believe that your custom controls need some special drawing and this makes me think about the paint event.
Since you found a fix yourself
I've assigned shortcut key to reload user control
I believe that you can use the OnFocus event to call this shortcut key or the code behind it.
So I have an odd issue while trying to use a WPF TextBox with SpellCheck enabled inside a Winforms form, using the custom control defined in this post.
This works just fine, I've tried using it in my own sandbox project and it looks great. The problem is when I try to replace the Winforms TextBoxes inside one of our existing forms. The SpellCheck context menu is "trapped" inside the control, so all I can see are the up/down arrows of the menu.
I'm not too familiar with Winforms, as I mostly work with WPF, so I'm having a hard time determining the problem. The text box shown above is the custom control as mentioned in the linked post. The control is contained in a forms TableLayoutPanel. How can I get the context menu to expand and actually be visible?
Edit
First, to clarify, the context menu appears normally when displayed in a console application that opens the form. I did a little more testing and created a new web project (what the original problem project is) with a button that opens the form, and then the problem behavior occurs. What difference between the console application and the web application would cause this?
Edit 2
I tried the suggestions in this post, thinking maybe the context menu really was just being automatically sized incorrectly (to fit the parent control). But none of those solutions seemed to make any difference either.
Edit 3
After using snoop to look at the differences between the working context menu (windows application) and the not-working one (xbap) the only difference I could see was that the DesiredSize of the xbap instance's context menu has a smaller size, I just have no idea why.
The wpf control is a control which is hosted in winforms via the ElementHost.
Hence it lives within the area provided by the parent.
The only way is to expand it, is to change the size of the parent. Give it a try by creating a winform supersized textbox as a quick debug example. Note whether the size change works on not. If it does can the GUI accommodate that change? I can't answer that.
i have create a few WPF applications in visual studio, and now i would like to create a final application to run all of the created apps in the final application. i would like to know how i can create a layout that displays the apps that are running inside the final app as buttons that can be clicked and cause the app to expand and allow the user to work on that app and then when finished return back to the final app and see the other apps to choose from. I imagine it would look like a Google chrome blank page that allows you see your familiar webpages and click on them to load them up. Any help or advice on what i should focus on to implement this would be much appreciated.
Thank you for taking the time to read over this.
Consider using a VisualBrush this takes other WPF UI (your "apps") and uses their UI as a brush for another UI element.
Raj Kumar has a simple article called Visual Brush in WPF for details.
The bit you probably want is at the bottom where he shows you rendering a controls content in another control. The magic being binding the controls visual to the element name whos UI it should render.
I am currently in the process of improving my options dialog for a winforms application. At the moment I am using a tab control.
I would like to create a form/dialog for settings that is similar to Visual Studio's. How is this done? I can see a treeview like control on the left hand side but what control are they using to display each of the options pages, it doesn't appear to be a tab control. I would like to be able to build the controls for each of the settings at design time.
Thanks.
They look to me like UserControls. I can't say how exactly they implement it, but it would be simple enough to build a UserControl for each option type and swap out the current control when the tree view selection changes. In your designer you would simply have the TreeView and a parent panel to host the UserControls. At runtime you would perform the swap.
I am doing a UI automation for a WPF application using the Microsoft UI Automation library and it works well.
However my app has four screens in a TabControl. Even when I click the tab item through code its child control tree isnt populated. The only control I can see is the "thumb" Control. Same happens when I see the control tree with UISpy.
However if the window is clicked then all the controls appear. As a Workaround I am simulating a mouseclick through code and it works. I wanted to know if there is some better way of doing it.
I ran into a problem similar to this. What was happening was some data was being retrieved on threads and the controls were not generated at the point automation peers were generated. I would suggest if you have access to the code base for the application you are attempting to automate looking into whether threading is being used. In my specific case it was because BeginInvokes were used to retrieve the data, I switched them to Invokes and it worked fine.
Also from what I could tell the reason the controls were being show on mouse over was because the tool tip generated a popup and caused the automation peers to be updated.
Why don't you click the control using mouse events if that is what works.
(Now, if you still are having that problem..)
How to simulate Mouse Click in C#?