ExpectedCondition tests

This commit is contained in:
Dirk Jahnke 2019-07-25 13:40:37 +02:00
parent 328c6e810e
commit cfe9535e18
1 changed files with 17 additions and 10 deletions

View File

@ -13,12 +13,19 @@ import org.testng.annotations.Test;
public class BasicTest { public class BasicTest {
private WebDriver driver; private WebDriver driver;
private WebDriverWait wait;
String URL = "https://0.fredldev.fremo-net.eu"; String URL = "https://0.fredldev.fremo-net.eu";
@BeforeClass @BeforeClass
public void testSetUp() { public void testSetUp() {
driver = new HtmlUnitDriver(true); driver = new HtmlUnitDriver(true);
wait = new WebDriverWait(driver, 15);
}
@AfterClass
public void tearDown() {
driver.quit();
} }
@Test @Test
@ -31,16 +38,21 @@ public class BasicTest {
@Test @Test
public void verifyLoginAsSystemUser() { public void verifyLoginAsSystemUser() {
driver.navigate().to(URL); driver.navigate().to(URL);
WebElement loginButton = wait.until(elementToBeClickable(By.name("doLogin"));
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");
driver.findElement(By.name("doLogin")).click(); loginButton.click();
//driver.findElement(By.xpath("//input[@name='login']")).sendKeys("system"); //driver.findElement(By.xpath("//input[@name='login']")).sendKeys("system");
//driver.findElement(By.xpath("//input[@name='password']")).sendKeys("system"); //driver.findElement(By.xpath("//input[@name='password']")).sendKeys("system");
//driver.findElement(By.xpath("//input[@name='doLogin']")).submit(); //driver.findElement(By.xpath("//input[@name='doLogin']")).submit();
WebDriverWait waitForLoginDone = new WebDriverWait(driver, 15); //wait.until(ExpectedConditions.ElementIsVisible(By.xpath("//input[@class='menu'][0]"));
//waitForLoginDone.until(ExpectedConditions.ElementIsVisible(By.xpath("//input[@class='menu'][0]")); //wait.until(ExpectedConditions.ElementIsVisible(By.className("menu")));
waitForLoginDone.until(ExpectedConditions.ElementIsVisible(By.className("menu"))); wait.until(titleIs("FreDL"));
driver.switchTo().frame("oben"); //driver.switchTo().frame("oben");
WebElement obenFrame = wait.until(frameToBeAvailableAndSwitchToIt("oben");
String versionInfo = driver.findElement(By.xpath("/table/tr/td/b")).getText(); String versionInfo = driver.findElement(By.xpath("/table/tr/td/b")).getText();
String userInfo = driver.findElement(By.xpath("/table/tr/td[3]")).getText(); String userInfo = driver.findElement(By.xpath("/table/tr/td[3]")).getText();
System.out.println("Version info found: " + versionInfo); System.out.println("Version info found: " + versionInfo);
@ -50,9 +62,4 @@ public class BasicTest {
System.out.println("Welcome message is: " + welcomeMessage); System.out.println("Welcome message is: " + welcomeMessage);
Assert.assertEquals(welcomeMessage, "Willkommen bei FreDL"); Assert.assertEquals(welcomeMessage, "Willkommen bei FreDL");
} }
@AfterClass
public void tearDown() {
driver.quit();
}
} }