Landscape Method

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

The Landscape method switches the mobile browser emulator to the landscape mode. This method should be applied to the VirtualBrowsers.CurrentBrowser object (see the example below).

Declaration

VirtualBrowserInfoObj.Landscape()

VirtualBrowserInfoObj An expression, variable or parameter that specifies a reference to a VirtualBrowserInfo object
Result None

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

  • For the Landsape method to work, the Chrome mobile emulator must already be running. You can run it by using the VirtualBrowsers.Item(browser_name).Run method.

  • The Landscape method logs a message if successful, and a warning if the mobile browser emulator is already in landscape mode.

  • The default orientation is determined by the Screen Width and Screen Height properties of the browser profile in Project Properties | Open Applications | Web Testing | Virtual Browsers (see Project Properties - Virtual Browsers Options).

  • To determine the current browser orientation from tests, compare the VirtualBrowsers.CurrentBrowser.ScreenWidth and ScreenHeight properties.

Example

The following example opens https://smartbear.com in the iPhone 7 emulator, and captures site screenshots in the portrait and landscape views.

JavaScript, JScript

function Test()
{
  VirtualBrowsers.Item("Apple iPhone 7").Run("http://smartbear.com");
  var page = Sys.Browser().Page("*smartbear.com*");

  VirtualBrowsers.CurrentBrowser.Landscape();
  Log.Picture(page.PagePicture(), "Site screenshot - landscape view");

  VirtualBrowsers.CurrentBrowser.Portrait();
  Log.Picture(page.PagePicture(), "Site screenshot - portrait view");

  Sys.Browser().Close();
}

Python

def Test():
  VirtualBrowsers.Item["Apple iPhone 7"].Run("http://smartbear.com")
  page = Sys.Browser().Page("*smartbear.com*")

  VirtualBrowsers.CurrentBrowser.Landscape()
  Log.Picture(page.PagePicture(), "Site screenshot - landscape view")

  VirtualBrowsers.CurrentBrowser.Portrait()
  Log.Picture(page.PagePicture(), "Site screenshot - portrait view")

  Sys.Browser().Close()

VBScript

Sub Test
  Dim page
  VirtualBrowsers.Item("Apple iPhone 7").Run("http://smartbear.com")
  Set page = Sys.Browser.Page("*smartbear.com*")

  Call VirtualBrowsers.CurrentBrowser.Landscape
  Call Log.Picture(page.PagePicture, "Site screenshot - landscape view")

  Call VirtualBrowsers.CurrentBrowser.Portrait
  Call Log.Picture(page.PagePicture, "Site screenshot - portrait view")

  Call Sys.Browser.Close
End Sub

DelphiScript

procedure Test;
var page;
begin
  VirtualBrowsers.Item('Apple iPhone 7').Run('http://smartbear.com');
  page := Sys.Browser.Page('*smartbear.com*');

  VirtualBrowsers.CurrentBrowser.Landscape();
  Log.Picture(page.PagePicture, 'Site screenshot - landscape view');

  VirtualBrowsers.CurrentBrowser.Portrait;
  Log.Picture(page.PagePicture, 'Site screenshot - portrait view');

  Sys.Browser.Close;
end;

C++Script, C#Script

function Test()
{
  VirtualBrowsers["Item"]("Apple iPhone 7")["Run"]("http://smartbear.com");
  var page = Sys["Browser"]()["Page"]("*smartbear.com*");

  VirtualBrowsers["CurrentBrowser"]["Landscape"]();
  Log["Picture"](page["PagePicture"](), "Site screenshot - landscape view");

  VirtualBrowsers["CurrentBrowser"]["Portrait"]();
  Log["Picture"](page["PagePicture"](), "Site screenshot - portrait view");

  Sys["Browser"]()["Close"]();
}

See Also

Testing Mobile Web Applications Using Emulator
Changing Mobile Browser Orientation
Portrait Method
CurrentBrowser Property

Highlight search results