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;
/**
@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();
}
}
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;
@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