@@ -41,7 +41,49 @@ public void DriverTypeNorOptionsTypeShouldBeMandatoryIfACustomFactoryTypeIsSpeci
4141 Assert . That ( ( ) => driver . WebDriver . GetBrowserId ( ) , Is . Not . Null ) ;
4242 }
4343
44- IServiceProvider GetServiceProvider ( Action < WebDriverCreationOptionsCollection > ? configureOptions = null )
44+ [ Test ]
45+ public void GetWebDriverShouldReturnADriverWithTheCorrectQuirksForChrome ( )
46+ {
47+ var services = GetServiceProvider ( extraRegistrations : services => services . AddWebDriverQuirks ( GetCommonBrowserQuirks ( ) ) ) ;
48+
49+ var driverFactory = services . GetRequiredService < IGetsWebDriver > ( ) ;
50+ using var driver = driverFactory . GetWebDriver ( "Chrome" ) ;
51+
52+ Assert . Multiple ( ( ) =>
53+ {
54+ Assert . That ( driver . WebDriver . HasQuirk ( "IAmChrome" ) , Is . True , "Chrome quirk" ) ;
55+ Assert . That ( driver . WebDriver . HasQuirk ( "IAmFirefox" ) , Is . False , "Firefox quirk" ) ;
56+ } ) ;
57+ }
58+
59+ [ Test ]
60+ public void GetWebDriverShouldReturnADriverWithTheCorrectQuirksForFirefox ( )
61+ {
62+ var services = GetServiceProvider ( extraRegistrations : services => services . AddWebDriverQuirks ( GetCommonBrowserQuirks ( ) ) ) ;
63+
64+ var driverFactory = services . GetRequiredService < IGetsWebDriver > ( ) ;
65+ using var driver = driverFactory . GetWebDriver ( "Firefox" ) ;
66+
67+ Assert . Multiple ( ( ) =>
68+ {
69+ Assert . That ( driver . WebDriver . HasQuirk ( "IAmChrome" ) , Is . False , "Chrome quirk" ) ;
70+ Assert . That ( driver . WebDriver . HasQuirk ( "IAmFirefox" ) , Is . True , "Firefox quirk" ) ;
71+ } ) ;
72+ }
73+
74+ Quirks . QuirksData GetCommonBrowserQuirks ( )
75+ {
76+ return new ( )
77+ {
78+ Quirks = new Dictionary < string , Quirks . BrowserInfoCollection >
79+ {
80+ { "IAmChrome" , new ( ) { AffectedBrowsers = new HashSet < Quirks . BrowserInfo > ( ) { new ( ) { Name = "chrome" } } } } ,
81+ { "IAmFirefox" , new ( ) { AffectedBrowsers = new HashSet < Quirks . BrowserInfo > ( ) { new ( ) { Name = "firefox" } } } } ,
82+ }
83+ } ;
84+ }
85+
86+ IServiceProvider GetServiceProvider ( Action < WebDriverCreationOptionsCollection > ? configureOptions = null , Action < IServiceCollection > ? extraRegistrations = null )
4587 {
4688 var services = new ServiceCollection ( ) ;
4789 services . AddSingleton ( GetConfiguration ( ) ) ;
0 commit comments