Have you tried:
var orientation = UIATarget.localTarget().deviceOrientation()
From the documentation:
deviceOrientation
Discussion
The returned value is a constant that represents the physical orientation of the device and may be different from the current orientation of your app’s user interface. The possible values are as follows:
UIA_DEVICE_ORIENTATION_UNKNOWN
UIA_DEVICE_ORIENTATION_PORTRAIT
UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN
UIA_DEVICE_ORIENTATION_LANDSCAPELEFT
UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT
UIA_DEVICE_ORIENTATION_FACEUP
UIA_DEVICE_ORIENTATION_FACEDOWN
EDIT
Device orientation is probably not available on the simulator. It's better to use interfaceOrientation()
on the UIAApplication
object instead.
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var orientation = app.interfaceOrientation();
if (orientation == UIA_INTERFACE_ORIENTATION_PORTRAIT || orientation == UIA_INTERFACE_ORIENTATION_PORTRAIT_UPSIDEDOWN) {
UIALogger.logDebug("Portrait");
} else if (orientation == UIA_INTERFACE_ORIENTATION_LANDSCAPELEFT || orientation == UIA_INTERFACE_ORIENTATION_LANDSCAPERIGHT) {
UIALogger.logDebug("Landscape");
}
This guide is pretty good.