samc
Topic Author
Posts: 43
Joined: 21 Aug 2019, 19:22

Is there a way to simulate button presses / mouse clicks for testing purposes?

15 Aug 2022, 20:52

Hello-

I'm wondering if anyone has found out a good way to simulate button clicks or just generally input into Noesis Engine for automated testing purposes. Anyone have suggestions / pointers?

thanks,
sam
 
User avatar
jsantos
Site Admin
Posts: 3548
Joined: 20 Jan 2012, 17:18
Contact:

Re: Is there a way to simulate button presses / mouse clicks for testing purposes?

15 Aug 2022, 22:45

Yes, NoesisView exposes the following methods to manually inject input:
  • KeyDown
  • KeyUp
  • Char
  • MouseMove
  • MouseButtonDown
  • MouseButtonUp
  • MouseDoubleClick
  • MouseWheel
  • TouchMove
  • TouchDown
  • TouchUp
 
User avatar
maherne
Site Admin
Posts: 13
Joined: 01 Jul 2022, 10:10

Re: Is there a way to simulate button presses / mouse clicks for testing purposes?

18 Aug 2022, 12:23

To add to Jesús answer. A pattern I have used in the past, to make finding and interacting with particular elements in the current view, is to create an attached property which registers the element in a static map using the element's Name as a key. You can then access this static map from your automation scripts, allowing you to find out if the element exists, and get it's position to interact with (e.g. using View::MouseButtonDown), or to assert that it's dependency properties are in the correct state.

In XAML the attached property would look something like this:
<Button x:Name="helpButton" local:ViewDebug.Register="true" />
The attached property changed callback would add/remove the element from a static map.
And the ViewDebug class would have a static API, something like:
ViewDebug::HasElement("helpButton");
const FrameworkElement* = ViewDebug::GetElement("helpButton");
This setup only allows for one element per name, but you can bind a dynamic value to the element's name, such as adding a index to the end of a Name for items in a list.

If you want more information on this, please let me know.

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 1 guest