Description
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).
Declaration
VirtualBrowserInfoObj.Portrait()
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
Portrait
method to work, the Chrome mobile emulator must already be running. You can run it by using theVirtualBrowsers.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
andScreenHeight
properties.
Example
The following example opens http://smartbear.com in the iPhone 5 emulator, and captures site screenshots in the portrait and landscape views.
JavaScript, JScript
function Test()
{
VirtualBrowsers.Item("Apple iPhone 5").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 5"].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 5").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 5').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 5")["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
Landscape Method
VirtualBrowsers.CurrentBrowser Property