|
11 | 11 | using System.Threading.Tasks; |
12 | 12 | using OpenQA.Selenium; |
13 | 13 | using OpenQA.Selenium.Chrome; |
| 14 | +using OpenQA.Selenium.Edge; |
| 15 | +using OpenQA.Selenium.IE; |
14 | 16 | using OpenQA.Selenium.Remote; |
| 17 | +using OpenQA.Selenium.Safari; |
15 | 18 | using Xunit; |
16 | 19 | using Xunit.Abstractions; |
17 | 20 |
|
@@ -234,55 +237,75 @@ private string UserProfileDirectory(string context) |
234 | 237 | name = $"{name} - {context}"; |
235 | 238 | } |
236 | 239 |
|
237 | | - var capabilities = new DesiredCapabilities(); |
| 240 | + DriverOptions options; |
| 241 | + |
| 242 | + switch (sauce.BrowserName.ToLower()) |
| 243 | + { |
| 244 | + case "chrome": |
| 245 | + options = new ChromeOptions(); |
| 246 | + break; |
| 247 | + case "safari": |
| 248 | + options = new SafariOptions(); |
| 249 | + break; |
| 250 | + case "internet explorer": |
| 251 | + options = new InternetExplorerOptions(); |
| 252 | + break; |
| 253 | + case "microsoftedge": |
| 254 | + options = new EdgeOptions(); |
| 255 | + break; |
| 256 | + default: |
| 257 | + throw new InvalidOperationException($"Browser name {sauce.BrowserName} not recognized"); |
| 258 | + } |
238 | 259 |
|
239 | 260 | // Required config |
240 | | - capabilities.SetCapability("username", sauce.Username); |
241 | | - capabilities.SetCapability("accessKey", sauce.AccessKey); |
242 | | - capabilities.SetCapability("tunnelIdentifier", sauce.TunnelIdentifier); |
243 | | - capabilities.SetCapability("name", name); |
| 261 | + options.AddAdditionalCapability("username", sauce.Username); |
| 262 | + options.AddAdditionalCapability("accessKey", sauce.AccessKey); |
| 263 | + options.AddAdditionalCapability("tunnelIdentifier", sauce.TunnelIdentifier); |
| 264 | + options.AddAdditionalCapability("name", name); |
244 | 265 |
|
245 | 266 | if (!string.IsNullOrEmpty(sauce.BrowserName)) |
246 | 267 | { |
247 | | - capabilities.SetCapability("browserName", sauce.BrowserName); |
| 268 | + options.AddAdditionalCapability("browserName", sauce.BrowserName); |
248 | 269 | } |
249 | 270 |
|
250 | 271 | if (!string.IsNullOrEmpty(sauce.PlatformVersion)) |
251 | 272 | { |
252 | | - capabilities.SetCapability("platformName", sauce.PlatformName); |
253 | | - capabilities.SetCapability("platformVersion", sauce.PlatformVersion); |
| 273 | + options.PlatformName = sauce.PlatformName; |
| 274 | + options.AddAdditionalCapability("platformVersion", sauce.PlatformVersion); |
254 | 275 | } |
255 | 276 | else |
256 | 277 | { |
257 | 278 | // In some cases (like macOS), SauceLabs expects us to set "platform" instead of "platformName". |
258 | | - capabilities.SetCapability("platform", sauce.PlatformName); |
| 279 | + options.AddAdditionalCapability("platform", sauce.PlatformName); |
259 | 280 | } |
260 | 281 |
|
261 | 282 | if (!string.IsNullOrEmpty(sauce.BrowserVersion)) |
262 | 283 | { |
263 | | - capabilities.SetCapability("browserVersion", sauce.BrowserVersion); |
| 284 | + options.BrowserVersion = sauce.BrowserVersion; |
264 | 285 | } |
265 | 286 |
|
266 | 287 | if (!string.IsNullOrEmpty(sauce.DeviceName)) |
267 | 288 | { |
268 | | - capabilities.SetCapability("deviceName", sauce.DeviceName); |
| 289 | + options.AddAdditionalCapability("deviceName", sauce.DeviceName); |
269 | 290 | } |
270 | 291 |
|
271 | 292 | if (!string.IsNullOrEmpty(sauce.DeviceOrientation)) |
272 | 293 | { |
273 | | - capabilities.SetCapability("deviceOrientation", sauce.DeviceOrientation); |
| 294 | + options.AddAdditionalCapability("deviceOrientation", sauce.DeviceOrientation); |
274 | 295 | } |
275 | 296 |
|
276 | 297 | if (!string.IsNullOrEmpty(sauce.AppiumVersion)) |
277 | 298 | { |
278 | | - capabilities.SetCapability("appiumVersion", sauce.AppiumVersion); |
| 299 | + options.AddAdditionalCapability("appiumVersion", sauce.AppiumVersion); |
279 | 300 | } |
280 | 301 |
|
281 | 302 | if (!string.IsNullOrEmpty(sauce.SeleniumVersion)) |
282 | 303 | { |
283 | | - capabilities.SetCapability("seleniumVersion", sauce.SeleniumVersion); |
| 304 | + options.AddAdditionalCapability("seleniumVersion", sauce.SeleniumVersion); |
284 | 305 | } |
285 | 306 |
|
| 307 | + var capabilities = options.ToCapabilities(); |
| 308 | + |
286 | 309 | await SauceConnectServer.StartAsync(output); |
287 | 310 |
|
288 | 311 | var attempt = 0; |
|
0 commit comments