From: Kai Moritz Date: Wed, 22 Jan 2020 12:19:07 +0000 (+0100) Subject: WIP X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=49b744ec187ec3787464074544a35098a7ff38aa;p=demos%2Fspring-boot WIP --- diff --git a/src/test/java/de/juplo/demo/DemoControllerIT.java b/src/test/java/de/juplo/demo/DemoControllerIT.java index d8a4580..dc91846 100644 --- a/src/test/java/de/juplo/demo/DemoControllerIT.java +++ b/src/test/java/de/juplo/demo/DemoControllerIT.java @@ -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(); } } diff --git a/src/test/java/de/juplo/demo/WebDriverExtension.java b/src/test/java/de/juplo/demo/WebDriverExtension.java index ada01f5..f53bcd4 100644 --- a/src/test/java/de/juplo/demo/WebDriverExtension.java +++ b/src/test/java/de/juplo/demo/WebDriverExtension.java @@ -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