forked from museumsvictoria/nodel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
nodel-jyhost/src/test/java/org/nodel/ActiveNavItemSeleniumTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.nodel; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ActiveNavItemSeleniumTest { | ||
|
||
@Test | ||
public void testActiveNavigationItem() { | ||
WebDriver driver = WebDriverSingleton.getDriver(); | ||
driver.get("http://127.0.0.1:8085"); | ||
String activeNavItemText = driver.findElement(By.cssSelector(".nav.navbar-nav .active")).getText(); | ||
assertEquals("Locals", activeNavItemText, "Active navigation item should be 'Locals'"); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
nodel-jyhost/src/test/java/org/nodel/NavigationSeleniumTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.nodel; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class NavigationSeleniumTest { | ||
|
||
@Test | ||
public void testNavigationBarPresence() { | ||
WebDriver driver = WebDriverSingleton.getDriver(); | ||
driver.get("http://127.0.0.1:8085"); | ||
assertNotNull(driver.findElement(By.cssSelector(".navbar")), "Navigation bar should be present"); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
nodel-jyhost/src/test/java/org/nodel/WebDriverSingleton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.nodel; | ||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class WebDriverSingleton { | ||
private static WebDriver driver = null; | ||
|
||
private WebDriverSingleton() {} | ||
|
||
public static WebDriver getDriver() { | ||
if (driver == null) { | ||
ChromeOptions options = new ChromeOptions(); | ||
options.addArguments("--remote-allow-origins=*"); | ||
driver = new ChromeDriver(options); | ||
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); | ||
} | ||
return driver; | ||
} | ||
|
||
public static void quitDriver() { | ||
if (driver != null) { | ||
driver.quit(); | ||
driver = null; | ||
} | ||
} | ||
} |