From cfe9535e18cd57915f0e680dd92163ff981dce80 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Thu, 25 Jul 2019 13:40:37 +0200 Subject: [PATCH] ExpectedCondition tests --- src/test/java/BasicTest.java | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/test/java/BasicTest.java b/src/test/java/BasicTest.java index 7cd5976..8566c57 100644 --- a/src/test/java/BasicTest.java +++ b/src/test/java/BasicTest.java @@ -13,12 +13,19 @@ import org.testng.annotations.Test; public class BasicTest { private WebDriver driver; + private WebDriverWait wait; String URL = "https://0.fredldev.fremo-net.eu"; @BeforeClass public void testSetUp() { driver = new HtmlUnitDriver(true); + wait = new WebDriverWait(driver, 15); + } + + @AfterClass + public void tearDown() { + driver.quit(); } @Test @@ -31,16 +38,21 @@ public class BasicTest { @Test public void verifyLoginAsSystemUser() { driver.navigate().to(URL); + WebElement loginButton = wait.until(elementToBeClickable(By.name("doLogin")); + driver.findElement(By.name("login")).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='password']")).sendKeys("system"); //driver.findElement(By.xpath("//input[@name='doLogin']")).submit(); - WebDriverWait waitForLoginDone = new WebDriverWait(driver, 15); - //waitForLoginDone.until(ExpectedConditions.ElementIsVisible(By.xpath("//input[@class='menu'][0]")); - waitForLoginDone.until(ExpectedConditions.ElementIsVisible(By.className("menu"))); - driver.switchTo().frame("oben"); + //wait.until(ExpectedConditions.ElementIsVisible(By.xpath("//input[@class='menu'][0]")); + //wait.until(ExpectedConditions.ElementIsVisible(By.className("menu"))); + wait.until(titleIs("FreDL")); + //driver.switchTo().frame("oben"); + WebElement obenFrame = wait.until(frameToBeAvailableAndSwitchToIt("oben"); + String versionInfo = driver.findElement(By.xpath("/table/tr/td/b")).getText(); String userInfo = driver.findElement(By.xpath("/table/tr/td[3]")).getText(); System.out.println("Version info found: " + versionInfo); @@ -50,9 +62,4 @@ public class BasicTest { System.out.println("Welcome message is: " + welcomeMessage); Assert.assertEquals(welcomeMessage, "Willkommen bei FreDL"); } - - @AfterClass - public void tearDown() { - driver.quit(); - } }