Site Loader
Auckland, New Zealand
In the last post, we discussed hand coding web application in coded UI testing and also we faced problem while trying to identify controls of next page (which was User Form Page) The problem was, every time while identifying a control from next page, we were needed to re-identify BrowserWindow and HtmlDocument as the parent of the control within the page, hence, the hierarchy for identifying any given control was this

Figure 1: Parent-Child Relationship

We can also view the same relation in UIMap.Uitest window, which looks something like this

Figure 2: UIMap.Uitest of Visual Studio

Why do we need relationship?

Before answering this question, let’s take our most popular browser automation testing tool Selenium. Let’s examine the code snippet below

Figure 3: Selenium Code Snippet (JAVA)

The above code snippet leaves us with following questions

  • Where is the relationship of controls maintained?
  • How does Selenium manage to identify the controls?
As shown in the code snippet, we are first creating the instance for WebDriver and then using this instance, we are finding all the controls, thus, the in selenium the relationship for identify each and every controls are by default maintained using the instance of Web Driver. Needless of where the browser takes the page, the web driver has the handle for every controls, hence there require no relationship. Here is the complete video of the above post Thanks for reading the post and watching the video !!! Please leave your comments and let me know if there is anything I need to improve in the post and video !!! Thanks, Karthik KK

Post Author: Karthik kk

20 Replies to “Understanding Why and How Parent-Child relationship works in Coded UI Testing”

  1. I am a regular reader of your blog which helping to learn Codedui in simple way.
    It would be really helpful for beginner if you share sample codedui project with framework.

      1. HI Karthik ,Have you posted the codedui sample project with framework in Github?
        It will be very useful to learn.
        Thank you,

  2. while creating the build in VSTS 2013, I am getting the fllowing issue.
    please suggest me how to slove this issue

    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (32561): Type ‘HtmlDocument’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34428): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34426): Type ‘HtmlHyperlink’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34422): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34418): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34416): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34412): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34408): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34404): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34400): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34394): Type ‘HtmlDiv’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34392): Type ‘HtmlEdit’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34390): Type ‘HtmlComboBox’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34388): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34384): Type ‘HtmlInputButton’ is not defined.
    C:\Builds\1\SHFL\shfl\src\SHFL complete testcase process\UIMap.Designer.vb (34382): Type ‘HtmlDiv’ is not defined.

    Thanks in Advance.

    1. Seems like reference to HtmlControl class is missing and hence its throwing this error.

      Can you check reference to the project as well as the DLL which is referencing it.

      Thanks,
      Karthik KK

  3. Hello Kartik,
    Thank you for the videos.

    I am getting error , when i tried to implement the section that is in the above video.

    Error 4 An object reference is required for the non-static field, method, or property ‘IMTtestCode.Testclass.parentwindow.get’

    Thanks,
    Bina

    1. I suspect the problem is somewhere in the way you are accessing the static property, if your accessing method as access specifier as static, then you will not have this problem.

      Please let me know if you have same problem

      Thanks,
      Karthik KK

  4. Hi Karthik,
    Thanks for free knowledge transfer through videos.
    I have below problem:
    1) In 15th video, you used as public static void CustomWebMethod() and in 16th video it is showing directly as public void CustomWebMethod.
    2) Because of removing static, i am unable to call this class in CodedUITestMethod1 because it is not static.
    Please let me know how can i overcome this problem.

  5. Hi Karthik,

    I am undergoing the videos of all about codedUI, It was great and much appreciated. After studying these I gained my confidence level in coded ui. However, I am going to complete all videos in another 2 o 3 days, so do we expect any more videos on coded ui apart from this in future?

    Thanks,
    Shiva

  6. Hey Karthik,

    Do you have the finished code for the CustomCaller.cs in this vid? I’m having trouble finding out what is wrong with my test. I keep getting “An object reference is required for the non-static field, method, or property ‘CustomCaller.CustomWebMethod()’ and my test is underlined in red. What kinds of things should i be looking for to fix this?

  7. Hi Karthik,
    In this vedio series you have explained ablout the parent child relationship for web. How about the Windows appliction. I have tried similar with the windows but currentwindow is not working the windows application.

Leave a Reply to Yogesh Kolhe Cancel reply

Your email address will not be published. Required fields are marked *