TestComplete 5 Sneak Peek: Firefox Support

Since TestComplete 5 is currently under development, the information contained in this article is not final and may change at any time.

One web browser that is growing in popularity in today's world is Mozilla's Firefox. According to different sources it started with a 1.5-2% share some two years ago with a 12-14% share of the global market today. With the browser's popularity on the rise and the shear number of people using it, developers are getting increasingly concerned about whether their projects will work correctly with browsers other than that developed by Microsoft. At AutomatedQA, we have received many requests from our users asking to implement support for the Mozilla Firefox browser in TestComplete, our automated test manager. To accommodate customers' needs, the company has improved the Web Testing Plug-in and included Firefox support through the Firefox Support Plug-in. Please note that the Web Testing and Firefox Support plug-ins are only included in TestComplete Enterprise.

Let's demonstrate how we can access elements on a web page that is displayed in the Firefox browser. Before we start, we need to make sure that the Web Testing and Firefox Support plug-ins are installed and enabled. To do this, invoke the Extensions dialog through the File | Install Extensions menu item and check whether the needed plug-ins are installed and enabled, that is, whether they are checked in the Active column.

Now we can search for elements on web pages opened in the Firefox browser. In TestComplete's Object Browser, processes containing Page elements are marked with the Open Application icon () in the object tree. The icon indicates that the process is "open" to TestComplete and the web page elements can be accessed from scripts. Find the Firefox node in the object tree and expand it. Then, expand the MozillaUIWindowClass window node and go through the hierarchy of the MozillaWindowClass and MozillaContextWindowClass windows until you find the window containing the Page object. The window hierarchy looks like this:

Click to display image

After you have found the Page object, you can explore the web page's elements. The elements can be displayed via two different object models: DOM or Tag. The model being used is specified by the Tree model project option. The DOM model is similar to the HTML object model used in web scripts. The Tag model provides more "readable" element names and can be useful in initial stages of testing to receive the general overview of the page. The following images show how different models affect the object tree:

Click to display image

DOM Model

Click to display image

Tag Model

If you are familiar with TestComplete 4, you may notice that TestComplete 5 implements support for Firefox the same way that Internet Explorer is supported. This means that you will need to make minimal changes to your scripts to be able to test web pages with the Firefox browser. The difference between Internet Explorer and Firefox is that the browsers use different window hierarchies for the Page object. Also, for web pages displayed in Internet Explorer TestComplete uses the NativeWebObject namespace to access specific methods and properties of web page elements. For Firefox, TestComplete uses the NativeFirefoxObject namespace. The namespaces provide similar functionality, so there won't be a big difference between scripts created for each browser.

Now let's analyze how TestComplete 5 works with a simple web page in the supported browsers. We will use the Tag tree model. To select this model:

  1. Open the project editor.
  2. Switch to the Properties page.
  3. Select the Web Testing group.
  4. Choose Tag from the drop-down list of the Tree model box:

    Click to display image

To prepare our sample project, we need to add the Win32 Tested Applications project item to it and then add two applications to the TestedApps list to launch Internet Explorer and Firefox respectively. The following figure shows the TestedApps editor and the needed settings.

Click to display image

We need to do the following to find information on TestComplete’s support for Web Testing Google:

  1. Open a browser (Firefox or Internet Explorer).
  2. Open the www.google.com web page.
  3. Enter "Does TestComplete support Web testing?" into the search field and click the "Google Search" button.
  4. Google will find a number of web pages that match the search criteria. Let's process the search results and post links from the first three pages of the search results to the test log.

The following script performs the described actions:

After the script is executed, the test log will contain the following messages:

Click to display image

As you can see, the test log contains a lot of links. Their names are listed in the upper log panel and the descriptions are shown in the Remarks panel. Each link is stored in the log as a link message, so you can open the appropriate web page just by clicking the link.

Now that you have seen how TestComplete 5 works with a page displayed in Mozilla's Firefox, let's take a closer look at our script. The two major routines are TestWithFirefox and TestWithIE. They are used to test web pages that are open in the corresponding browser. The routines obtain the Page object and then call the CollectLinks method that simulates user input and processes the results. To obtain text of a web control we use the GetContentTextFromElement script function. The way you get text depends on the browser and the function uses the appropriate properties to return the text.

We have demonstrated how TestComplete 5 recognizes objects viewed via Mozilla's Firefox Internet browser and how you can work with this browser from scripts. Also, we have compared how TestComplete works with Mozilla's Firefox and Microsoft's Internet Explorer. Now you can use TestComplete 5 to test web pages that are displayed in the Firefox browser, and if you have been using TestComplete to test pages viewed via Internet Explorer, you will need to make minor changes in your testing scripts to make them work with both browsers.


Close

By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox