Check if Browser Is Running

Applies to TestComplete 15.63, last modified on April 23, 2024

In your web tests, you may want to check if the web browser in which your test will simulate user action is actually running before the simulation starts. This topic describes how you can check from your tests whether the web browser is running.

Note: Due to the specifics of implementation of cross-platform web tests, you launch a web browser at the beginning of the test run (see Connect to Device Lab and Launch Web Browser). The testing session exists while the web browser is running and stops as soon as the web browser is closed.

In Keyword Tests

To check if the needed web browser is running, you can use If Object operation where the Object parameter is set to Sys.WaitBrowser() and the Condition parameter is set to Exists.

The image below demonstrates a sample keyword test that checks if a browser is running and simulates user actions on success:

Checking if browser is running from keyword tests

Click the image to enlarge it.

In Scripts

To check whether the browser is running, you can use the Sys.WaitBrowser().Exists property:

In web tests that implement the classic approach, you can specify the exact browser to check.

JavaScript, JScript


if (Sys.WaitBrowser("chrome").Exists)
{
  // Simulate user actions
  …
}

Python


if (Sys.WaitBrowser("chrome").Exists):
  # Simulate user actions
  …

VBScript


If Sys.WaitBrowser("chrome").Exists Then
  ' Simulate user actions
  …
End If

DelphiScript


if Sys.WaitBrowser('chrome').Exists then
begin
  // Simulate user actions
  …
end;

C++Script, C#Script


if (Sys["WaitBrowser"]("chrome")["Exists"])
{
  // Simulate user actions
  …
}

See Also

How To
Connect to Device Lab and Launch Web Browser (Cross-Platform Web Tests)
Launch Web Browsers (Classic Web Tests)
Close Web Browsers

Highlight search results