Added StartInstaller -- installation complete not detected yet.
This commit is contained in:
		| @@ -16,16 +16,14 @@ import org.testng.annotations.Test; | |||||||
| public class BasicTest { | public class BasicTest { | ||||||
|     private WebDriver driver; |     private WebDriver driver; | ||||||
|     private WebDriverWait wait; |     private WebDriverWait wait; | ||||||
|     private int implicitTimeoutMilliseconds = 3000; |  | ||||||
|     private int timeoutInSeconds = 20; |     private int timeoutInSeconds = 20; | ||||||
|     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, timeoutInSeconds); |         wait = new WebDriverWait(driver, timeoutInSeconds); | ||||||
|         driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); |         FredlTestHelper.setUp(driver); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @AfterClass |     @AfterClass | ||||||
| @@ -33,20 +31,6 @@ public class BasicTest { | |||||||
|         driver.quit(); |         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 |     @Test | ||||||
|     public void verifyFredlPageTitle() { |     public void verifyFredlPageTitle() { | ||||||
|         driver.navigate().to(URL); |         driver.navigate().to(URL); | ||||||
| @@ -60,7 +44,7 @@ public class BasicTest { | |||||||
|         driver.navigate().to(URL); |         driver.navigate().to(URL); | ||||||
|         System.out.println("Navigate to: " + URL); |         System.out.println("Navigate to: " + URL); | ||||||
|  |  | ||||||
|         if (elementExistsById("privacy-cookie-statement")) { |         if (FredlTestHelper.elementExistsById("privacy-cookie-statement")) { | ||||||
|             System.out.println("Cookies consent page is shown"); |             System.out.println("Cookies consent page is shown"); | ||||||
|             WebElement consentButton = driver.findElement(By.id("opt-in-button-allow")); |             WebElement consentButton = driver.findElement(By.id("opt-in-button-allow")); | ||||||
|             consentButton.click(); |             consentButton.click(); | ||||||
| @@ -102,5 +86,18 @@ public class BasicTest { | |||||||
|         String expectedWelcomeMessage = "Willkommen bei FreDL"; |         String expectedWelcomeMessage = "Willkommen bei FreDL"; | ||||||
|         System.out.println("Welcome message is: " + welcomeMessage); |         System.out.println("Welcome message is: " + welcomeMessage); | ||||||
|         Assert.assertEquals(welcomeMessage, expectedWelcomeMessage); |         Assert.assertEquals(welcomeMessage, expectedWelcomeMessage); | ||||||
|  |  | ||||||
|  |         // we leave our tests always with having the driver located to the top frame | ||||||
|  |         driver.switchTo().parentFrame(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void verifyLogout() { | ||||||
|  |         WebElement logoutButton = wait.until(ExpectedConditions.elementToBeClickable(By.name("doLogin"))); | ||||||
|  |  | ||||||
|  |         String frameObenName = "oben"; | ||||||
|  |         wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameObenName)); | ||||||
|  |  | ||||||
|  |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,11 +1,36 @@ | |||||||
| package org.fremo.fredl.test; | package org.fremo.fredl.test; | ||||||
|  | import org.openqa.selenium.By; | ||||||
| import org.openqa.selenium.WebDriver; | import org.openqa.selenium.WebDriver; | ||||||
|  |  | ||||||
|  | import java.util.concurrent.TimeUnit; | ||||||
|  |  | ||||||
| public class FredlTestHelper { | public class FredlTestHelper { | ||||||
|     public static void printPageSource(WebDriver driver) { |     private static int implicitTimeoutMilliseconds = 3000; | ||||||
|  |     private static WebDriver driver; | ||||||
|  |  | ||||||
|  |     public static void setUp(WebDriver _driver) { | ||||||
|  |         driver = _driver; | ||||||
|  |         driver.manage().timeouts().implicitlyWait(implicitTimeoutMilliseconds, TimeUnit.MILLISECONDS); | ||||||
|  |     } | ||||||
|  |     public static void printPageSource() { | ||||||
|         String body; // used for debugging purposes only |         String body; // used for debugging purposes only | ||||||
|  |  | ||||||
|         body = driver.getPageSource(); |         body = driver.getPageSource(); | ||||||
|         System.out.println("HTML: " + body); |         System.out.println("HTML: " + body); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static 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; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static 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; | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										57
									
								
								src/test/java/org/fremo/fredl/test/StartInstaller.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/test/java/org/fremo/fredl/test/StartInstaller.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | package org.fremo.fredl.test; | ||||||
|  |  | ||||||
|  | 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.ExpectedConditions; | ||||||
|  | import org.openqa.selenium.support.ui.WebDriverWait; | ||||||
|  | import org.testng.Assert; | ||||||
|  | import org.testng.annotations.AfterClass; | ||||||
|  | import org.testng.annotations.BeforeClass; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
|  | import java.util.concurrent.TimeUnit; | ||||||
|  |  | ||||||
|  | public class StartInstaller { | ||||||
|  |     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(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void startInstaller() { | ||||||
|  |         driver.navigate().to(URL); | ||||||
|  |         String getTitle = driver.getTitle(); | ||||||
|  |         System.out.println("Page title: " + getTitle); | ||||||
|  |  | ||||||
|  |         if (FredlTestHelper.elementExistsByXpath("//table[@class='loginall']")) { | ||||||
|  |             // Login page shown, thus we do not need to start the installer | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         Assert.assertEquals(getTitle, "FreDL"); | ||||||
|  |         WebElement installerLink = driver.findElement(By.xpath("//a[@href='install.php']")); | ||||||
|  |         String expectedInstallerLinkText = "start the installer"; | ||||||
|  |         Assert.assertEquals(installerLink.getText(), expectedInstallerLinkText); | ||||||
|  |         installerLink.click(); | ||||||
|  |  | ||||||
|  |         FredlTestHelper.printPageSource(); | ||||||
|  |  | ||||||
|  |         //WebElement appLink = wait.until(ExpectedConditions.elementToBeClickable(By.name("doLogin"))); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -3,6 +3,7 @@ | |||||||
| <suite name="Suite" parallel="none"> | <suite name="Suite" parallel="none"> | ||||||
|   <test name="Test"> |   <test name="Test"> | ||||||
|     <classes> |     <classes> | ||||||
|  |       <class name="org.fremo.fredl.test.StartInstaller"/> | ||||||
|       <class name="org.fremo.fredl.test.BasicTest"/> |       <class name="org.fremo.fredl.test.BasicTest"/> | ||||||
|     </classes> |     </classes> | ||||||
|   </test> <!-- Test --> |   </test> <!-- Test --> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user