Thursday, February 14, 2013

Coded UI Usability Automation using JavaScript


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

# Send your feedback to rankumar@microsoft.com / rajkamal@microsoft.com

     
//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();

            ListRepository> 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();

            ListRepository> 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();

            ListRepository> 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();

            ListRepository> list = UsabilityAutomation.Usability.GetUsabilityProperties(bw, "input");

            foreach (UsabilityAutomation.Repository prop in list)

            {

                // your assert logic

 

              

 

            }

 

        }

3 comments:

xyz123 said...

Hello, i downloaded already your Extension to Visual Studio. I looked up your Video which you also posted, but you are choosing an template, when you open up a project. This template isnt more available to download. Where can i find it?

Very Great Idea!! I think this will get very succesful! Thank you for developing this...

Can i ask you some question or contact you please?

xyz123 said...

Oh no sorry, i already found the projekt template. Sorry for misunderstanding. Thank you for this gread extension...
Is there also any function to grab images from web Component?

contact microsoft hotmail said...

Thank you. Your blog was very helpful and efficient For Me,Thanks for Sharing the information.