What is the best way to handle configuration settings in a c# selenium project?

37 views
Skip to first unread message

David Lai

unread,
Apr 18, 2014, 1:58:44 PM4/18/14
to seleniu...@googlegroups.com
I was wondering how do you handle config management where you need to switch between browsers, platforms, and enviornments? (I'm currently running c# / NUnit as my framework)

Currently I'm using App.config with SlowCheetah transformations.  But the weakness here is I'll need to create either custom xml transform rules or a build configuration for every browser x platform x environment configuration.  Which doesn't seem that intuitive for my particular use case.  

I'm thinking of maybe writing my own config manager that supports cascading config settings so I can apply one after another with the control of which ones to apply from system environment variable.  But I thought I might ask around first to see if there's already a better solution that exists.

Shawn McCarthy

unread,
Apr 18, 2014, 6:55:31 PM4/18/14
to seleniu...@googlegroups.com
I use Java instead of C#, but the way I do it is by using JVM arguments for the browser, platform, and a lot of other things. I use property files for the environment specific items (like backend databases).

David Lai

unread,
Apr 24, 2014, 1:18:33 PM4/24/14
to seleniu...@googlegroups.com
I decided to just bite the bullet and write my own config manager using cascading json with overrides via environment variable.  I think the XML/XSLT transforms used by Web.Config and and SlowCheetah has an inherent weakness in that it relies too much on the build process.  Ideally I'd like to just drop a config file and it'll run, I can set some envionrment variables on the fly and it should pick up those changes.  The idea of a separate build task for each config combination seems not intuitive for a test project.

I'm using the Newtonsoft.Json package to do the Json parsing.  Basically creating a method ConfigReader.get<T>(string settingKey).  Which will grab the json value from the config file, then use the appropriate type converter to convert into the desired object.  So I can create say a desired capabilities type converter that can convert a serialized desired capability from json file.
Reply all
Reply to author
Forward
0 new messages