Choosing Web Tree Model

The structure of web-elements representation in Object Browser depends on the project setting Web Tree Model. This setting affects the way that web elements are displayed in Object Browser and accessed from scripts.

In this recipe we will consider the available web application models.

How to do it...

To change the Web Tree Model settings, it is necessary to perform the following actions:

  1. Right-click on the name of the project and navigate to the Edit | Properties menu item.
  2. Open the following group of settings: Open Application | Web Testing | General.
  3. In the Tree model drop-down list, select one of the elements (Tree, DOM, Tag, or Hybrid).
    How to do it...
  4. Save the changes by pressing Ctrl + S.
  5. The controls elements in the browser will be shown differently, depending on the selected model. Accessing those from the scripts will be different as well.

How it works...

TestComplete supports the following models for web applications:

  • Tree: This is the recommended model (in TestComplete 9 all the other models are considered as obsolete and necessary only for backward compatibility with the previous versions). When the Tree is being used, the hierarchy of control elements in Object Browser corresponds with that of the application. The Tree is the only model with cross-browser testing support.
    How it works...
  • DOM: In this model all the webpage elements are available as siblings of the document.all element. If the page contains frames, they can be accessed via the document.frames object, similarly to the way they are represented in the DOM model of the webpages.
    How it works...
  • Tag: When using this model, the control elements are grouped by tags in the elements with the corresponding names. The elements that are found to be singular (for example, HTML, BODY, and so on) do not have sibling elements; rather they directly correspond to the eponymous page elements.
    How it works...
  • Hybrid: This is a combination of models Tree and DOM that is meant for creation of the new scripts with the use of the recommended Tree model, simultaneously lending support for the older scripts which utilized the DOM model:
    How it works...

If you are not content with the recommended Tree model, you can try using other models; however, the cross-browser TestComplete testing possibilities will not be available.

There's more...

If you have some older scripts, written with the help of the Tag model, and you're willing to write some new ones using the recommended Tree model, you could dynamically signify which model to use for each of the tests. An instance of dynamically changing the objects model from script is shown in the following code snippet:

Options.Web.TreeModel = "Tag"
Options.Web.TreeModel = "Tree"

See also

  • You can read more about cross-browser testing in the Performing Cross-browser testing recipe in this chapter
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.159.82