@@ -49,6 +49,7 @@ import { screencapture } from "./helpers/screenshot-manager";
4949import { LogImageType } from "./enums/log-image-type" ;
5050import { DeviceOrientation } from "./enums/device-orientation" ;
5151import { NsCapabilities } from "./ns-capabilities" ;
52+ import { AutomationName } from "./automation-name" ;
5253
5354export class AppiumDriver {
5455 private _defaultWaitTime : number = 5000 ;
@@ -548,14 +549,15 @@ export class AppiumDriver {
548549 await this . _driver . setOrientation ( orientation ) ;
549550
550551 if ( orientation === DeviceOrientation . LANDSCAPE && this . isAndroid ) {
551- if ( ( < NsCapabilities > this . nsCapabilities ) . tryGetApiLevel ( ) < 6.0 ) {
552+ if ( ( < NsCapabilities > this . nsCapabilities ) . automationName === AutomationName . UiAutomator1
553+ || ( < NsCapabilities > this . nsCapabilities ) . automationName === AutomationName . Appium ) {
552554 // HACK since the image is rotated and action bar is on the bottom of the image, it is needed to exclude action bar from bottom.
553555 const height = this . _imageHelper . options . cropRectangle . width - this . _imageHelper . options . cropRectangle . y ;
554556 const width = this . _imageHelper . options . cropRectangle . height + this . _imageHelper . options . cropRectangle . y ;
555557 this . imageHelper . options . cropRectangle . y = 0 ;
556558 this . imageHelper . options . cropRectangle . width = width ;
557559 this . imageHelper . options . cropRectangle . height = height ;
558- } else if ( ( < NsCapabilities > this . nsCapabilities ) . tryGetApiLevel ( ) >= 6.0 ) {
560+ } else if ( ( < NsCapabilities > this . nsCapabilities ) . automationName === AutomationName . UiAutomator2 ) {
559561 const height = this . _imageHelper . options . cropRectangle . width - this . imageHelper . options . cropRectangle . y ;
560562 const width = this . _imageHelper . options . cropRectangle . height + this . imageHelper . options . cropRectangle . y ;
561563 this . imageHelper . options . cropRectangle . width = width ;
0 commit comments