ScreenHeight Property

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

Description

The ScreenHeight property returns the screen height (in CSS pixels) defined in a mobile browser profile. Browser profiles are configured in the project’s Virtual Browsers properties; the browser screen height is specified in the Screen height column.

Declaration

VirtualBrowserInfoObj.ScreenHeight

Read-Only Property Integer
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 browser screen height in CSS pixels.

Remarks

The browser screen size of a mobile device is not necessarily the same as the device’s physical screen resolution.

For example, Apple devices with Retina displays have double pixel density and show 1 CSS pixel using 4 physical pixels (2×2). While iPhone 5’s physical resolution is 1136×640, its browser screen size is 568×320 CSS pixels.

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

Example

The following code checks the screen orientation of a mobile browser.

JavaScript, JScript

function Test()
{
  var browserInfo = VirtualBrowsers.Item("Apple iPad");

  if (browserInfo.ScreenHeight > browserInfo.ScreenWidth)
    Log.Message("The 'Apple iPad' emulator has portrait orientation.")
  else
    Log.Message("The 'Apple iPad' emulator has landscape orientation.");
}

Python

def Test():
  browserInfo = VirtualBrowsers.Item["Apple iPad"]

  if browserInfo.ScreenHeight > browserInfo.ScreenWidth:
    Log.Message("The 'Apple iPad' emulator has portrait orientation.")
  else:
    Log.Message("The 'Apple iPad' emulator has landscape orientation.")

VBScript

Sub Test
  Dim browserInfo
  Set browserInfo = VirtualBrowsers.Item("Apple iPad")

  If browserInfo.ScreenHeight > browserInfo.ScreenWidth Then
    Call Log.Message("The 'Apple iPad' emulator has portrait orientation.")
  Else
    Call Log.Message("The 'Apple iPad' emulator has landscape orientation.")
  End If
End Sub

DelphiScript

procedure Test;
var browserInfo;
begin
  browserInfo := VirtualBrowsers.Item('Apple iPad');

  if browserInfo.ScreenHeight > browserInfo.ScreenWidth then
    Log.Message('The "Apple iPad" emulator has portrait orientation.')
  else
    Log.Message('The "Apple iPad" emulator has landscape orientation.');
end;

C++Script, C#Script

function Test()
{
  var browserInfo = VirtualBrowsers["Item"]("Apple iPad");

  if (browserInfo["ScreenHeight"] > browserInfo["ScreenWidth"])
    Log["Message"]("The 'Apple iPad' emulator has portrait orientation.")
  else
    Log["Message"]("The 'Apple iPad' emulator has landscape orientation.");
}

See Also

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

Highlight search results