DevicePixelRatio Property

Applies to TestComplete 15.65, last modified on July 17, 2024


The DevicePixelRatio property returns the ratio of physical pixels per CSS pixel emulated for the specified mobile browser. For example, Apple devices with Retina displays (like iPhone 6) have the device pixel ratio of 2, which means that one CSS pixel is displayed using 4 physical pixels – 2 horizontally and 2 vertically.

This is the same value as specified in the Device Pixel Ratio column in Project Properties | Open Applications | Web Testing | Virtual Browsers (see Project Properties - Virtual Browsers Options).



Read-Only Property Double
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 ratio of physical pixels to CSS pixels.


For information about specifying screen parameters for the mobile browser emulator, see Creating Mobile Browser Profiles.


JavaScript, JScript

function Test()
  var ipad = VirtualBrowsers.Item("Apple iPad");
  Log.Message("iPad device pixel ratio: " + ipad.DevicePixelRatio);


def Test():
  ipad = VirtualBrowsers.Item["Apple iPad"];
  Log.Message("iPad device pixel ratio: " + aqConvert.VarToStr(ipad.DevicePixelRatio));


Sub Test()
  Dim ipad
  Set ipad = VirtualBrowsers.Item("Apple iPad")
  Log.Message("iPad device pixel ratio: " & ipad.DevicePixelRatio)
End Sub


function Test();
var ipad: variant;
  ipad := VirtualBrowsers.Item('Apple iPad');
  Log.Message('iPad device pixel ratio: ' + aqConvert.VarToStr(ipad.DevicePixelRatio));

C++Script, C#Script

function Test()
  var ipad = VirtualBrowsers["Item"]("Apple iPad");
  Log["Message"]("iPad device pixel ratio: " + ipad["DevicePixelRatio"]);

See Also

Testing Mobile Web Applications Using Emulator
Creating Mobile Browser Profiles
VirtualBrowserInfo Object
ScreenWidth Property
UserAgent Property
Name Property
RunOptions Property

Highlight search results