@@ -797,17 +797,23 @@ private boolean elementsAreOverlappedOnBorder(WebElement rootElement, WebElement
797797 int widthRoot = rootElement .getSize ().width ;
798798 int heightRoot = rootElement .getSize ().height ;
799799
800- int sqRootElement = ( xRoot + widthRoot ) * ( yRoot + heightRoot ) ;
801- int sqElement = ( elLoc . x + elSize .width ) * ( elLoc . y + elSize .height ) ;
800+ int sqRootElement = widthRoot * heightRoot ;
801+ int sqElement = elSize .width * elSize .height ;
802802
803803 int sqCommon = 0 ;
804- if ((xRoot < elLoc .x && yRoot == elLoc .y ) || (yRoot < elLoc .y && xRoot == elLoc .x )) {
805- sqCommon = (xRoot + widthRoot + elSize .width ) * (yRoot + heightRoot + elSize .height );
806- } else if ((elLoc .x < xRoot && yRoot == elLoc .y ) || (elLoc .y < yRoot && xRoot == elLoc .x )) {
807- sqCommon = (elLoc .x + elSize .width + widthRoot ) * (elLoc .y + elSize .height + heightRoot );
804+ if (xRoot < elLoc .x && yRoot == elLoc .y ) {
805+ sqCommon = (widthRoot + (elLoc .x - (xRoot + widthRoot ) + elSize .width )) * (heightRoot );
806+ } else if (yRoot < elLoc .y && xRoot == elLoc .x ) {
807+ sqCommon = (heightRoot + (elLoc .y - (yRoot + heightRoot ) + elSize .height )) * (widthRoot );
808+ } else if ((elLoc .x < xRoot && yRoot == elLoc .y )) {
809+ sqCommon = ((elSize .width ) + (xRoot - (elLoc .x + elSize .width ) + widthRoot )) * (elSize .height );
810+ } else if (elLoc .y < yRoot && xRoot == elLoc .x ) {
811+ sqCommon = ((elSize .height ) + (yRoot - (elLoc .y + elSize .height ) + heightRoot )) * (elSize .width );
812+ } else {
813+ return false ;
808814 }
809815
810- return sqCommon - sqElement >= sqRootElement ;
816+ return sqCommon < sqRootElement + sqElement ;
811817 }
812818
813819 private boolean elementsAreOverlapped (WebElement elementOverlapWith ) {
0 commit comments