ExecuteAutomation

Understanding Why and How Parent-Child relationship works in Coded UI Testing

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

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