locked
Coded UI cross browser testing using handcoding. RRS feed

  • Question

  • Hi,

    I am handcoding a coded ui test for web application. I wrote around 30-40 common methods which takes browser name, doc friendlyname etc as parameter and perform operations like click, edit, hover etc. I wrote this by considering IE only but now we want to run in different browsers. I have made appropriate configurations in my machine and some of the basic methods like launch browser, click on link etc are working fine. But most of the others are failing.

    So, Below are my major queries.

    1. Is there are any precautions we need to take care of while writing methods?. Like which control specific properties to focus on?.

    2. Does developer needs to follow some standards which may help us in automation, like setting  specific properynames for links, buttons, div etc

    3. Whether there are any limitations of coded ui for cross browser testing and workaround if any.

    4. I have identified one issue. I used 'friendlyName' for HtmlDiv element and its working with ie but with chrome and firefox. For chrome its detecting div with 'netHidden' class.

    My configurations:

    1. VS2012 premium update 4.

    2. chrome ver. 35

    3. firefox ver. 27

    Thanks in advance

    Friday, June 13, 2014 7:05 AM

Answers

All replies

  • It is recommended that we use Id and/or Name properties as search properties. Simply because these properties will be mostly unique for each control on a page.

    TejasJ.

    Friday, June 13, 2014 1:11 PM
  • Hi Vijay

    As Trejas says but also you can use the Class property which varies a lot between browsers in your Filter Properties. See here for info in Search & Filter Properties Blog

    Friday, June 13, 2014 1:28 PM
  • Yes. I always give id/Name as first preference but in many cases i didnt find that field for various controls but friendly name. So, i used friendlyName in most of the cases. But it fails with chrome and firefox. Any alternative?

    Our developers are coding for web application. So, do they need to follow some practices so that we will be able to get those properties?

    Friday, June 13, 2014 2:32 PM
  • Hi,

    As Tejas said, generally we use Id and Name projects as search properties. In order to locate target controls better, you can use more unique properties as search properties such as DisplayName.

    Please reference this blog to know what properties Coded UI engine records as search proeprties/filter properties and then you can apply it in your hand coding test:

    http://blogs.msdn.com/b/visualstudioalm/archive/2012/12/10/coded-ui-test-configuring-search-properties-while-recording-on-internet-explorer.aspx

    This blog provided by Ian also can help you: How does “Coded UI test” finds a control ??

    Actually there are any limitations for cross browser coded UI test. Please see ‘Know Limitations’ section in this blog:

    http://blogs.msdn.com/b/visualstudioalm/archive/2012/10/30/introducing-cross-browser-testing-with-coded-ui-tests.aspx

    I met many people met any issues when playing back with non-IE browser. The latest version of Chrome and Firefox which have been verified and supported are version 32 and 26, maybe there are some existing and unknown issues when playing back on Chrome version 35 and Firefox version 27. So we recommend you to post your issue on this page for better support: http://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d through clicking ‘Q AND A’ and ‘start a discussion’ because such test uses Selenium components.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Wednesday, June 18, 2014 10:19 AM
    • Marked as answer by Amanda Zhu Friday, June 20, 2014 8:24 AM
    Monday, June 16, 2014 7:06 AM
  • Hi Zhu.

    Thank you for your reply. Yes, I have already visited those blogs but didnt find much relevant to what i am doing. This can be possible because i may be doing wrong. As i am completely new to coded ui and whatever i did is what i learn from msdn blogs or any other source from internet but till now its working as per our requirement except cross browser. Hope we are on right track. Can i share my sample code with you and you can share your opinion on it?

    Regards

    Vijay

    Tuesday, June 17, 2014 4:56 AM
  • Hi,

    You can send your sample project to me through uploading it to OneDrive and then posting the download link here. You said we did not help you on some issues, please tell us what you are doing and what real issues you are encountering. But if the issue is about cross browser testing with Coded UI as you described in your original post, as I suggested in my previous reply, you should consult on Selenium component page:  http://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d for better solution/support.

    Thank you for your understanding and support.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 17, 2014 5:07 AM
  • Hi,

    Currently i dont have access to OneDrive, so will do it later. Till now i can share few common/generic methods with you which we are using in our test methods by passing appropriate parameters to them.

    We are using below method to click on perticular link on page.

     public void ClickOnLink(string browserName, string docFriendlyName, div FriendlyName, string linkInnerText)
            {
                BrowserWindow browser = new BrowserWindow();
                browser.TechnologyName = "MSAA";
                browser.SearchProperties.Add("Name", browserName, PropertyExpressionOperator.Contains);

                HtmlDocument hDoc = new HtmlDocument(browser);
                hDoc.TechnologyName = "Web";
                hDoc.SearchProperties.Add("FriendlyName", docFriendlyName,               PropertyExpressionOperator.Contains);

                HtmlDiv hDiv = new HtmlDiv(hDoc);
                hDiv.TechnologyName = "Web";
                hDiv.SearchProperties.Add("FriendlyName", divFriendlyName,               PropertyExpressionOperator.Contains);

                HtmlHyperlink hLink = new HtmlHyperlink(hDiv);
                hLink.TechnologyName = "Web";
                hLink.SearchProperties.Add("InnerText", linkInnerText, PropertyExpressionOperator.Contains);

                if (hLink.Exists)
                {
                    Mouse.Click(hLink);
                    //Wait till browser finishes loading
                    Playback.Wait(1000);
                }

                else
                {
                    Assert.Fail("Given link doesnt exists in given page.");
                }

           }

    Tuesday, June 17, 2014 5:47 AM
  • Hi,

    What issues are you getting with this method? You said you are doing cross browser tests, whether this method failed when you played it back with non- IE browser?

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 17, 2014 6:12 AM
  • Hi,

    Yes. It does fail on non-ie browsers and it may be just because i used 'FriendlyName' for 'HtmlDiv'. Did you checked it?

    Regard

    Vijay

    Tuesday, June 17, 2014 7:08 AM
  • Hi,

    Because of some security reasons, it is hard for us to check this issue which is involved to VS Add-in: Selenium components for Coded UI cross browser testing, chrome driver and selenium dot bindings on our machine. I believe it is an issue on cross browser testing. In order to help you to resolve it, we recommend you to posting this issue to the development team of Selenium components for Coded UI cross browser testing: http://visualstudiogallery.msdn.microsoft.com/11cfc881-f8c9-4f96-b303-a2780156628d They will evaluate them seriously.

    Thank you for your understanding very much.

    Regard


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 17, 2014 9:54 AM