Skip to content

Commit

Permalink
[java] add some timeouts and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Jan 8, 2024
1 parent e1e538e commit ce0a19e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Map;
import org.assertj.core.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.SessionNotCreatedException;
Expand All @@ -52,6 +53,7 @@ class ChromeDriverFunctionalTest extends JupiterTestBase {
private final String CLIPBOARD_WRITE = "clipboard-write";

@Test
@Timeout(120)
@NoDriverBeforeTest
public void builderGeneratesDefaultChromeOptions() {
// This test won't pass if we want to use Chrome in a non-standard location
Expand All @@ -65,6 +67,7 @@ public void builderGeneratesDefaultChromeOptions() {
}

@Test
@Timeout(120)
@NoDriverBeforeTest
public void builderOverridesDefaultChromeOptions() {
ChromeOptions options = (ChromeOptions) CHROME.getCapabilities();
Expand All @@ -75,6 +78,7 @@ public void builderOverridesDefaultChromeOptions() {
}

@Test
@Timeout(120)
@NoDriverBeforeTest
public void driverOverridesDefaultClientConfig() {
assertThatThrownBy(
Expand All @@ -91,6 +95,7 @@ public void driverOverridesDefaultClientConfig() {
}

@Test
@Timeout(120)
void builderWithClientConfigThrowsException() {
ClientConfig clientConfig = ClientConfig.defaultConfig().readTimeout(Duration.ofMinutes(1));
RemoteWebDriverBuilder builder =
Expand All @@ -102,6 +107,7 @@ void builderWithClientConfigThrowsException() {
}

@Test
@Timeout(120)
@Ignore(value = CHROME, reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4350")
void canSetPermission() {
HasPermissions permissions = (HasPermissions) driver;
Expand Down Expand Up @@ -132,6 +138,7 @@ public String checkPermission(WebDriver driver, String permission) {
}

@Test
@Timeout(120)
@Ignore(gitHubActions = true)
void canCast() {
HasCasting caster = (HasCasting) driver;
Expand All @@ -151,6 +158,7 @@ void canCast() {
}

@Test
@Timeout(120)
@Ignore(gitHubActions = true)
public void canCastOnDesktop() {
HasCasting caster = (HasCasting) driver;
Expand All @@ -170,6 +178,7 @@ public void canCastOnDesktop() {
}

@Test
@Timeout(120)
void canManageNetworkConditions() {
HasNetworkConditions conditions = (HasNetworkConditions) driver;

Expand All @@ -192,6 +201,7 @@ void canManageNetworkConditions() {
}

@Test
@Timeout(120)
void canExecuteCdpCommands() {
HasCdp cdp = (HasCdp) driver;

Expand Down
9 changes: 7 additions & 2 deletions java/test/org/openqa/selenium/testing/JupiterTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.logging.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
Expand All @@ -37,6 +39,7 @@

public abstract class JupiterTestBase {

private static final Logger LOG = Logger.getLogger(JupiterTestBase.class.getName());
@RegisterExtension protected static SeleniumExtension seleniumExtension = new SeleniumExtension();

protected TestEnvironment environment;
Expand All @@ -53,7 +56,7 @@ public static void shouldTestBeRunAtAll() {
}

@BeforeEach
public void prepareEnvironment() {
public void prepareEnvironment(TestInfo info) {
environment = GlobalTestEnvironment.getOrCreate(InProcessTestEnvironment::new);
appServer = environment.getAppServer();

Expand All @@ -62,10 +65,12 @@ public void prepareEnvironment() {
driver = seleniumExtension.getDriver();
wait = seleniumExtension::waitUntil;
shortWait = seleniumExtension::shortWaitUntil;
LOG.info("start test: " + info.getDisplayName());
}

@AfterEach
public void quitLocalDriver() {
public void quitLocalDriver(TestInfo info) {
LOG.info("done with test: " + info.getDisplayName());
if (localDriver != null) {
localDriver.quit();
}
Expand Down

0 comments on commit ce0a19e

Please sign in to comment.