WIP
authorKai Moritz <kai@juplo.de>
Wed, 22 Jan 2020 12:19:07 +0000 (13:19 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 7 Apr 2023 11:15:40 +0000 (13:15 +0200)
src/test/java/de/juplo/demo/DemoControllerIT.java
src/test/java/de/juplo/demo/WebDriverExtension.java

index d8a4580..dc91846 100644 (file)
@@ -2,11 +2,16 @@ package de.juplo.demo;
 
 
 import lombok.extern.slf4j.Slf4j;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
 import org.openqa.selenium.remote.RemoteWebDriver;
 import org.springframework.boot.test.context.SpringBootTest;
 import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
+import org.springframework.boot.web.server.LocalServerPort;
 
 
 /**
@@ -18,9 +23,24 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
 @Slf4j
 public class DemoControllerIT
 {
+  @LocalServerPort
+  int port;
+  String baseUri;
+
+
+  @BeforeEach()
+  void generateBaseUri()
+  {
+    baseUri = "http://localhost:" + port;
+  }
+
+
   @Test
   void testSubmit(RemoteWebDriver driver)
   {
-    
+    driver.get(baseUri + "/");
+
+    WebElement submit = driver.findElement(By.xpath(".card-footer/button"));
+    assertThat(submit).isNotNull();
   }
 }
index ada01f5..f53bcd4 100644 (file)
@@ -1,6 +1,7 @@
 package de.juplo.demo;
 
 
+import java.io.File;
 import org.junit.jupiter.api.extension.BeforeEachCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.api.extension.ParameterContext;
@@ -25,7 +26,10 @@ public class WebDriverExtension implements BeforeEachCallback, ParameterResolver
   @Override
   public void beforeEach(ExtensionContext context) throws Exception
   {
-    chrome = new BrowserWebDriverContainer().withCapabilities(DesiredCapabilities.chrome());
+    chrome =
+        new BrowserWebDriverContainer()
+            .withCapabilities(DesiredCapabilities.chrome())
+            .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL, new File("./target/"));
   }
 
   @Override