-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWebDriverUpdaterFactory.cs
55 lines (36 loc) · 1.79 KB
/
WebDriverUpdaterFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Gsemac.Net.Http;
using Gsemac.Net.WebBrowsers;
using System;
namespace Gsemac.Net.WebDrivers {
public class WebDriverUpdaterFactory :
IWebDriverUpdaterFactory {
// Public members
public WebDriverUpdaterFactory() :
this(WebDriverUpdaterOptions.Default) {
}
public WebDriverUpdaterFactory(IWebDriverUpdaterOptions webDriverUpdaterOptions) :
this(new HttpWebRequestFactory(), webDriverUpdaterOptions) {
}
public WebDriverUpdaterFactory(IHttpWebRequestFactory webRequestFactory, IWebDriverUpdaterOptions webDriverUpdaterOptions) {
this.webRequestFactory = webRequestFactory;
this.webDriverUpdaterOptions = webDriverUpdaterOptions;
}
public IWebDriverUpdater Create(IWebBrowserInfo webBrowserInfo) {
if (webBrowserInfo is null)
throw new ArgumentNullException(nameof(webBrowserInfo));
switch (webBrowserInfo.Id) {
case WebBrowserId.GoogleChrome:
return new ChromeWebDriverUpdater(webRequestFactory, webDriverUpdaterOptions);
case WebBrowserId.MicrosoftEdge:
return new EdgeWebDriverUpdater(webRequestFactory, webDriverUpdaterOptions);
case WebBrowserId.Firefox:
return new FirefoxWebDriverUpdater(webRequestFactory, webDriverUpdaterOptions);
default:
throw new ArgumentException(string.Format(Properties.ExceptionMessages.UnsupportedWebBrowserWithBrowserName, webBrowserInfo.Name), nameof(webBrowserInfo));
}
}
// Private members
private readonly IHttpWebRequestFactory webRequestFactory;
private readonly IWebDriverUpdaterOptions webDriverUpdaterOptions;
}
}