Skip to content

Commit 55bda33

Browse files
committed
conditional on missing bean
1 parent d7d1982 commit 55bda33

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/main/java/com/udemy/spring/springselenium/config/WebDriverConfig.java

+11
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
import io.github.bonigarcia.wdm.WebDriverManager;
44
import org.openqa.selenium.WebDriver;
55
import org.openqa.selenium.chrome.ChromeDriver;
6+
import org.openqa.selenium.firefox.FirefoxDriver;
67
import org.openqa.selenium.support.ui.WebDriverWait;
78
import org.springframework.beans.factory.annotation.Value;
9+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
10+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
811
import org.springframework.context.annotation.Bean;
912
import org.springframework.context.annotation.Configuration;
1013
import org.springframework.context.annotation.Lazy;
@@ -17,6 +20,14 @@ public class WebDriverConfig {
1720
private int timeout;
1821

1922
@Bean
23+
@ConditionalOnProperty(name = "browser", havingValue = "firefox")
24+
public WebDriver firefoxDriver(){
25+
WebDriverManager.firefoxdriver().setup();
26+
return new FirefoxDriver();
27+
}
28+
29+
@Bean
30+
@ConditionalOnMissingBean
2031
public WebDriver chromeDriver(){
2132
WebDriverManager.chromedriver().version("77.0.3865.40").setup();
2233
return new ChromeDriver();

src/main/java/com/udemy/spring/springselenium/util/ScreenShotUtil.java

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.springframework.stereotype.Component;
99
import org.springframework.util.FileCopyUtils;
1010

11-
import javax.annotation.PostConstruct;
1211
import java.io.File;
1312
import java.io.IOException;
1413
import java.nio.file.Path;
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
application.url=https://www.google.com
22
screenshot.path=/home/vins/Documents/udemy/temp
3+
browser=firefox

0 commit comments

Comments
 (0)