From 69363f40d30aa2fe0918b0b1ad24e11f2170c0aa Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Wed, 12 Jun 2019 18:15:30 +0200
Subject: [PATCH] no-jira: change how position are calculated in Selenium for
 Chrome

---
 .../olat/selenium/page/graphene/Position.java | 29 +++++++------------
 .../page/qti/QTI21HotspotEditorPage.java      |  6 +---
 2 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/test/java/org/olat/selenium/page/graphene/Position.java b/src/test/java/org/olat/selenium/page/graphene/Position.java
index 2582fb253d7..4a03366c1ff 100644
--- a/src/test/java/org/olat/selenium/page/graphene/Position.java
+++ b/src/test/java/org/olat/selenium/page/graphene/Position.java
@@ -24,7 +24,6 @@ import java.util.List;
 import org.olat.ims.qti21.model.xml.AssessmentItemFactory;
 import org.openqa.selenium.Dimension;
 import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.firefox.FirefoxDriver;
 
 /**
  * 
@@ -67,36 +66,28 @@ public class Position {
 			y = (y2 + y1) / 2;
 		}
 		
-		if(browser instanceof FirefoxDriver) {
-			x = x - Math.round(dimension.getWidth() / 2.0f);
-			y = y - Math.round(dimension.getHeight() / 2.0f);
-		}
+		x = x - Math.round(dimension.getWidth() / 2.0f);
+		y = y - Math.round(dimension.getHeight() / 2.0f);
 		return new Position(x, y);
 	}
 	
 	public static Position valueOf(int x, int y, Dimension dimension, WebDriver browser) {
-		if(browser instanceof FirefoxDriver) {
-			x = x - Math.round(dimension.getWidth() / 2.0f);
-			y = y - Math.round(dimension.getHeight() / 2.0f);
-		}
+		x = x - Math.round(dimension.getWidth() / 2.0f);
+		y = y - Math.round(dimension.getHeight() / 2.0f);
 		return new Position(x, y);
 	}
 	
 	public static Position valueOf(int x, int y, int firefoxCorrection, Dimension dimension, WebDriver browser) {
-		if(browser instanceof FirefoxDriver) {
-			x = x - Math.round(dimension.getWidth() / 2.0f);
-			y = y - Math.round(dimension.getHeight() / 2.0f);
-			x += firefoxCorrection;
-			y += firefoxCorrection;
-		}
+		x = x - Math.round(dimension.getWidth() / 2.0f);
+		y = y - Math.round(dimension.getHeight() / 2.0f);
+		x += firefoxCorrection;
+		y += firefoxCorrection;
 		return new Position(x, y);
 	}
 	
 	public static Position valueOf(int x, int y, int width, int height, WebDriver browser) {
-		if(browser instanceof FirefoxDriver) {
-			x = x - Math.round(width / 2.0f);
-			y = y - Math.round(height / 2.0f);
-		}
+		x = x - Math.round(width / 2.0f);
+		y = y - Math.round(height / 2.0f);
 		return new Position(x, y);
 	}
 
diff --git a/src/test/java/org/olat/selenium/page/qti/QTI21HotspotEditorPage.java b/src/test/java/org/olat/selenium/page/qti/QTI21HotspotEditorPage.java
index beb294e8468..51ff28fa929 100644
--- a/src/test/java/org/olat/selenium/page/qti/QTI21HotspotEditorPage.java
+++ b/src/test/java/org/olat/selenium/page/qti/QTI21HotspotEditorPage.java
@@ -27,7 +27,6 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.Dimension;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
 import org.openqa.selenium.interactions.Actions;
 
 import uk.ac.ed.ph.jqtiplus.value.Cardinality;
@@ -82,10 +81,7 @@ public class QTI21HotspotEditorPage extends QTI21AssessmentItemEditorPage {
 	public QTI21HotspotEditorPage moveToHotspotEditor() {
 		By editorBy = By.id("o_qti_hotspots_edit");
 		OOGraphene.waitElement(editorBy, browser);
-		
-		if(browser instanceof FirefoxDriver) {
-			OOGraphene.scrollTo(editorBy, browser);
-		}
+		OOGraphene.scrollTo(editorBy, browser);
 		return this;
 	}
 	
-- 
GitLab