mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Bug 4339: Due to the WebDriver specification, moveTo or click are not
expected to scroll the element into view. This can lead to test failures depending on the WebDriver implementation (e.g. GeckoDriver). This change explicitly ensures at some central places that elements to be clicked are being scrolled into view.
This commit is contained in:
1 parent
c038d4628c
commit
67a01d6a69
3 files changed
+33
-6
No files matched your search
@@ -12,6 +12,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.openqa.selenium.Alert;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.NoAlertPresentException;
|
||||
import org.openqa.selenium.SearchContext;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
@@ -585,4 +586,13 @@ public class PageObject {
|
||||
}
|
||||
throw new NoAlertPresentException();
|
||||
}
|
||||
|
||||
protected void scrollToView(WebElement webElement) {
|
||||
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(false);", webElement);
|
||||
}
|
||||
|
||||
protected void scrollToViewAndClick(WebElement webElement) {
|
||||
scrollToView(webElement);
|
||||
webElement.click();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -57,7 +57,7 @@ public abstract class DataEntryDialogPO extends PageArea {
|
||||
}
|
||||
|
||||
public void pressOk(boolean accept) {
|
||||
this.okButton.click();
|
||||
scrollToViewAndClick(this.okButton);
|
||||
|
||||
ExpectedCondition<Alert> condition = ExpectedConditions.alertIsPresent();
|
||||
Alert alert = condition.apply(this.driver);
|
||||
|
||||
+22
-5
@@ -119,17 +119,34 @@ public class DataEntryPO extends CellTableRowPO {
|
||||
|
||||
protected Action getModifiedSelectAction() {
|
||||
Actions actions = new Actions(this.driver);
|
||||
final WebElement elementToSelect;
|
||||
final boolean controlClick;
|
||||
if (table.getColumnHeaders().get(0).equals("\u2713")) {
|
||||
// it's a checkbox column
|
||||
actions.moveToElement(this.columns.isEmpty() ? getWebElement() : this.columns.get(0));
|
||||
actions.click();
|
||||
elementToSelect = this.columns.isEmpty() ? getWebElement() : this.columns.get(0);
|
||||
controlClick = false;
|
||||
} else {
|
||||
elementToSelect = getElementForSelect();
|
||||
controlClick = true;
|
||||
}
|
||||
if (controlClick) {
|
||||
actions.keyDown(Keys.CONTROL);
|
||||
moveToUpperLeftCorner(actions, getElementForSelect());
|
||||
actions.click();
|
||||
}
|
||||
moveToUpperLeftCorner(actions, elementToSelect);
|
||||
actions.moveToElement(elementToSelect, 1, 1);
|
||||
actions.click();
|
||||
if (controlClick) {
|
||||
actions.keyUp(Keys.CONTROL);
|
||||
}
|
||||
return actions.build();
|
||||
final CompositeAction compositeAction = new CompositeAction();
|
||||
compositeAction.addAction(new Action() {
|
||||
@Override
|
||||
public void perform() {
|
||||
scrollToView(elementToSelect);
|
||||
}
|
||||
});
|
||||
compositeAction.addAction(actions.build());
|
||||
return compositeAction;
|
||||
}
|
||||
|
||||
protected CompositeAction getModifiedCompositeActionAction() {
|
||||
|
||||
Reference in new issue
Block a user