Web Testing with Firefox

Applies to TestComplete 15.81, last modified on March 04, 2026

Firefox 116 and later use the WebDriver BiDi protocol for automation in TestComplete. Firefox versions 115 and earlier rely on internal Firefox APIs, which could change without notice.

WebDriver BiDi is a standards-based protocol. Some behaviors in Firefox 116 and later might differ from earlier versions. If you run into issues, contact the Support Team.

This topic describes important considerations for automated web testing in Firefox. Due to browser security restrictions, you must start Firefox with the --remote-debugging-port command-line switch when recording or playing back tests.

Running the browser

Due to browser security restrictions, when starting Firefox manually for test recording or playback in TestComplete, you must include the --remote-debugging-port command-line switch.

C:\Program Files\Mozilla Firefox>firefox --remote-debugging-port=9222

You can specify any available port instead of 9222.

The --remote-debugging-port switch enables TestComplete to communicate with Firefox.

Note: TestComplete’s Run Browser operation automatically appends the required --remote-debugging-port switch and selects the first available port. If you use Run Browser, no additional configuration is required.

When starting Firefox from the Tested Apps list, specify firefox.exe as the executable and include the --remote-debugging-port switch in the command-line parameters.

Additional limitations

  • Only one Firefox instance can be active during test recording or playback.

  • To close browser tabs, use the following script temporarily:

    Sys.Browser("firefox").Page("http://your-page-url.org").Close();

  • Firefox must be started with the --remote-debugging-port command-line switch. This port enables TestComplete to connect to Firefox. Ensure the specified port is available and not blocked by firewall rules.

  • After the remote debugging connection is established, TestComplete uses the WebSockets protocol (localhost) for internal communication with the browser. By default, TestComplete attempts to use port 8080 and checks sequential ports if that port is unavailable.

    The WebSockets port is separate from the --remote-debugging-port specified when starting Firefox. If WebSockets are disabled or blocked, communication fails and testing is not possible.

  • To confirm a dialog box, use the script:

    Sys.Browser("firefox").Page("http://your-page-url.org").ConfirmAlertDialogOK();

  • To cancel a confirmation dialog, use:

    Sys.Browser("firefox").Page("http://your-page-url.org").ConfirmDialogCancel();

Accessing Extended JS/HTML Properties

To retrieve specific HTML or JavaScript properties in your test, use scripting. Full object-based access is not currently available.

Use the following sample to get the number of columns in the first table on a page:

function GetNumberOfColumnsInTheFirstTable() {
 var numberOfColumns = Sys.Browser("firefox").Page("https://your-page-url.org").Eval(" \
 (function() { \
  var table = document.getElementsByTagName('table')[0]; \
  var headerRow = table.rows[0]; \
  var numberOfColumns = headerRow.cells.length; \
  return numberOfColumns; \
 })(); \
 ");
 Log.Message("numberOfColumns=" + numberOfColumns);
}

The Eval function executes the provided string as a client-side script in the context of the web page, similar to using a browser’s developer console.

See Also

Preparing Web Browsers
Classic Web Testing
Requirements for Web Testing

Highlight search results