Portrait Method

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


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



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



  • For the Portrait 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 Portrait 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.


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*");

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

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



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

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

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



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


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

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

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


C++Script, C#Script

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

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

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


See Also

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

Highlight search results