@@ -49,6 +49,7 @@ import { screencapture } from "./helpers/screenshot-manager";
49
49
import { LogImageType } from "./enums/log-image-type" ;
50
50
import { DeviceOrientation } from "./enums/device-orientation" ;
51
51
import { NsCapabilities } from "./ns-capabilities" ;
52
+ import { AutomationName } from "./automation-name" ;
52
53
53
54
export class AppiumDriver {
54
55
private _defaultWaitTime : number = 5000 ;
@@ -548,14 +549,15 @@ export class AppiumDriver {
548
549
await this . _driver . setOrientation ( orientation ) ;
549
550
550
551
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 ) {
552
554
// 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.
553
555
const height = this . _imageHelper . options . cropRectangle . width - this . _imageHelper . options . cropRectangle . y ;
554
556
const width = this . _imageHelper . options . cropRectangle . height + this . _imageHelper . options . cropRectangle . y ;
555
557
this . imageHelper . options . cropRectangle . y = 0 ;
556
558
this . imageHelper . options . cropRectangle . width = width ;
557
559
this . imageHelper . options . cropRectangle . height = height ;
558
- } else if ( ( < NsCapabilities > this . nsCapabilities ) . tryGetApiLevel ( ) >= 6.0 ) {
560
+ } else if ( ( < NsCapabilities > this . nsCapabilities ) . automationName === AutomationName . UiAutomator2 ) {
559
561
const height = this . _imageHelper . options . cropRectangle . width - this . imageHelper . options . cropRectangle . y ;
560
562
const width = this . _imageHelper . options . cropRectangle . height + this . imageHelper . options . cropRectangle . y ;
561
563
this . imageHelper . options . cropRectangle . width = width ;
0 commit comments