Skip to content

Commit

Permalink
refactor ChromeDriver setup
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed Sep 23, 2024
1 parent 2fe817a commit b97b1a2
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import com.dumbster.smtp.SimpleSmtpServer;
import org.cloudfoundry.identity.uaa.oauth.client.test.TestAccounts;
import org.cloudfoundry.identity.uaa.test.UaaTestAccounts;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
Expand All @@ -27,7 +27,7 @@

import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.concurrent.TimeUnit;
import java.time.Duration;

@PropertySource("classpath:integration.test.properties")
public class DefaultIntegrationTestConfig {
Expand Down Expand Up @@ -63,6 +63,7 @@ public ChromeDriver webDriver() {
"--verbose",
"--headless=old",
"--window-position=-2400,-2400",
"--window-size=1024,768",
"--disable-web-security",
"--ignore-certificate-errors",
"--allow-running-insecure-content",
Expand All @@ -73,15 +74,12 @@ public ChromeDriver webDriver() {
);

options.setAcceptInsecureCerts(true);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
options.setImplicitWaitTimeout(Duration.ofSeconds(IMPLICIT_WAIT_TIME * timeoutMultiplier));
options.setPageLoadTimeout(Duration.ofSeconds(PAGE_LOAD_TIMEOUT * timeoutMultiplier));
options.setScriptTimeout(Duration.ofSeconds(SCRIPT_TIMEOUT * timeoutMultiplier));

ChromeDriver driver = new ChromeDriver(options);

driver.manage().timeouts()
.implicitlyWait(IMPLICIT_WAIT_TIME * timeoutMultiplier, TimeUnit.SECONDS)
.pageLoadTimeout(PAGE_LOAD_TIMEOUT * timeoutMultiplier, TimeUnit.SECONDS)
.setScriptTimeout(SCRIPT_TIMEOUT * timeoutMultiplier, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(1024, 768));
return driver;
return new ChromeDriver(options);
}

@Bean(destroyMethod = "stop")
Expand Down

0 comments on commit b97b1a2

Please sign in to comment.