1

This is my first time tangling with Coded UI and I've hit my first real speed bump. I don't have Microsoft Test Manager which may make this process trivial, but I'm having a heck of a time.

I have a text box, let's call it 'Project Name'. I want to run a small test in several iterations, each one using a different Project Name (the static value is set as 'Castle'). I have my CSV file created and my Data Source set, but I cannot find the right syntax to use TestContext to point the variable to the CSV.

Everything I've found says to use some variation of 'SearchProperties[WpfButton.PropertyNames.SOMETHING] = TestContext.DataRow["ProjectName"].ToString();'.

My issue is I can't find anything in PropertyNames that represents the value of the input string, nor does adding 'value' as a property do anything. The only place in the UImap that I can find the static Value set is in the UI actions tree, in the SetValueActionWrapper properties.

How do I specify the right value? The frustrating thing is this is an extremely trivial task in the other automation tools that I've used, but I'm not a strong coder. Please advise!

1 Answers1

0

A simple way to do this is to let Coded UI teach you how to do it. In a sandbox project use Coded UI to record the required actions then copy the interesting or useful pieces into your own tests. For entering text into a text box you could just record the displaying of the text box and the typing of the text. For much more on how to data drive with Coded UI see this Stack Overflow answer.

Whilst MTM is a very useful program I believe it would not make the problem you have any easier.

Community
  • 1
  • 1
AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
  • Thanks for the article, that looks helpful. So if the method that the recorder comes up with is this; – Aryeh Gildiner Oct 21 '16 at 18:07
  • public void TypeProjectName() { #region Variable Declarations WpfEdit uIItemEdit = this.UIUploadProjectWindow.UIItemEdit; #endregion // Type 'Castle' in text box uIItemEdit.Text = this.TypeProjectNameParams.UIItemEditText; – Aryeh Gildiner Oct 21 '16 at 18:08
  • I revised the code to 'this.UIMap.UIUploadProjectWindow.UIItemEdit.Text = TestContext.DataRow["ProjectName"].ToString();' where ProjectName is the first column in my CSV. The exception I get is "Column ProjectName does not belong to table ." Is the format of my CSV wrong? There are no spaces, no quotes, just commas. – Aryeh Gildiner Oct 21 '16 at 18:52
  • The code looks OK, but you have not shown the CSV file (only the top 2 or 3 lines is needed). See also http://stackoverflow.com/a/24768318/546871 about the BOM issue with CSV files. – AdrianHHH Oct 21 '16 at 20:10