Change screen orientation
Your test case may require you to change the device orientation of the device. You can change the screen orientation of an Android or iOS device to set your application in portrait or landscape mode during the execution of the test.
If you are using BrowserStack SDK, you can set the following capability within the browserstack.yml
file:
Capability
Description
Values
deviceOrientation
Set the screen orientation of mobile device
portrait, landscape Default: portrait
```yml
deviceOrientation: landscape
```
Copy icon
Copy
deviceOrientation : landscape
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page .
Use the following code snippet to change the orientation of your preferred device:
Capability
Description
Values
deviceOrientation
Set the screen orientation of mobile device
portrait, landscape Default: portrait
DesiredCapabilities capabilities = new DesiredCapabilities ( ) ;
HashMap < String , Object > browserstackOptions = new HashMap < String , Object > ( ) ;
browserstackOptions. put ( "deviceOrientation" , "landscape" ) ;
Copy icon
Copy
var capabilities = {
'bstack:options' : {
"deviceOrientation" : "landscape" ,
} ,
}
Copy icon
Copy
AppiumOptions capabilities = new AppiumOptions ( ) ;
Dictionary< string , object > browserstackOptions = new Dictionary< string , object > ( ) ;
browserstackOptions. Add ( "deviceOrientation" , "landscape" ) ;
Copy icon
Copy
$caps = array (
'bstack:options' => array (
"deviceOrientation" => "landscape" ,
) ,
)
Copy icon
Copy
desired_cap = {
'bstack:options' : {
"deviceOrientation" : "landscape" ,
} ,
}
Copy icon
Copy
capabilities = {
'bstack:options' = > {
"deviceOrientation" = > "landscape" ,
} ,
}
Copy icon
Copy
DesiredCapabilities desiredCapabilities = new DesiredCapabilities ( ) ;
desiredCapabilities. setCapability ( "deviceOrientation" , "landscape" ) ;
Copy icon
Copy
var capabilities = {
'deviceOrientation' : 'landscape' ,
}
Copy icon
Copy
DesiredCapabilities capability = new DesiredCapabilities ( ) ;
capability. SetCapability ( "deviceOrientation" , "landscape" ) ;
Copy icon
Copy
$capabilities = new DesiredCapabilities ( ) ;
$capabilities -> setCapability ( "deviceOrientation" , "landscape" ) ;
Copy icon
Copy
desired_cap = {
'deviceOrientation' : 'landscape'
}
Copy icon
Copy
desired_caps = {
'deviceOrientation' : 'landscape'
}
Copy icon
Copy
Is this page helping you?
Thank you for your valuable feedback!