@@ -1001,22 +1001,27 @@ export class AppiumDriver {
1001
1001
* Useful for image comparison
1002
1002
*/
1003
1003
public getScreenActualViewPort ( ) : IRectangle {
1004
- return < IRectangle > ( this . _args . appiumCaps && this . _args . appiumCaps . viewportRect ) || this . _args . device . viewportRect ;
1004
+ return < IRectangle > ( this . _args . device . viewportRect || this . imageHelper . options . cropRectangle ) ;
1005
1005
}
1006
1006
1007
1007
/**
1008
- * Get screen view port
1009
- * This is convenient to use for some gestures on the screen
1008
+ * Get screen view port.
1009
+ * Provides the view port that is needed for some gestures like swipe etc.
1010
1010
*/
1011
1011
public getScreenViewPort ( ) : IRectangle {
1012
- const rect = ( this . _args . appiumCaps && this . _args . appiumCaps . viewportRect ) || this . _args . device . viewportRect ;
1013
- if ( rect && Object . getOwnPropertyNames ( rect ) . length > 0 ) {
1012
+ const rect = this . getScreenActualViewPort ( ) ;
1013
+ if ( rect
1014
+ && Object . getOwnPropertyNames ( rect ) . length > 0
1015
+ && this . _args . appiumCaps . device . deviceScreenDensity ) {
1014
1016
return < IRectangle > {
1015
1017
x : rect . x / this . _args . appiumCaps . device . deviceScreenDensity ,
1016
1018
y : rect . y / this . _args . appiumCaps . device . deviceScreenDensity ,
1017
- width : rect . x / this . _args . appiumCaps . device . deviceScreenDensity ,
1018
- height : rect . x / this . _args . appiumCaps . device . deviceScreenDensity ,
1019
+ width : rect . width / this . _args . appiumCaps . device . deviceScreenDensity ,
1020
+ height : rect . height / this . _args . appiumCaps . device . deviceScreenDensity ,
1019
1021
}
1022
+ } else {
1023
+ logError ( "Device's density is undefined!" ) ;
1024
+ return rect ;
1020
1025
}
1021
1026
}
1022
1027
0 commit comments