@@ -11,7 +11,8 @@ import {
1111 DeviceController ,
1212 IDevice ,
1313 DeviceType ,
14- AndroidController
14+ AndroidController ,
15+ IOSController
1516} from "mobile-devices-controller" ;
1617import {
1718 addExt ,
@@ -47,6 +48,7 @@ import { DeviceOrientation } from "./enums/device-orientation";
4748import { NsCapabilities } from "./ns-capabilities" ;
4849import { AutomationName } from "./automation-name" ;
4950import { AndroidKeyEvent } from "mobile-devices-controller" ;
51+ import { setInterval } from "timers" ;
5052
5153export class AppiumDriver {
5254 private _defaultWaitTime : number = 5000 ;
@@ -117,7 +119,7 @@ export class AppiumDriver {
117119 }
118120
119121 /**
120- * Get the storage where test results from image comparison is logged It will be reports/app nam/device name
122+ * Get the storage where test results from image comparison is logged. The path should be reports/app nam/device name
121123 */
122124 get reportsPath ( ) {
123125 return this . _args . reportsPath ;
@@ -215,10 +217,11 @@ export class AppiumDriver {
215217
216218 let hasStarted = false ;
217219 let retries = 10 ;
220+ let sessionInfoDetails ;
221+
218222 while ( retries > 0 && ! hasStarted ) {
219223 try {
220224 let sessionInfo ;
221- let sessionInfoDetails ;
222225 try {
223226 if ( args . sessionId || args . attachToDebug ) {
224227 const sessionInfos = JSON . parse ( ( ( await getSessions ( args . port ) ) || "{}" ) + '' ) ;
@@ -311,7 +314,19 @@ export class AppiumDriver {
311314 await driver . updateSettings ( appiumCapsFromConfig . settings ) ;
312315 }
313316
314- return new AppiumDriver ( driver , wd , webio , args . driverConfig , args ) ;
317+ if ( + sessionInfoDetails . statBarHeight === 0
318+ && sessionInfoDetails . platformName . toLowerCase ( ) === "ios"
319+ && sessionInfoDetails . platformVersion . startsWith ( "13" ) ) {
320+ try {
321+ const devicesInfos = IOSController . devicesDisplaysInfos ( ) ;
322+ const matches = devicesInfos . filter ( d => sessionInfoDetails . deviceName . includes ( d . deviceType ) ) ;
323+ const deviceType = matches [ matches . length - 1 ] ;
324+ args . device . viewportRect . y += deviceType . statBarHeight * deviceType . density ;
325+ } catch ( error ) { }
326+ }
327+
328+ const appiumDriver = new AppiumDriver ( driver , wd , webio , args . driverConfig , args ) ;
329+ return appiumDriver ;
315330 }
316331
317332 public async updateSettings ( settings : any ) {
@@ -1011,16 +1026,16 @@ export class AppiumDriver {
10111026 public getScreenViewPort ( ) : IRectangle {
10121027 const rect = this . getScreenActualViewPort ( ) ;
10131028 if ( rect
1029+ && this . isIOS
10141030 && Object . getOwnPropertyNames ( rect ) . length > 0
1015- && this . _args . appiumCaps . device . deviceScreenDensity ) {
1031+ && this . _args . device . deviceScreenDensity ) {
10161032 return < IRectangle > {
1017- x : rect . x / this . _args . appiumCaps . device . deviceScreenDensity ,
1018- y : rect . y / this . _args . appiumCaps . device . deviceScreenDensity ,
1019- width : rect . width / this . _args . appiumCaps . device . deviceScreenDensity ,
1020- height : rect . height / this . _args . appiumCaps . device . deviceScreenDensity ,
1033+ x : rect . x / this . _args . device . deviceScreenDensity ,
1034+ y : rect . y / this . _args . device . deviceScreenDensity ,
1035+ width : rect . width / this . _args . device . deviceScreenDensity ,
1036+ height : rect . height / this . _args . device . deviceScreenDensity ,
10211037 }
10221038 } else {
1023- logError ( "Device's density is undefined!" ) ;
10241039 return rect ;
10251040 }
10261041 }
0 commit comments