@@ -16,20 +16,29 @@ public static class BrowserFactory
1616 /// Creates a new instance of <see cref="IBrowser"/> with a given browser type.
1717 /// </summary>
1818 /// <param name="playwright">The <see cref="IPlaywright"/>.</param>
19- /// <param name="browserType">The browser type in which <see cref="IBrowser"/> will be created.</param>
20- /// <param name="headless">Whether the browser runs in headless mode or not.</param>
19+ /// <param name="testOptions">The <see cref="UITestOptions"/>.</param>
2120 /// <returns>An instance of <see cref="IBrowser"/>.</returns>
2221 /// <exception cref="NotSupportedException"></exception>
23- public static async Task < IBrowser > CreateAsync ( IPlaywright playwright , BrowserType browserType , bool headless )
22+ public static async Task < IBrowser > CreateAsync ( IPlaywright playwright , UITestOptions testOptions )
2423 {
25- var browser = browserType switch
24+ var browser = testOptions . BrowserType switch
2625 {
27- BrowserType . Edge => _edgeBrowser ?? await playwright . Chromium . LaunchAsync ( new BrowserTypeLaunchOptions { Channel = "msedge" , Headless = headless } ) ,
28- BrowserType . Chrome => _chromeBrowser ?? await playwright . Chromium . LaunchAsync ( new BrowserTypeLaunchOptions { Headless = headless } ) ,
29- BrowserType . Firefox => _fireFoxBrowser ?? await playwright . Firefox . LaunchAsync ( new BrowserTypeLaunchOptions { Headless = headless } ) ,
26+ BrowserType . Edge => _edgeBrowser ?? await playwright . Chromium . LaunchAsync ( new BrowserTypeLaunchOptions
27+ {
28+ Channel = "msedge" ,
29+ Headless = testOptions . Headless
30+ } ) ,
31+ BrowserType . Chrome => _chromeBrowser ?? await playwright . Chromium . LaunchAsync ( new BrowserTypeLaunchOptions
32+ {
33+ Headless = testOptions . Headless
34+ } ) ,
35+ BrowserType . Firefox => _fireFoxBrowser ?? await playwright . Firefox . LaunchAsync ( new BrowserTypeLaunchOptions
36+ {
37+ Headless = testOptions . Headless
38+ } ) ,
3039 _ => throw new NotSupportedException ( )
3140 } ;
3241
33- return new Browser ( new PlaywrightBrowserAccessor ( browser ) , browserType , headless ) ;
42+ return new Browser ( new PlaywrightBrowserAccessor ( browser ) ) { Type = testOptions . BrowserType } ;
3443 }
3544}
0 commit comments