Created
June 3, 2022 12:14
-
-
Save nadvolod/aad9a927cd4da7d20d8b2764d4971259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Core.BestPractices.Web.Tests.Desktop | |
{ | |
// We read data from TestConfigData.PopularDesktopCombinations | |
[TestFixtureSource(typeof(TestConfigData), nameof(TestConfigData.PopularDesktopCombinations))] | |
[TestFixture] | |
[Parallelizable] | |
public class DesktopTests : WebTestsBase | |
{ | |
[SetUp] | |
public void SetupDesktopTests() | |
{ | |
if (BrowserOptions.BrowserName == "chrome") | |
((ChromeOptions) BrowserOptions).AddAdditionalCapability("sauce:options", SauceOptions, true); | |
else | |
BrowserOptions.AddAdditionalCapability("sauce:options", SauceOptions); | |
Driver = GetDesktopDriver(BrowserOptions.ToCapabilities()); | |
} | |
public string BrowserVersion { get; } | |
public string PlatformName { get; } | |
public DriverOptions BrowserOptions { get; } | |
public DesktopTests(string browserVersion, string platformName, DriverOptions browserOptions) | |
{ | |
if (string.IsNullOrEmpty(browserVersion)) | |
BrowserVersion = browserVersion; | |
if (string.IsNullOrEmpty(platformName)) | |
PlatformName = platformName; | |
BrowserOptions = browserOptions; | |
} | |
[Test] | |
[Category("ci")] | |
public void LoginWorks() | |
{ | |
var loginPage = new LoginPage(Driver); | |
loginPage.Visit(); | |
loginPage.Login("standard_user"); | |
new ProductsPage(Driver).IsVisible().Should().NotThrow(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestConfigData | |
{ | |
private const string defaultBrowserVersion = ""; | |
private const string defaultOS = ""; | |
private static readonly SafariOptions safariOptions = new() | |
{ | |
BrowserVersion = "latest", | |
PlatformName = "macOS 10.15" | |
}; | |
private static readonly ChromeOptions chromeOptions = new() | |
{ | |
BrowserVersion = "latest", | |
PlatformName = "Windows 10", | |
UseSpecCompliantProtocol = true | |
}; | |
private static readonly EdgeOptions edgeOptions = new() | |
{ | |
BrowserVersion = "latest", | |
PlatformName = "Windows 10" | |
}; | |
internal static IEnumerable PopularDesktopCombinations | |
{ | |
get | |
{ | |
yield return new TestFixtureData("latest", "macOS 10.15", safariOptions); | |
yield return new TestFixtureData(defaultBrowserVersion, defaultOS, chromeOptions); | |
yield return new TestFixtureData(defaultBrowserVersion, defaultOS, edgeOptions); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment