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
Related
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.
Hi all I used Selenium some time ago to create a program to carry out automated actions on a website I enjoy using.
I managed to use Selenium to do what I wanted before without much trouble the only issue I had was using it in the background.
I couldn't use it without it effecting other things I was doing on the PC, I did think of using virtual machines but I would like to try and avoid this.
Last night I was playing around with the WebBrowser class in C# and its nice but limited, I like how it was self contained within the windows form application so this is what I am looking for.
Dose anyone know the best way integrating a visual representation of a browser within a windows form application but still allow me to mimic key entry etc but would run in the background.
I have heard of things like WaitN, GekoFX, MozNet etc but from what I read I am not sure any of these would work.
In general, when you are attempting to automate a web page using a browser, you have two options for simulating user events. You can either simulate them via JavaScript, or you can use OS-level mechanisms (so-called "native events") for simulating mouse and keyboard events. Both approaches have their pitfalls.
Simulated events using JavaScript only would probably allow the window being automated to remain in the background, without system focus, while carrying out the tasks you desire. Selenium RC used this method, and Selenium WebDriver offers the ability to use simulated events for Firefox and IE. However, there are some drawbacks to this approach. Simulated events may lack the fidelity and accuracy you require. For example, "drop-down menus" on a page that work via the CSS :hover pseudoselector cannot be triggered via JavaScript, so this approach is doomed to failure in these cases. Additionally, since you're using JavaScript, you're restricted to the JavaScript sandbox, which means that cross-domain frames and the like may be strictly out of bounds.
Native events, on the other hand, are far more closely representational of a user's actual mouse and keyboard operations. In general, they'll allow the correct events to fire on the web page, and in the correct order, without you having to guess which events to fire on which elements. The downside to using them is that to implement them correctly, the window being automated must have the system focus to receive the events properly. You can attempt to hack around this using the SendMessage API if you're on Windows, but this is the Wrong Thing to do, as it's error prone and absolutely not guaranteed to work. The correct way to use native events is to use the SendInput API, but that API sends the input to the window with the system focus. WebDriver defaults to using native events for simulating user input, but it defaults to the flawed SendMessage approach. For IE, at least, it does provide an option to use the more correct SendInput approach.
If you're dead set on not requiring a browser window in the foreground, you really ought to look into a headless option. PhantomJS is a great option, and WebDriver also has a driver for it, which means you can still write your automation code in C#. Otherwise, you're limited to one of the other approaches outlined above.
Does the application need to be hosted within a window?
I have used selenium, Watin for automation, unfortunately they do interfere with what you are doing and I have not managed to find a way around this.
I have used the .Net WebBrowser class too, but for automating I am not sure without testing if it is a fully featured IE, with regard to JavaScript running inside it. I think it does execute JavaScripts though, but you would need to check.
If you do not need to see what is happening there are headless options available too, even for Selenium I think:
Is it possible to hide the browser in Selenium RC?
Here is a list of headless versions if that is viable for you:
https://gist.github.com/evandrix/3694955
From https://learn.microsoft.com/en-us/visualstudio/test/use-ui-automation-to-test-your-code?view=vs-2022
Visual Studio 2019 is the last version where Coded UI Test will be
fully available. We recommend using Playwright 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. To reduce the impact on users some minimum
support will still be available in Visual Studio 2022 Preview 4 or
later.
I am going to start a new (Right-To-Left) WPF project and the Main reason is to provide a single UI for the application in Windows and Web.
What Should I consider?
Which WPF Controls should/shouln't (can/can't) I use?
Do I Have to Use Silverlight? (I'm not interest)
Should I use XBAP project orWindows Project with Page base modules?
TIA
Your choices are indeed XBAP (WPF Browser App) and SilverLight.
You can easily google to find lots of comparisons, here is a short and simple one.
You main decision factor is your target audience. Do you want to support the Apple platform and maybe even Linux? Then use SilverLight.
If you're sure you only have Windows clients (Web and Desktop) you could use the more powerful WPF. But do write the WBA first so you don't run into permission issues later.
I want to start silverlight development inside an application which developed by WPF.
Actually we want to add silverlight featuretoan existing WPF project. what should we consider and how todo this
I saw Getting started with Silverlight development and it was not my answer
I mark this as a Community Wiki.
Please clarify your intent. What do you mean by a Silverlight feature ?
Silverlight is a subset of WPF, but is intended for a Web application (i.e. running inside a Web browser, using the .NET framework provided by the browser plug-in), while WPF is meant for a desktop application (i.e. running outside of a browser, using the full .NET present on the disk).
(there is the notion of running WPF inside the browser, but that is still using the full .NET framework).
"Adding" Silverlight to WPF doesn't make much sense because you can accomplish whatever you need to do in regular WPF for the most part. If you already have a WPF application you are enforcing windows and the full .NET client run time so you are going to get any deployment benefits.
I assume what you may be considering (since you mentioned XBAP) is to re-write or recompile your current WPF XBAP application into a Silverlight application? This way you get cross platform web deployment with the full Client run time requirement.
If this is the case then you would not be "adding" to your existing solution. It would be more an exercise in porting the existing application over to Silverlight. With SL3 this is less painful then before (and if SL 4 is an option it will be an even better experience).
My first step would be to simply create a new Silverlight application and begin moving your code over and seeing how far you get.
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.