From 90612a18803200018ac79f3b711069c7863a9085 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Thu, 25 Jul 2019 15:01:29 +0200 Subject: [PATCH] Added handling of cookie consent page --- src/test/java/BasicTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/test/java/BasicTest.java b/src/test/java/BasicTest.java index adea696..1e53556 100644 --- a/src/test/java/BasicTest.java +++ b/src/test/java/BasicTest.java @@ -40,14 +40,21 @@ public class BasicTest { public void verifyLoginAsSystemUser() { driver.navigate().to(URL); System.out.println("Navigate to: " + URL); - String body = driver.getPageSource(); - System.out.println("HTML: " + body); - String scaleInfo = driver.findElement(By.xpath("/table[@class='loginall']/tr/td[0]/div")).getText(); - System.out.println("Scale: " + scaleInfo); + // String body = driver.getPageSource(); + // System.out.println("HTML: " + body); + + if (driver.findElements( By.id("privacy-cookie-statement") ).size() != 0) { + System.out.println("Cookies consent page is shown"); + WebElement consentButton = driver.findElement(By.id("opt-in-button-allow")); + consentButton.click(); + } // WebElement loginButton = wait.until(ExpectedConditions.elementToBeClickable(By.name("doLogin"))); WebElement loginButton = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.name("doLogin")))); + String scaleInfo = driver.findElement(By.xpath("/table[@class='loginall']/tr/td[0]/div")).getText(); + System.out.println("Scale: " + scaleInfo); + driver.findElement(By.name("login")).sendKeys("system"); driver.findElement(By.name("password")).sendKeys("system"); loginButton.click();