Debug ...

This commit is contained in:
Dirk Jahnke 2019-07-26 22:06:31 +02:00
parent 068fdda66b
commit a509166cfa
2 changed files with 15 additions and 0 deletions

View File

@ -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();
}
}
}

View File

@ -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);