Cleanup
This commit is contained in:
parent
8512339bea
commit
7ee66246c4
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -78,13 +78,12 @@ public class BasicTest {
|
||||||
String expectedTitle = "FreDL";
|
String expectedTitle = "FreDL";
|
||||||
wait.until(ExpectedConditions.titleIs(expectedTitle));
|
wait.until(ExpectedConditions.titleIs(expectedTitle));
|
||||||
|
|
||||||
FredlTestHelper.printPageSource(driver);
|
// FredlTestHelper.printPageSource(driver);
|
||||||
|
|
||||||
//driver.switchTo().frame("oben");
|
|
||||||
String frameObenName = "oben";
|
String frameObenName = "oben";
|
||||||
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameObenName));
|
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 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 userInfo = driver.findElement(By.xpath("//table[1]/tbody/tr/td[3]")).getText();
|
||||||
|
@ -97,7 +96,7 @@ public class BasicTest {
|
||||||
String frameRechtsName = "rechts";
|
String frameRechtsName = "rechts";
|
||||||
driver.switchTo().frame(frameRechtsName);
|
driver.switchTo().frame(frameRechtsName);
|
||||||
|
|
||||||
FredlTestHelper.printPageSource(driver);
|
// FredlTestHelper.printPageSource(driver);
|
||||||
|
|
||||||
String welcomeMessage = driver.findElement(By.xpath("//body/h1")).getText();
|
String welcomeMessage = driver.findElement(By.xpath("//body/h1")).getText();
|
||||||
String expectedWelcomeMessage = "Willkommen bei FreDL";
|
String expectedWelcomeMessage = "Willkommen bei FreDL";
|
||||||
|
|
Loading…
Reference in New Issue