I'm evaluating the use of automated selenium tests using BrowserStack. I'm currently trying to change the orientation of a device that runs on an emulator on BrowserStack, either Android or iPad. I've implemented the IRotatable interface as per the Selenium documentation:
public class RotatableRemoteWebDriver : RemoteWebDriver, IRotatable
{
public RotatableRemoteWebDriver(Uri uri, DesiredCapabilities dc, ScreenOrientation initialOrientation = ScreenOrientation.Portrait): base(uri, dc)
{
this.Orientation = initialOrientation;
}
public ScreenOrientation Orientation
{
get
{
var orientationResponse = this.Execute(DriverCommand.GetOrientation, null);
return (ScreenOrientation)Enum.Parse(typeof(ScreenOrientation), orientationResponse.Value.ToString(), true);
}
set
{
var response = this.Execute(DriverCommand.SetOrientation, new Dictionary<string, object>() { { "orientation", value.ToString().ToUpperInvariant() } });
}
}
}
When I try to use this with iPad capabilities I get directly an exception saying "Invalid method for resource: POST /session/1d410f56479543a99410140bc39dc3d0d6d94c57/orientation". The same call for Android capabilities does succeed but it doesn't seem to change the orientation since I take a screenshot directly afterwards and the device is still in portrait mode.
Any idea if it is at all possible to change orientation through the Automate testing or should I give up and use the Screenshots API for this?
As i see, BrowserStack runs iPhone driver for selenium testing on iOS emulators. As the driver is deprecated as per selenium site [refer: https://code.google.com/p/selenium/wiki/IPhoneDriver], there are very limited commands supported for iOS in selenium. Orientation is one that is not supported by the driver itself. BrowserStack is working on the feature to provide the support and will update as soon as it is done.
For your android issue. Can you run your test in debug mode by passing "browserstack.debug" capability as "true". That will give you full desktop screenshot and show you the orientation before and after the command. You may see not difference in landscape and portrait screenshots if the site that you are trying to open is not responsive.
Hope I answered your concerns.