, , , , , , , , ,

Having messed up some test projects in trying read values from CSV files, and emulating several online tutorials, I decided to try a different approach. A Coded UI Test project directory has UIMap.Designer.cs, which does pretty much the same thing as the CSV file, so why not edit that instead?


The easiest way of altering the parameters it contains is by double-clicking the UIMap.uitest entry in the Solution Explorer and changing the values in the Properties window.


The less convenient way of changing the parameters is by modifying the lines in UIMap.Designer.cs. It doesn’t work with passwords, though – these are stored in an encrypted form, and replacing it with a plaintext value would break the test script. Any new password must be encrypted beforehand.


Fortunately I din’t have to write a function for that, as Microsoft already provides one: Playback.EncryptText(). Simply use this, and change the variable passed to this function from the UIMap.Designer.cs.


But the whole point of adding a CSV file was to make it easier for others to change the test parameters. The next best thing is having all the variables declared near the head of UIMap.Designer.cs. Why not create another partial public class, and have the script reference that instead of this.[Method]Params class?

Just above the [GeneratedCode] in UIMap.Designer.cs, I inserted the following:


And changed the variables in the other class to reference them: