0

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?

kkara
  • 791
  • 1
  • 9
  • 11

1 Answers1

1

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.

dhimil
  • 81
  • 3
  • Thank you for your response, I see now that the iPhone driver doesn't support it. For android though, I set debug to true and saw that the Set Orientation LANDSCAPE command is sent and seems to be understood. But the screenshots I capture before and after changing the orientation are identical, both are portrait screenshots. – kkara Dec 19 '13 at 22:26
  • Oh.. This should happen if the site is not responsive (does not change dimensions on orientation change. Would it be possible for you to ping the site? – dhimil Jan 04 '14 at 07:45