Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hand Coding Coded UI Tests [closed]

Hi I am looking at using Coded UI Tests (CUIT) to test an application. I have tried the recording option and this is not flexible enough for me. If you use it on a different size screen it breaks.

I know you can hand code the tests but I cannot find any good examples of how to write a basic test. There are examples on here that use CUITe but these posts are from 2011 and I'm not sure how relevant they are anymore with the new upgrades to CUIT from Microsoft.

These tests need to be integrated with my build environments in Visual Studio 2012 Ultimate, that is why I'm not using Selenium.

And Code samples or links to good tutorials would be appreciated, but in particular I am looking for an exampl on how to start hand coding my CUITs

like image 804
Jeff Finn Avatar asked Jun 21 '13 14:06

Jeff Finn


1 Answers

Not a lot of developers know this, but it's possible to create Code First tests with CodedUI. It's not being advocated, which is bad imo. I consider the Recording option as a fragile one. It uses mouse coords which means you have to recreate the tests when the UI changes...

The maintainable way would be to use the Page Object pattern (also used by other popular tools like Selenium). This creates an abstraction of the UI which gives you more flexibility and strong typing.

You get easy, readable and most of all maintainable code:

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

Read more

like image 101
Jowen Avatar answered Sep 30 '22 20:09

Jowen