DevicePixelRatio Property

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

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).

Declaration

VirtualBrowserInfoObj.DevicePixelRatio

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.

Remarks

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

Example

JavaScript, JScript

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

Python

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

VBScript

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

DelphiScript

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

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