How to get element properties from Metro W8? - c#

I'm automation test engineer and performing automation using SilkTest
Is there any way to get active Metro window elements (e.g name, style, coordinates, sub-elements)?
Latest SilkTest 13.5 version do not see Metro objects at all :(.

Could not figure out from the comments whether you are looking at options other than SilkTest. If you do then have a look at RIATest which does support Metro applications.
Stating from version 6.0 a number of features in RIATest are specifically targeted at Metro style application automation, particularly:
Ability to stay on top of Metro UI to allow you to simultaneously see your Metro application and RIATest IDE and minimize switching from Desktop to Metro screens when automating a Metro application.
Recording of actions performed on native Windows GUI elements (including Metro GUI). The recorder analyses your script code and reuses your variable names to generate cleaner recorded scripts similar to how you would hand-code an automation script.
Seamless workaround for bugs like this in Windows UI Automation implementation in Metro UI.
Disclaimer: I work for Cogitek, the RIATest company.

From the SilkTest 13.5 release notes

Related

UI automation with another application

I need to interact with a windows application by clicking a button in my application. More precisely: how can I write in a textbox or scroll a dropdown menu?
There are multiple ways to do this depending on what kind of application you are automating. If you are automating a WPF application I would suggesting using Microsoft UI Automation (UIA). There are some nice wrappers written around UIA like TestStack.White and FlaUI. FlaUI is the more modern of the two and supports UIAv3 using a COM wrapper. TestStack.White is built on top of a UIAv2 using the managed wrapper in the .NET Framework which is no longer supported.
If you are automating anything else besides a WPF application you can do straight PInvokes to SendMessage. I would suggest staying away from that method and using the Microsoft UIA framework since sending windows messages can get quite verbose. If you really want to go with the Win32 route I suggest using something like AutoIT to automate your application.
Lastly, you will want to download the Windows SDK and run Inspect.exe from that. Inspect.exe is the application that will allow you to see the properties you are attempting to query and the patterns that are available. Applications like AutoIT have essentially built their own Inspect.exe or reference and application call UISpy which is also in the Windows SDK but mostly superseded by Inspect.exe.

C# Windows Universal 10 TopMost Window

I'm developing a Windows 10 Universal app (UWP).
Is it possible to set application as TopMost (always on top)? Like WPF or Winforms (TopMost property).
Thanks
A feature called CompactOverlay mode was added in the Creators Update that supports this type of functionality. When an app window enters compact overlay mode it’ll be shown above other windows so it won’t get blocked. This allows users to continue to keep an eye on your app's content even when they are working with something else. The canonical example of an app taking advantage of this feature is a media player or a video chat app.
A blog post describing the feature can be found here
https://blogs.msdn.microsoft.com/universal-windows-app-model/2017/02/11/compactoverlay-mode-aka-picture-in-picture/
Short answer is no, there is no way as of today to make the application modal.
There is a petition going around asking for this functionality, which was requested last December but given the amount of votes it got (35 at the time this answer was written), it doesn't look like it will be taken into consideration anytime soon.
As mentioned in the comments, this functionality would be PC only so even if it was added, my assumption would be that it wouldn't work outside of the PC mode (so no tablet, mobile or surface family device support).
It's not possible UWP apps have some restrictions compared with WPF of Win32 apps(classic apps).
With uwp apps you need enable some capabilities to do something special in your app as you can see in the link uwp apps need ask for permission or they can't access or modify files directly.
https://msdn.microsoft.com/en-us/library/windows/apps/mt270968.aspx
Best Regards

c# automation code

I need to write C# automation script for metro app testing. I am using ranorex tool. How do I launch the application present on metro UI through the script? If I record and play back, it doesn't work on the different system. Please suggest script to launch the metro app.
I do not know the folder/path to the metro app as it is hidden.
Thanks
There is a framework called UIA provided by Microsoft for automating Windows 8 apps.
This link would give you the brief idea.

Silverlight Automation Similar to Watin

I am considering porting a WPF application to Silverlight. However, the WPF application uses Watin to spawn IE processes and automate certain tasks.
My question is if there is a way to automate tasks in Silverlight by spawning popups and performing tasks in them similar to how you would with Watin.
I haven't tried this tool yet, but it is the closest I've found to Watin for Silverlight. It is WebAii from Telerik and it is a free download. I ran across it the other day and plan to try it soon.
WebAii Testing Framework plugs
directly into the Silverlight
application it automates and has
access to every single element/object
in the entire Silverlight application.
Beside the ability to perform basic
automation actions like clicking,
moving and setting text, the tool
gives you access to complex properties
on UI elements such as brushes,
borders and even transform matrices.
What’s best is that you can set most
of these properties, which is crucial
for test verifications and
synchronizations.
As far as I know WatiN is a web application test framework, but your question seems to indicate that you are using WatiN to automate tasks in your application. In that context I will try to answer your question.
A Silverlight application is executed in a sandboxed environment and is unable to start new processes on the local computer. However, a Silverlight application can interact with the browser object model that is used to host the Silverlight application. This allows for some interaction with the local environment. If you can fit your use of WatiN into this model you are able to do it from Silverlight but in general you should consider a Silverlight application to live in a sandboxed environment.
Have you had a look at the Silverlight Automation Peer?
http://msdn.microsoft.com/en-us/library/cc645045(VS.95).aspx

Is there any way to automate windows forms testing?

I am familiar with nunit for unit testing of the business layer however I am looking now to automate the test of the win forms gui layer.
I have seen watin and the watin recorder for automating tests on web application by accessing the controls and automating them. However I am struggling to find a watin equivalent for windows forms (written in c# or vb.net) preferably that is open source.
Does one exist or are all products based on recording mouse and keyboard presses?
Update: I have looked at this blog post on white and it seems the sort of thing I am looking for. The blog post raises some issues but as white is only in version 0.6 these may be resolved. Be interested if others have used white or any others for comparison.
Check out http://www.codeplex.com/white and http://nunitforms.sourceforge.net/. We've used the White project with success.
Same Answer to a previous question
Edit
The White project has moved, and is now located on GitHub as part of TestStack.
AutomatedQA's TestComplete is a good testing application to automate GUI testing. It supports more than just Windows Forms also, so you can reuse it for other applications. It is not open source and this is the best that I have found. I haven't seen an open source equivalent to WatiN. It does have a free trial, for you decide if you like it or not. The main reason I went with it, is that it really is cost effective, compared to other testing applications.
As a new alternative, I can give you FlaUI (https://github.com/Roemer/FlaUI). It is basically a complete re-write of white with more features and a clean code-base.
WinAppDriver is a Selenium-like UI test automation service for testing Windows applications including Windows Forms applications. It can be used with Appium, a test automation framework.
The list
Please check the updated list at the: List of Automated Testing (TDD/BDD/ATDD/SBE) Tools and Frameworks for .NET: User Interface Testing
Framework
Comment
Coded UI
Discontinued
FlaUI
NUnitForms
Discontinued
Squish GUI Tester
TestComplete
TestStack.White
WinAppDriver
What Microsoft recommends
WinAppDriver
Microsoft recommends to use WinAppDriver:
Windows Application Driver (WinAppDriver) is a service to support
Selenium-like UI Test Automation on Windows Applications. This service
supports testing Universal Windows Platform (UWP), Windows Forms
(WinForms), Windows Presentation Foundation (WPF), and Classic Windows
(Win32) apps on Windows 10 PCs.
Coded UI (Visual Studio ≤ 2019)
Previously, Coded UI, a Visual Studio built-in feature and part of the UI Automation, was recommended for application UI testing (it's deprecated now):
Coded UI Test for automated UI-driven functional testing is
deprecated. Visual Studio 2019 is the last version where Coded UI Test
will be available. We recommend using Selenium for testing web apps
and Appium with WinAppDriver for testing desktop and UWP apps.
Consider Xamarin.UITest for testing iOS and Android apps using the
NUnit test framework.
Automated tests that drive your application through its user interface
(UI) are known as coded UI tests (CUITs). These tests include
functional testing of the UI controls. They let you verify that the
whole application, including its user interface, is functioning
correctly. Coded UI Tests are particularly useful where there is
validation or other logic in the user interface, for example in a web
page. They are also frequently used to automate an existing manual
test.
Read more at: https://learn.microsoft.com/en-us/visualstudio/test/use-ui-automation-to-test-your-code
As far as I know, White is an abstraction layer over the top of Microsoft's UI Automation framework. I have written a similar layer that we use internally on our projects and it works great. So White would definattley be worth a look
Microsoft have released the source to UI Automation, so if necessary you should be able to debug right down the whole stack if necessary.
The really cool thing is that with licence cost, you can scale up and run as many machines as you like for execution.
We run inside VSTS and link our results to requirements, but you can use c# express and nUnit and get first class tools and languages for little to no cost.
Here are some links from MSDN Magazine on automatic testing code:
Using UIAutomation Bugslayer March 2007
Using PowerShell Test Run December 2007
Tester, a utility for recording mouse clicks and keystrokes, then playing them back & program checking behaviour. Excellent for unmanaged code. Uses windows handles so may not work well for managed code. Bugslayer March 2002.
You could check out the Microsoft UI Automation framework. This has been included in .NET since version 3.0. This is actually what the White framework uses anyway.
You may also use Winium(https://github.com/2gis/Winium) that works on multiple Windows platform besides Windows 10 and is similar to Selenium with extra features that support controlling the application remotely.

Categories