Coded UI Testing with more than one UIMap.Designer.cs? - visual-studio-2010

I started with Coded UI Tests. So far so good, but I have one concern about the file UIMap.uitest. Since I have to create many test scenarios, means many cs files. The more files I have, the bigger the UIMap.uitest is, because it keeps regenerating the code all the time. My question is that it's possible to have/create each UIMap.uitest for each cs file, respectively?
I am using VS2010.
Thanks

Yes. Look for information on "multiple ui maps". The general approach is to right-click in solution explorer, add a new item that is a "Coded UI test map" (Add => New item => Visual C# items (or possibly VB) => Test => Coded UI test map). After naming the map and clicking OK the normal Coded UI dialogues should appear allowing recording and generating of new items. Some people recommend creating a folder in solution explorer to contain all the UI maps. After recording and generating code, calls of the generated methods will need to be added manually to the test methods. Additionally, these new UI maps will need to be instantiated. This Microsoft blog has some more details http://blogs.msdn.com/b/anutthara/archive/2010/02/10/walkthrough-using-multiple-coded-ui-maps-in-test-automation.aspx
When using multiple UI maps DO NOT right click in the source files and select the "Generate code for Coded UI test". If you do then the code will be added to the default "UImap.uitest" file, creating one if needed and with no warning that it is doing so. (See also http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3378897-choosing-the-uimap-when-recording-tests )
I have not found any way of moving items from one UI map file to another except by editing their XML sources and that is complicated.

Related

How to obtain a list of widgets in a windows form

I am trying to automate a help system. I have it set up so you right-click on any widget (Button, etc.) and one of the items is help. Selecting help causes a help file to display (PDF, HTML, or Wiki). Help positions the display to the paragraph that describes the widget. (The document is a hypertext document so the paragraph can contain cross links, etc.)
All of this is working. There is an implementation problem in that it is necessary to input the widget name manually when building the widget list for the help system. The problem is widgets can be renamed during development. New widgets can be added. Old ones deleted, etc. Maintenance becomes a problem.
So my question is, is it possible to obtain a list of widgets by form from a .net application being developed using Visual Studio? I don't mind scraping a set of files to extract the list, but I do need to automate obtaining the list so I can compare with the current list to determine any maintenance necessary to keep the help system in sync with the .net application.
Developer Studio does generate partial classes that do contain the information. Parsing these will be some effort since the parser must understand the format of the class. What would be nice is if Visual Studio had the ability to produce information about the structure of the app being developed.

Possible to include an image in the meta data in code? VS 2013

I would like to be able to include a screenshot of a control inside my code, this way making control identification easier for new members on my team, is such a thing possible?
Maybe even the ability to just have the image on a network share with the path in a comment, and then have a plugin that when hovering over the link brings up the image?
EDIT (More detail):
I'm creating a test project, the application under test has over 1000 controls, some of them are similar in name and purpose, this can make it difficult at times for developers to reuse the API I am creating because the control name is simply not enough for quick identification of the control in use.
I use the word API very loosely too, none of this stuff will be consumed in web services, and it will always be white box with developers including a project reference and have direct access to the source code.
For every form in my application (The test one), I have a controls.cs file where all the controls for that form in the application under test are listed - This is where I want the hover to screenshot ability in the control definitions.
Another sure factor is that all developers will be using VS2013 (For now the base version), later this could be update 1 or 2.
As the initial author and senior developer on this project, these hover / image references (in the code) will be as useful to me personally as any 3rd party developers, or any later developers to join the initiative.
Thanks again, and I added a bounty!
I believe you can use Whole Tomato's free SourceLinks Visual Studio extension to do what you want - or at least get pretty close to it.
Built-in Functionality:
Out of the box, the extension allows you to specify comment patterns you want users to be able to take an action on. Once the patterns are specified, SourceLinks will highlight any occurrences of those patterns in the text editor. You will be able to double click the highlighted items and perform a pre-configured action (such as opening a link in an internal/external browser, or launching an executable).
You can see an example in the SourceLinks configuration dialog shown below:
(source: wholetomato.com)
So you could use this feature pretty painlessly to define a keyword such as Control Image and then put comments like the following in your code:
// Control Image: my_smart_list.jpg
SourceLinks would allow you double click this text, and you could have that configured to launch the image (using a file:// or http:// url depending on how and where your images are stored) either inside Visual Studio in it's internal browser, or in an external browser.
Custom Tooltips!
Now, if you want to put in some more effort into this and actually write some code, then SourceLinks allows you to create API Extensions to display custom tooltips when the user hovers over the marked text in the editor. The default installation of SourceLinks comes with sample API extensions that you can copy to create your own. See the article linked at the very top of the answer for more details on these samples.
This post in the SourceLinks forum informs us that SourceLinks expects the custom API Extension to return the tooltip value as FlowDocument XAML text. This is awesome news for us, because a FlowDocument can contain many types of elements, including formatted text, hyperlinks, and images.
Imanges in a Flow document can be specified both inline as well as externally.
Hope this helps!
I would use doxygen -- create the images somewhere in the source tree and use doxygen comments. You can embed the \image command in source comments (see docs) and doxygen will generate all the HTML documentation from there. I think doxygen is a great tool for documenting a codebase as you can generate the documentation directly from comments in the source and distribute or host the HTML separately.

Build the tree hierarchy of apps in Coded UI test for windows phone without manually building the UIMap

I was looking for automation testing tools for Windows Phone like adb for Android or iOS instruments for iOS. I have found Coded UI Test. That works fine if you want to build your test on a subset of UI elements.
But I need to build the list of all UI elements dynamically, or rather I need to know the hierarchical tree of the window with which the user interacts (something similar to logElementTree in iOS instruments) during the test.
I wouldn't build UIMap for every page of my app. Instead I'd prefer to build the hierarchical tree of UIElements dynamically in order to find the element of interest (such as an object for a tap action) by its properties (name, text, bounds, etc.).
For example, to give you an idea, I would like to do something like this pseudo code:
listOfUIObjects = getWindowTree(app);
element=listOfUIObjects.getElementByText("Pippo");
element.tap();
Does someone of you know a way to do this with coded ui test?
If it's not possible, is there an automation tool to do this?
You won't grab a 'tree' as such, but you can search for controls programatically. Take a look here for a starter:
http://www.codewrecks.com/blog/index.php/2014/04/10/programmatically-use-of-coded-ui-in-visual-studio/
Another good place to look is the generated code behind a UI map - it will show you the search code used which you should be able to modify for your own uses.

Choosing between Excel Add-In, Template and Workbook?

I'm looking for some high-level help with determining the best type of Visual Studio 2010 project to use for an Excel custom application.
I will be developing a program that requires the user to enter a dataset in a particular way. Not using a form per se, but rather in columns and the program will need to do some custom validation on the items in order to prep the data. From there, the user will be able to conduct various operations on the data via a custom Ribbon and associated options. The program will also transmit the data via web service.
I've fooled around with the Add-In project and that gives me a lot of what I need but I'm wondering if a Template or Workbook project is better for this in terms of data entry and being able to "guide" the user a little more.
How do you go about choosing between which project type to use? Do all the project types support a custom Ribbon?
Sorry if this is too far off topic. I'm referring to VBA, not Visual Studio, but it might still be relevant.
With an AddIn, compared to a Workbook, you can separate your code from the user's data. So, if the code is complex, and you'll need to update it separately from user's workbooks with data, this is not a bad idea.
With an AddIn, you can add buttons that do things like check to make sure the user data workbook is ok, or process it in someway. However, the AddIn custom buttons will load ever time a user opens any Excel worksheet. This doesn't sound good, but in practice, isn't so bad. You can code your AddIn so it does nothing as long as no one uses a button, so it almost doesn't hurt load times, etc...
A Workbook might be useful if you need to really guide the user - that is, you cannot rely on the user to hit a button to verify something, and instead you need to verify on every change, for example. However, the workbook solution incorporates the user data and your code in the same workbook, so if you need to update the code for existing users' data, that's harder.
I use a combination of AddIn (.xlam) with buttons, and a template (with minimal self-describing data only).
I'm not sure about the template-only option, so won't comment on that.

How to add controls (programmatically) to a Visual Studio designer WinForm

In my current job we are not allowed to use databinding. I’m currently using a code generator (ORM) to generate the data layer objects. In the past I usually generated a data source (from the object) and do a drag and drop to automatically add the controls (with the correct databinding to the WinForm).
Is there is a way to do something similar (programmatically) using Visual Studio?
I tried to use the a copy and paste approach (by analyzing the data of the control, in the clipboard, generated by VS), but unfortunately the format used by VS to serialize the control to the clipboard is binary (I was hoping that the format was XML because I can easy modify that). Other approaches I tried was generating the designer code using a code generator. Unfortunately this only works if I want to create a new form but it is, from a practical point, unworkable if you want to add new controls to an existing form.
Controls are just objects. Any properties you can set in the designer can be set in code as well. And event handlers are just delegates. You can build the entire GUI without using the designer at all -- just write the code. I've done this several times with dynamically-generated GUI elements.
Spend some time reading through the code that the Visual Studio designer generates, and you'll quickly see how to do the same things by hand.

Resources