From 471dccfa479de772b005ce11fd33b9e483747fb9 Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Mon, 16 Dec 2024 08:07:04 +0000 Subject: [PATCH] feat: add scroll to bottom on ebsr --- .../org/dvsa/testing/framework/pageObjects/BasePage.java | 9 ++++++--- .../dvsa/testing/framework/stepdefs/vol/EBSRUpload.java | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/dvsa/testing/framework/pageObjects/BasePage.java b/src/test/java/org/dvsa/testing/framework/pageObjects/BasePage.java index fad229e35..64493f6d5 100644 --- a/src/test/java/org/dvsa/testing/framework/pageObjects/BasePage.java +++ b/src/test/java/org/dvsa/testing/framework/pageObjects/BasePage.java @@ -674,9 +674,12 @@ public static String getSelectedTextFromDropDown(@NotNull String selector, @NotN return option.getFirstSelectedOption().getText(); } - public static void scrollToBottom() { - JavascriptExecutor js = (JavascriptExecutor) getDriver(); - js.executeScript("window.scrollTo(0, document.body.scrollHeight)"); + public void scrollToBottom() { + WebElement footer = getDriver().findElement(By.tagName("govuk-footer")); + int deltaY = footer.getRect().y; + new Actions(getDriver()) + .scrollByAmount(0, deltaY) + .perform(); } public boolean pageContains(String text) { diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/EBSRUpload.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/EBSRUpload.java index cfb062731..e08538ff7 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/EBSRUpload.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/EBSRUpload.java @@ -90,6 +90,7 @@ public void documentsAreGenerated() throws IllegalBrowserException, IOException } while ((long) findElements("//*[@class='field file-upload']", SelectorType.XPATH).size() < 2 && System.currentTimeMillis() < kickOutTime); try { + scrollToBottom(); assertTrue(findElements("//*[@class='field file-upload']", SelectorType.XPATH).stream().anyMatch( webElement -> webElement.getText().contains("Route Track Map PDF (Auto Scale)"))); } catch (Exception e) {