UserAgent Property

Applies to TestComplete 15.64, last modified on May 16, 2024


The UserAgent property returns the user agent string of the given mobile browser profile (specified by the VirtualBrowserInfoObj object). The user agent string identifies the browser to web servers so that they can return browser-specific content if needed.

The user agent strings of all mobile browser profiles that can be used in a test project are specified in the project’s Open Applications | Web | Virtual Browsers properties.



Read-Only Property String
VirtualBrowserInfoObj An expression, variable or parameter that specifies a reference to a VirtualBrowserInfo object

Applies To

The property is applied to the following object:

Property Value

The user agent string of a mobile browser. For example, the user agent string of the iPhone 7 browser emulator is as follows:

Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A5297c Safari/602.1

You can find more user agent examples here: Browser


The following example logs the user agent of the iPad browser emulator:

JavaScript, JScript

function Test()
  var uastr = VirtualBrowsers.Item("Apple iPad").UserAgent;
  Log.Message("iPad user agent: " + uastr);


def Test():
  uastr = VirtualBrowsers.Item["Apple iPad"].UserAgent;
  Log.Message("iPad user agent: " + uastr);


Sub Test
  Dim uastr
  uastr = VirtualBrowsers.Item("Apple iPad").UserAgent

  Log.Message "iPad user agent: " & uastr
End Sub


procedure Test;
var uastr;
  uastr := VirtualBrowsers.Item('Apple iPad').UserAgent;
  Log.Message('iPad user agent: ' + uastr);

C++Script, C#Script

function Test()
  var uastr = VirtualBrowsers["Item"]("Apple iPad")["UserAgent"];
  Log["Message"]("iPad user agent: " + uastr);

See Also

Testing Mobile Web Applications Using Emulator
VirtualBrowserInfo Object
ScreenHeight Property
ScreenWidth Property
DevicePixelRatio Property
Name Property
RunOptions Property

Highlight search results