Added handling of cookie consent page

This commit is contained in:
Dirk Jahnke 2019-07-25 15:01:29 +02:00
parent a565114a99
commit 90612a1880
1 changed files with 11 additions and 4 deletions

View File

@ -40,14 +40,21 @@ public class BasicTest {
public void verifyLoginAsSystemUser() { public void verifyLoginAsSystemUser() {
driver.navigate().to(URL); driver.navigate().to(URL);
System.out.println("Navigate to: " + URL); System.out.println("Navigate to: " + URL);
String body = driver.getPageSource(); // String body = driver.getPageSource();
System.out.println("HTML: " + body); // System.out.println("HTML: " + body);
String scaleInfo = driver.findElement(By.xpath("/table[@class='loginall']/tr/td[0]/div")).getText();
System.out.println("Scale: " + scaleInfo); 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.elementToBeClickable(By.name("doLogin")));
WebElement loginButton = wait.until(ExpectedConditions.visibilityOf(driver.findElement(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("login")).sendKeys("system");
driver.findElement(By.name("password")).sendKeys("system"); driver.findElement(By.name("password")).sendKeys("system");
loginButton.click(); loginButton.click();