@@ -47,44 +47,14 @@ public class EdgeOptions : ChromiumOptions
4747 {
4848 private const string DefaultBrowserNameValue = "MicrosoftEdge" ;
4949 private const string WebViewBrowserNameValue = "webview2" ;
50-
51- // Engine switching
52- private const string UseChromiumCapability = "ms:edgeChromium" ;
53- private bool useChromium = true ;
54-
5550 private const string EdgeOptionsCapabilityName = "edgeOptions" ;
5651
57- // Edge Legacy options
58- private const string UseInPrivateBrowsingCapability = "ms:inPrivate" ;
59- private const string ExtensionPathsCapability = "ms:extensionPaths" ;
60- private const string StartPageCapability = "ms:startPage" ;
61-
62- private bool useInPrivateBrowsing ;
63- private string startPage ;
64- private List < string > extensionPaths = new List < string > ( ) ;
65-
66- // Additional Edge-specific Chromium options
67- private bool useWebView ;
68-
6952 /// <summary>
7053 /// Initializes a new instance of the <see cref="EdgeOptions"/> class.
7154 /// </summary>
7255 public EdgeOptions ( ) : base ( )
7356 {
7457 this . BrowserName = DefaultBrowserNameValue ;
75- this . AddKnownCapabilityName ( UseChromiumCapability , "UseChromium property" ) ;
76- this . AddKnownCapabilityName ( UseInPrivateBrowsingCapability , "UseInPrivateBrowsing property" ) ;
77- this . AddKnownCapabilityName ( StartPageCapability , "StartPage property" ) ;
78- this . AddKnownCapabilityName ( ExtensionPathsCapability , "AddExtensionPaths method" ) ;
79- }
80-
81- /// <summary>
82- /// Gets or sets a value indicating whether to launch Edge Chromium. Defaults to using Edge Legacy.
83- /// </summary>
84- public bool UseChromium
85- {
86- get { return this . useChromium ; }
87- set { this . useChromium = value ; }
8858 }
8959
9060 /// <summary>
@@ -112,110 +82,5 @@ public bool UseWebView
11282 get { return this . BrowserName == WebViewBrowserNameValue ; }
11383 set { this . BrowserName = value ? WebViewBrowserNameValue : DefaultBrowserNameValue ; }
11484 }
115-
116-
117- /// <summary>
118- /// Gets or sets a value indicating whether the browser should be launched using
119- /// InPrivate browsing.
120- /// </summary>
121- public bool UseInPrivateBrowsing
122- {
123- get { return this . useInPrivateBrowsing ; }
124- set { this . useInPrivateBrowsing = value ; }
125- }
126-
127- /// <summary>
128- /// Gets or sets the URL of the page with which the browser will be navigated to on launch.
129- /// </summary>
130- public string StartPage
131- {
132- get { return this . startPage ; }
133- set { this . startPage = value ; }
134- }
135-
136- /// <summary>
137- /// Adds a path to an extension that is to be used with the Edge Legacy driver.
138- /// </summary>
139- /// <param name="extensionPath">The full path and file name of the extension.</param>
140- public void AddExtensionPath ( string extensionPath )
141- {
142- if ( string . IsNullOrEmpty ( extensionPath ) )
143- {
144- throw new ArgumentException ( "extensionPath must not be null or empty" , "extensionPath" ) ;
145- }
146-
147- this . AddExtensionPaths ( extensionPath ) ;
148- }
149-
150- /// <summary>
151- /// Adds a list of paths to an extensions that are to be used with the Edge Legacy driver.
152- /// </summary>
153- /// <param name="extensionPathsToAdd">An array of full paths with file names of extensions to add.</param>
154- public void AddExtensionPaths ( params string [ ] extensionPathsToAdd )
155- {
156- this . AddExtensionPaths ( new List < string > ( extensionPathsToAdd ) ) ;
157- }
158-
159- /// <summary>
160- /// Adds a list of paths to an extensions that are to be used with the Edge Legacy driver.
161- /// </summary>
162- /// <param name="extensionPathsToAdd">An <see cref="IEnumerable{T}"/> of full paths with file names of extensions to add.</param>
163- public void AddExtensionPaths ( IEnumerable < string > extensionPathsToAdd )
164- {
165- if ( extensionPathsToAdd == null )
166- {
167- throw new ArgumentNullException ( "extensionPathsToAdd" , "extensionPathsToAdd must not be null" ) ;
168- }
169-
170- this . extensionPaths . AddRange ( extensionPathsToAdd ) ;
171- }
172-
173- /// <summary>
174- /// Returns DesiredCapabilities for Edge with these options included as
175- /// capabilities. This copies the options. Further changes will not be
176- /// reflected in the returned capabilities.
177- /// </summary>
178- /// <returns>The DesiredCapabilities for Edge with these options.</returns>
179- public override ICapabilities ToCapabilities ( )
180- {
181- return this . useChromium ? ToChromiumCapabilities ( ) : ToLegacyCapabilities ( ) ;
182- }
183-
184- /// <summary>
185- /// Adds vendor-specific capabilities for Chromium-based browsers.
186- /// </summary>
187- /// <param name="capabilities">The capabilities to add.</param>
188- protected override void AddVendorSpecificChromiumCapabilities ( IWritableCapabilities capabilities )
189- {
190- capabilities . SetCapability ( EdgeOptions . UseChromiumCapability , this . useChromium ) ;
191- }
192-
193- private ICapabilities ToChromiumCapabilities ( )
194- {
195- return base . ToCapabilities ( ) ;
196- }
197-
198- private ICapabilities ToLegacyCapabilities ( )
199- {
200- IWritableCapabilities capabilities = this . GenerateDesiredCapabilities ( true ) ;
201- capabilities . SetCapability ( EdgeOptions . UseChromiumCapability , this . useChromium ) ;
202-
203- if ( this . useInPrivateBrowsing )
204- {
205- capabilities . SetCapability ( UseInPrivateBrowsingCapability , true ) ;
206- }
207-
208- if ( ! string . IsNullOrEmpty ( this . startPage ) )
209- {
210- capabilities . SetCapability ( StartPageCapability , this . startPage ) ;
211- }
212-
213- if ( this . extensionPaths . Count > 0 )
214- {
215- capabilities . SetCapability ( ExtensionPathsCapability , this . extensionPaths ) ;
216- }
217-
218- return capabilities . AsReadOnly ( ) ;
219- }
22085 }
22186}
0 commit comments