From 7ee66246c44df077de7815de9ea3118c32e873b2 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Fri, 26 Jul 2019 13:51:53 +0200 Subject: [PATCH] Cleanup --- src/test/java/BasicTest.java | 112 ------------------ .../java/org/fremo/fredl/test/BasicTest.java | 7 +- 2 files changed, 3 insertions(+), 116 deletions(-) delete mode 100644 src/test/java/BasicTest.java diff --git a/src/test/java/BasicTest.java b/src/test/java/BasicTest.java deleted file mode 100644 index 1373e97..0000000 --- a/src/test/java/BasicTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.fremo.fredl.test; - -import java.util.concurrent.TimeUnit; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.htmlunit.HtmlUnitDriver; -import org.openqa.selenium.support.ui.WebDriverWait; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class BasicTest { - private WebDriver driver; - private WebDriverWait wait; - private int implicitTimeoutMilliseconds = 3000; - private int timeoutInSeconds = 20; - String URL = "https://0.fredldev.fremo-net.eu"; - - @BeforeClass - public void testSetUp() { - - driver = new HtmlUnitDriver(true); - wait = new WebDriverWait(driver, timeoutInSeconds); - driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); - } - - @AfterClass - public void tearDown() { - driver.quit(); - } - - private boolean elementExistsByXpath(String xpath) { - driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS); - boolean exists = driver.findElements( By.xpath(xpath) ).size() != 0; - driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); - return exists; - } - - private boolean elementExistsById(String 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; - } - - @Test - public void verifyFredlPageTitle() { - driver.navigate().to(URL); - String getTitle = driver.getTitle(); - System.out.println("Page title: " + getTitle); - Assert.assertEquals(getTitle, "FREDL"); - } - - @Test - public void verifyLoginAsSystemUser() { - String body; // used for debugging purposes only - - driver.navigate().to(URL); - System.out.println("Navigate to: " + URL); - - if (elementExistsById("privacy-cookie-statement")) { - 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/tbody/tr/td/div")).getText(); - String scaleInfo = driver.findElement(By.xpath("//table[@class='loginall']/tbody/tr/td/div")).getText(); - System.out.println("Scale: " + scaleInfo); - - driver.findElement(By.xpath("//input[@name='login']")).sendKeys("system"); - driver.findElement(By.xpath("//input[@name='password']")).sendKeys("system"); - loginButton.click(); - - String expectedTitle = "FreDL"; - wait.until(ExpectedConditions.titleIs(expectedTitle)); - - //body = driver.getPageSource(); - //System.out.println("HTML: " + body); - - //driver.switchTo().frame("oben"); - String frameObenName = "oben"; - wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameObenName)); - - //body = driver.getPageSource(); - //System.out.println("HTML: " + body); - - String versionInfo = driver.findElement(By.xpath("//table[1]/tbody/tr/td[1]/b")).getText(); - String userInfo = driver.findElement(By.xpath("//table[1]/tbody/tr/td[3]")).getText(); - String expectedUserInfo = "Benutzer: FREDL System (Syste)"; - System.out.println("Version info found: " + versionInfo); - System.out.println("User info found: " + userInfo); - Assert.assertEquals(userInfo, expectedUserInfo); - - driver.switchTo().parentFrame(); - String frameRechtsName = "rechts"; - driver.switchTo().frame(frameRechtsName); - //body = driver.getPageSource(); - //System.out.println("HTML: " + body); - - String welcomeMessage = driver.findElement(By.xpath("//body/h1")).getText(); - String expectedWelcomeMessage = "Willkommen bei FreDL"; - System.out.println("Welcome message is: " + welcomeMessage); - Assert.assertEquals(welcomeMessage, expectedWelcomeMessage); - } -} diff --git a/src/test/java/org/fremo/fredl/test/BasicTest.java b/src/test/java/org/fremo/fredl/test/BasicTest.java index 582159a..92772b1 100644 --- a/src/test/java/org/fremo/fredl/test/BasicTest.java +++ b/src/test/java/org/fremo/fredl/test/BasicTest.java @@ -78,13 +78,12 @@ public class BasicTest { String expectedTitle = "FreDL"; wait.until(ExpectedConditions.titleIs(expectedTitle)); - FredlTestHelper.printPageSource(driver); + // FredlTestHelper.printPageSource(driver); - //driver.switchTo().frame("oben"); String frameObenName = "oben"; wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameObenName)); - FredlTestHelper.printPageSource(driver); + // FredlTestHelper.printPageSource(driver); String versionInfo = driver.findElement(By.xpath("//table[1]/tbody/tr/td[1]/b")).getText(); String userInfo = driver.findElement(By.xpath("//table[1]/tbody/tr/td[3]")).getText(); @@ -97,7 +96,7 @@ public class BasicTest { String frameRechtsName = "rechts"; driver.switchTo().frame(frameRechtsName); - FredlTestHelper.printPageSource(driver); + // FredlTestHelper.printPageSource(driver); String welcomeMessage = driver.findElement(By.xpath("//body/h1")).getText(); String expectedWelcomeMessage = "Willkommen bei FreDL";