After downloading the extension, add the DLL to your references under your Coded UI Project. Please find below the sample documentation #Coded UI Usability Automation using JavaScript # Refer to http://geektester.blogspot.in/2013/02/coded-ui-usability-automation-using.html for more details # Send your feedback to rankumar@microsoft.com / rajkamal@microsoft.com
Demo:
C# Edit|Remove csharp//This method retreives the properties of hyperlink with inner text "News" and "Hotmail" [TestMethod] public void CodedUITestMethod1() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "a", "News,Hotmail"); foreach (UsabilityAutomation.Repository prop in list) { Assert.AreEqual(prop.font_family, "Arial,Sans-Serif"); Assert.AreEqual(prop.text_decoration, "none"); } } //This method retrieves the properties of div element whose id is "hp_container " [TestMethod] public void CodedUITestMethod2() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "div","hp_container"); foreach (UsabilityAutomation.Repository prop in list) { Assert.AreEqual(prop.margin_left, "117px"); Assert.AreEqual(prop.font_size, "13.33px"); Assert.AreEqual(prop.width, "1366px"); Assert.AreEqual(prop.color, "rgb(0, 0, 0)"); } } //This method retrieves the properties of input element whose id is "sb_form_q" [TestMethod] public void CodedUITestMethod3() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "input", "sb_form_q"); foreach (UsabilityAutomation.Repository prop in list) { Assert.AreEqual(prop.padding_left, "9px"); Assert.AreEqual(prop.padding_right, "5px"); } } //This method retrieves the properties of all input element present on the page [TestMethod] public void CodedUITestMethod4() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "input"); foreach (UsabilityAutomation.Repository prop in list) { // your assert logic } } //This method retreives the properties of hyperlink with inner text "News" and "Hotmail" [TestMethod] public void CodedUITestMethod1() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "a", "News,Hotmail"); foreach (UsabilityAutomation.Repository prop in list) { Assert.AreEqual(prop.font_family, "Arial,Sans-Serif"); Assert.AreEqual(prop.text_decoration, "none"); } } //This method retrieves the properties of div element whose id is "hp_container " [TestMethod] public void CodedUITestMethod2() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "div","hp_container"); foreach (UsabilityAutomation.Repository prop in list) { Assert.AreEqual(prop.margin_left, "117px"); Assert.AreEqual(prop.font_size, "13.33px"); Assert.AreEqual(prop.width, "1366px"); Assert.AreEqual(prop.color, "rgb(0, 0, 0)"); } } //This method retrieves the properties of input element whose id is "sb_form_q" [TestMethod] public void CodedUITestMethod3() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "input", "sb_form_q"); foreach (UsabilityAutomation.Repository prop in list) { Assert.AreEqual(prop.padding_left, "9px"); Assert.AreEqual(prop.padding_right, "5px"); } } //This method retrieves the properties of all input element present on the page [TestMethod] public void CodedUITestMethod4() { BrowserWindow bw = BrowserWindow.Launch(new Uri("http://www.bing.com/")); bw.WaitForControlReady(); List<UsabilityAutomation.Repository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "input"); foreach (UsabilityAutomation.Repository prop in list) { // your assert logic } }
|