From a509166cfaa3964cb9844a51f07d12974aec2044 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Fri, 26 Jul 2019 22:06:31 +0200 Subject: [PATCH] Debug ... --- .../java/org/fremo/fredl/test/FredlTestHelper.java | 12 ++++++++++++ .../java/org/fremo/fredl/test/StartInstaller.java | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/test/java/org/fremo/fredl/test/FredlTestHelper.java b/src/test/java/org/fremo/fredl/test/FredlTestHelper.java index 1e5b21f..eac78e9 100644 --- a/src/test/java/org/fremo/fredl/test/FredlTestHelper.java +++ b/src/test/java/org/fremo/fredl/test/FredlTestHelper.java @@ -1,6 +1,7 @@ package org.fremo.fredl.test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import java.util.concurrent.TimeUnit; @@ -11,6 +12,7 @@ public class FredlTestHelper { public static void setUp(WebDriver _driver) { driver = _driver; driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); + System.out.println("FredlTestHelper.setUp -- timeout set to " + implicitTimeoutMilliseconds + "ms"); } public static void printPageSource() { String body; // used for debugging purposes only @@ -20,6 +22,7 @@ public class FredlTestHelper { } public static boolean elementExistsByXpath(String xpath) { + System.out.println("elementExistsByXpath for " + xpath); driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS); boolean exists = driver.findElements(By.xpath(xpath)).size() != 0; driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); @@ -27,10 +30,19 @@ public class FredlTestHelper { } public static boolean elementExistsById(String id) { + System.out.println("elementExistsById for " + id); driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS); boolean exists = driver.findElements(By.id(id)).size() != 0; driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); return exists; } + public static void skipConsentCookiePage() { + if (FredlTestHelper.elementExistsById("privacy-cookie-statement")) { + System.out.println("Cookies consent page is shown"); + WebElement consentButton = driver.findElement(By.id("opt-in-button-allow")); + consentButton.click(); + } + } + } diff --git a/src/test/java/org/fremo/fredl/test/StartInstaller.java b/src/test/java/org/fremo/fredl/test/StartInstaller.java index 87fb251..326a441 100644 --- a/src/test/java/org/fremo/fredl/test/StartInstaller.java +++ b/src/test/java/org/fremo/fredl/test/StartInstaller.java @@ -37,6 +37,9 @@ public class StartInstaller { @Test public void startInstaller() { driver.navigate().to(URL); + + FredlTestHelper.skipConsentCookiePage(); + String getTitle = driver.getTitle(); System.out.println("Page title: " + getTitle);