2222import java .util .concurrent .ConcurrentHashMap ;
2323import java .util .concurrent .atomic .AtomicLong ;
2424
25- import static environment .EnvironmentFactory .isChrome ;
26- import static environment .EnvironmentFactory .isMobile ;
25+ import static environment .EnvironmentFactory .*;
2726import static util .general .SystemHelper .isAutomotionFolderExists ;
2827import static util .general .SystemHelper .isRetinaDisplay ;
2928import static util .validator .Constants .*;
@@ -698,12 +697,16 @@ String getFormattedMessage(WebElement element) {
698697 }
699698
700699 int getRetinaValue (int value ) {
701- int zoom = Integer .valueOf (currentZoom .replace ("%" , "" ));
702- if (zoom != 100 ){
703- value = (int ) (value - (value * Math .abs (zoom - 100f ) / 100f ));
704- }
705- if (isRetinaDisplay () && isChrome ()) {
706- return 2 * value ;
700+ if (!isMobile ()) {
701+ int zoom = Integer .valueOf (currentZoom .replace ("%" , "" ));
702+ if (zoom != 100 ) {
703+ value = (int ) (value - (value * Math .abs (zoom - 100f ) / 100f ));
704+ }
705+ if (isRetinaDisplay () && isChrome ()) {
706+ return 2 * value ;
707+ } else {
708+ return value ;
709+ }
707710 } else {
708711 return value ;
709712 }
@@ -712,8 +715,12 @@ int getRetinaValue(int value) {
712715 long getPageWidth () {
713716 if (!isMobile ()) {
714717 JavascriptExecutor executor = (JavascriptExecutor ) driver ;
715- currentZoom = (String ) executor .executeScript ("return document.body.style.zoom;" );
716- if (currentZoom .equals ("100%" ) || currentZoom .equals ("" )) {
718+ if (isFirefox ()) {
719+ currentZoom = (String ) executor .executeScript ("document.body.style.MozTransform" );
720+ } else {
721+ currentZoom = (String ) executor .executeScript ("return document.body.style.zoom;" );
722+ }
723+ if (currentZoom == null || currentZoom .equals ("100%" ) || currentZoom .equals ("" )) {
717724 currentZoom = "100%" ;
718725 return (long ) executor .executeScript ("if (self.innerWidth) {return self.innerWidth;} if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}if (document.body) {return document.body.clientWidth;}" );
719726 } else {
@@ -727,8 +734,12 @@ long getPageWidth() {
727734 long getPageHeight () {
728735 if (!isMobile ()) {
729736 JavascriptExecutor executor = (JavascriptExecutor ) driver ;
730- currentZoom = (String ) executor .executeScript ("return document.body.style.zoom;" );
731- if (currentZoom .equals ("100%" ) || currentZoom .equals ("" )) {
737+ if (isFirefox ()) {
738+ currentZoom = (String ) executor .executeScript ("document.body.style.MozTransform" );
739+ } else {
740+ currentZoom = (String ) executor .executeScript ("return document.body.style.zoom;" );
741+ }
742+ if (currentZoom == null || currentZoom .equals ("100%" ) || currentZoom .equals ("" )) {
732743 currentZoom = "100%" ;
733744 return (long ) executor .executeScript ("if (self.innerHeight) {return self.innerHeight;} if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}if (document.body) {return document.body.clientHeight;}" );
734745 } else {
0 commit comments