Skip to content

Commit

Permalink
chore: fix webdriver configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Sep 14, 2023
1 parent 4647516 commit 1a90544
Showing 1 changed file with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package mucsi96.traininglog.core;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import lombok.Data;

Expand All @@ -18,22 +23,24 @@ public class WebDriverConfiguration {
private String apiUri;

@Bean
public WebDriver getWebDriver() {
ChromeOptions options = new ChromeOptions().addArguments("--headless",
"--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage",
"--window-size=1920,1080", "--remote-allow-origins=*");

ChromeDriver driver = new ChromeDriver(options);
driver.setLogLevel(Level.WARNING);
return driver;
@Profile({ "test", "local" })
public WebDriver getLocalWebDriver() {
ChromeOptions options = new ChromeOptions().addArguments("--headless",
"--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage",
"--window-size=1920,1080", "--remote-allow-origins=*");

ChromeDriver driver = new ChromeDriver(options);
driver.setLogLevel(Level.WARNING);
return driver;
}

// @Bean
// public WebDriver getWebDriver() throws MalformedURLException {
// ChromeOptions options = new ChromeOptions().addArguments("--headless", "--no-sandbox", "--disable-dev-shm-usage");
@Bean
@Profile({ "prod" })
public WebDriver getRemoteWebDriver() throws MalformedURLException {
ChromeOptions options = new ChromeOptions().addArguments("--headless", "--no-sandbox", "--disable-dev-shm-usage");

// RemoteWebDriver driver = new RemoteWebDriver(new URL(apiUri), options);
// driver.setLogLevel(Level.WARNING);
// return new Augmenter().augment(driver);
// }
RemoteWebDriver driver = new RemoteWebDriver(new URL(apiUri), options);
driver.setLogLevel(Level.WARNING);
return new Augmenter().augment(driver);
}
}

0 comments on commit 1a90544

Please sign in to comment.