@@ -13,7 +13,6 @@ public void GetWebDriverShouldCreateALocalChromeDriverFromAppropriateOptions([St
1313 {
1414 DriverType = nameof ( ChromeDriver ) ,
1515 OptionsFactory = ( ) => new ChromeOptions ( ) ,
16- OptionsCustomizer = new AppveyorLinuxChromeCustomizer ( ) ,
1716 } ;
1817
1918 using var driver = sut . GetWebDriver ( options ) . WebDriver ;
@@ -29,24 +28,36 @@ public void GetWebDriverShouldCustomiseDriverOptionsWithCallbackWhenItIsSpecifie
2928 {
3029 DriverType = nameof ( ChromeDriver ) ,
3130 OptionsFactory = ( ) => driverOptions ,
32- OptionsCustomizer = new AppveyorLinuxChromeCustomizer ( ) ,
3331 } ;
3432
3533 using var driver = sut . GetWebDriver ( options , o => o . AddAdditionalOption ( "Foo" , "Bar" ) ) . WebDriver ;
3634 Assert . That ( driverOptions . ToCapabilities ( ) [ "Foo" ] , Is . EqualTo ( "Bar" ) ) ;
3735 }
3836
37+ [ Test , AutoMoqData ]
38+ public void GetWebDriverShouldCustomiseDriverFromCustomizerInstanceIfSpecified ( [ StandardTypes ] IGetsWebDriverAndOptionsTypes typeProvider ,
39+ WebDriverFromOptionsFactory sut )
40+ {
41+ var driverOptions = new ChromeOptions ( ) ;
42+ var customizer = new AppveyorLinuxChromeCustomizer ( ) ;
43+ var options = new WebDriverCreationOptions
44+ {
45+ DriverType = nameof ( ChromeDriver ) ,
46+ OptionsFactory = ( ) => driverOptions ,
47+ OptionsCustomizer = customizer ,
48+ } ;
49+
50+ using var driver = sut . GetWebDriver ( options ) ;
51+ Assert . That ( customizer . IsCustomized , Is . True ) ;
52+ }
53+
3954 public class AppveyorLinuxChromeCustomizer : ICustomizesOptions < ChromeOptions >
4055 {
56+ public bool IsCustomized { get ; private set ; }
57+
4158 public void CustomizeOptions ( ChromeOptions options )
4259 {
43- if ( string . Equals ( Environment . GetEnvironmentVariable ( "APPVEYOR" ) , bool . TrueString , StringComparison . InvariantCultureIgnoreCase )
44- && Environment . GetEnvironmentVariable ( "APPVEYOR_BUILD_WORKER_IMAGE" ) ! . Contains ( "ubuntu" , StringComparison . InvariantCultureIgnoreCase ) )
45- {
46- Console . Error . WriteLine ( "Running on Appveyor Linux, customising Chrome options." ) ;
47- options . BinaryLocation = "/usr/bin/google-chrome" ;
48- options . AddArgument ( "--no-sandbox" ) ;
49- }
60+ IsCustomized = true ;
5061 }
5162 }
5263}
0 commit comments