I have been playing around with this idea for quite some time and I already build this for a customer in the past, but after questions I got from people using CodedUI who tried to come up with a simplified syntax I thought it would be time to publish what I have at the moment.
If you hand code your test automation with CodedUI, then you know that searching for a control is always a couple of lines of code to set up a search. You first create an instance of the control you need, provide it the search scope in the constructor and next you need to set the search properties. Once that is done you can then use the control and the moment you use one of it’s properties it will search for your control.
With Selenium this is a bit different. You have the Driver class that provides more or less to primary methods. FindElement and FindElements and you provide it an instance of the By class that contains the search criteria.
Let me illustrate what I mean with two examples. Bot do the same. We goto the google home page and type a search query.
CodedUI:
|
BrowserWindow b = BrowserWindow.Launch(new Uri("http://google.com")); HtmlEdit searchBox = new HtmlEdit(b); searchBox.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "lst-ib"); Keyboard.SendKeys(searchBox, "codedUI Course{Enter}"); |
Selenium:
|
var driver = new ChromeDriver(@"driverfolder"); driver.Navigate().GoToUrl("http://google.com"); var searchBox = driver.FindElement(By.Id("lst-ib")); searchBox.SendKeys("codedUI Course{Enter}"); |
In general I hear that people like the Selenium syntax more then the multistep aproach in codedUI. The thing I dislike is that I lose the type safety of the type of control. So the question is, would it be possible to get the same syntax for codedUI and still use codedUI and get a type safe way of interacting with the search controls?
Continue reading