User interface coding

Hi, I am learning to use Coded UI Tests (CUIT) to test the application. I tried the recording option, and that is not enough for me. If you use it on a different size screen, it breaks.

I know that you can pass the test code, but I cannot find good examples of how to write a basic test. There are examples here that use CUITe, but these messages are from 2011, and I'm not sure how relevant they are with the new Microsoft CUIT updates.

These tests need to be integrated with my build environments in Visual Studio 2012 Ultimate, so I don't use Selenium.

And code samples or links to good tutorials would be appreciated, but in particular I'm looking for an example on how to start coding my CUITs.

+8
c # visual-studio automated-tests coded-ui-tests
source share
4 answers

The API draft of the first code of the coded UI on CodePlex ( http://codeduicodefirst.codeplex.com/ ) includes a demonstration of the project that you can download - an application and tests. It is designed to create CUIT tests without recording / playback dependency.

The biggest thing you need if you are going to work only on the basis of code is a way to avoid dependence on the map of auto-generated objects created by CUIT records. The Code-First project uses classes mapped to individual page objects to get around this - you will need to extend the project code for working with desktop applications, if I remember correctly.

(I am in no way associated with this project - this is only the only manual coding resource other than CUITe that I found, and CUITe has not been updated for some time, the last thing I saw).

+5
source share

These are not many developers, but you can create Code First tests with CodedUI. This is not promoted, which is bad imo. I consider the recording option as fragile. It uses mouse coordinates, which means you need to recreate the tests when the user interface changes ...

A useful way would be to use a page object template (also used by other popular tools such as Selenium). This creates an abstraction of the user interface, which gives you great flexibility and strong typing.

You get easy, readable and, above all, supported code:

var storeHyperlink = new HtmlHyperlink(_browserWindow); storeHyperlink.SearchProperties[HtmlHyperlink.PropertyNames.Id] = "StoreLink"; Mouse.Click(storeHyperlink); 

More details

+1
source share

Here's a video showing how to do code tests of the first Code First code:

Coded User Interfaces - DeepDive-Episode3-HandCoding

0
source share

Not sure if anyone is still looking to find out how to best handle code for coded UI tests, but the imo going to the record and the playback path will be disappointing later on! The best way is to create an automation infrastructure that defines the individual objects you want to interact with and have page objects to process your business logic. If you are testing web applications, you can define objects using common UITestControls or HtmlControls. For example:

 public static UITestControl EditBox_Password { get { if ( mEditBox_Password == null || ! mEditBox_Password.Exists ) { mEditBox_Password = new UITestControl (browserWindow ); mEditBox_Password.TechnologyName = "Web"; mEditBox_Password.SearchProperties.Add (UITestControl.PropertyNames.ControlType , "Edit"); mEditBox_Password.SearchProperties.Add ( UITestControl.PropertyNames.Name , "TxtPassword"); } return mEditBox_Password ; } } 

If you are testing Windows-based applications, you can define objects using WinControls or WpfControls.

I recently bought a book about Amazon (manual coding) that clearly defines how to set up a framework and create easily supported code. Not sure if it's available at any bookstore, but here is a link to Amazon if you want to see

https://www.amazon.com/dp/1547000856/ref=sr_1_1?s=books&ie=UTF8&qid=1496767488&sr = 1-1 & keywords = 1547000856

I hope this will be helpful.

Updated: it is simply encrypted in Google and there is a discount code for the book http://www.arkenstone-ltd.com/testing-with-coded-ui/

0
source share

All Articles