-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix chrome/selenium tests #25330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix chrome/selenium tests #25330
Changes from all commits
dd42fdc
3e0f62e
e0cb381
7d71792
a24de39
24e98d7
b5b63bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,10 @@ | |
using System.Threading.Tasks; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
using OpenQA.Selenium.Edge; | ||
using OpenQA.Selenium.IE; | ||
using OpenQA.Selenium.Remote; | ||
using OpenQA.Selenium.Safari; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
|
@@ -234,55 +237,75 @@ private string UserProfileDirectory(string context) | |
name = $"{name} - {context}"; | ||
} | ||
|
||
var capabilities = new DesiredCapabilities(); | ||
DriverOptions options; | ||
|
||
switch (sauce.BrowserName.ToLower()) | ||
{ | ||
case "chrome": | ||
options = new ChromeOptions(); | ||
break; | ||
case "safari": | ||
options = new SafariOptions(); | ||
break; | ||
case "internet explorer": | ||
options = new InternetExplorerOptions(); | ||
break; | ||
case "microsoftedge": | ||
options = new EdgeOptions(); | ||
break; | ||
default: | ||
throw new InvalidOperationException($"Browser name {sauce.BrowserName} not recognized"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? We ended up not going this route @ajaybhargavb isn't that the case? We only need chrome I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need Chrome for local and CI tests. But we use other browsers when running in SauceLabs. We need to pass in the correct options to SauceLabs in that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ajaybhargavb but do we actually run in SauceLabs? I thought we discarded that idea. That's why I'm asking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still want to. What we discarded was the idea to do real device testing on SauceLabs. |
||
|
||
// Required config | ||
capabilities.SetCapability("username", sauce.Username); | ||
capabilities.SetCapability("accessKey", sauce.AccessKey); | ||
capabilities.SetCapability("tunnelIdentifier", sauce.TunnelIdentifier); | ||
capabilities.SetCapability("name", name); | ||
options.AddAdditionalOption("username", sauce.Username); | ||
options.AddAdditionalOption("accessKey", sauce.AccessKey); | ||
options.AddAdditionalOption("tunnelIdentifier", sauce.TunnelIdentifier); | ||
options.AddAdditionalOption("name", name); | ||
|
||
if (!string.IsNullOrEmpty(sauce.BrowserName)) | ||
{ | ||
capabilities.SetCapability("browserName", sauce.BrowserName); | ||
options.AddAdditionalOption("browserName", sauce.BrowserName); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(sauce.PlatformVersion)) | ||
{ | ||
capabilities.SetCapability("platformName", sauce.PlatformName); | ||
capabilities.SetCapability("platformVersion", sauce.PlatformVersion); | ||
options.PlatformName = sauce.PlatformName; | ||
options.AddAdditionalOption("platformVersion", sauce.PlatformVersion); | ||
} | ||
else | ||
{ | ||
// In some cases (like macOS), SauceLabs expects us to set "platform" instead of "platformName". | ||
capabilities.SetCapability("platform", sauce.PlatformName); | ||
options.AddAdditionalOption("platform", sauce.PlatformName); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(sauce.BrowserVersion)) | ||
{ | ||
capabilities.SetCapability("browserVersion", sauce.BrowserVersion); | ||
options.BrowserVersion = sauce.BrowserVersion; | ||
} | ||
|
||
if (!string.IsNullOrEmpty(sauce.DeviceName)) | ||
{ | ||
capabilities.SetCapability("deviceName", sauce.DeviceName); | ||
options.AddAdditionalOption("deviceName", sauce.DeviceName); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(sauce.DeviceOrientation)) | ||
{ | ||
capabilities.SetCapability("deviceOrientation", sauce.DeviceOrientation); | ||
options.AddAdditionalOption("deviceOrientation", sauce.DeviceOrientation); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(sauce.AppiumVersion)) | ||
{ | ||
capabilities.SetCapability("appiumVersion", sauce.AppiumVersion); | ||
options.AddAdditionalOption("appiumVersion", sauce.AppiumVersion); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(sauce.SeleniumVersion)) | ||
{ | ||
capabilities.SetCapability("seleniumVersion", sauce.SeleniumVersion); | ||
options.AddAdditionalOption("seleniumVersion", sauce.SeleniumVersion); | ||
} | ||
|
||
var capabilities = options.ToCapabilities(); | ||
|
||
await SauceConnectServer.StartAsync(output); | ||
|
||
var attempt = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"drivers": { | ||
"chrome": {} | ||
"chrome": { | ||
"version" : "85.0.4183.87" | ||
} | ||
}, | ||
"ignoreExtraDrivers": true | ||
"ignoreExtraDrivers": true | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty big jump. Did something change with the way the package is versioned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, they moved to use versions matching Chrome versions. There as a jump from v.2.46.0 to v.71.0.3578.137 a while back.
In addition, we were almost 2 years out-of-date in using v2.43.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. That makes sense.
How does this mesh with the fact that we don't control what version of Chrome is downloaded with the installer (AFAIK)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should mean we can be proactive. Whenever a dev notices their Chrome installation wants to be restarted, they can check whether it's a new major version and update this particular package version. Or, @sebastienros could add a reminder to check the Selenium versions in his ops rotation invites every few (10?) rotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could, I am afraid I will forget ;) I would suggest to update the operations book, and let's say "if your rotation happens on the first Tuesday of the month then you should ..."
Mondays are frequently skipped due to holidays
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. May also need something in https://github.com/dotnet/aspnetcore-internal/blob/master/.github/ISSUE_TEMPLATE/Build_OPS_handoff.md @JunTaoLuo what do you think❔