Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Created June 3, 2022 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/aad9a927cd4da7d20d8b2764d4971259 to your computer and use it in GitHub Desktop.
Save nadvolod/aad9a927cd4da7d20d8b2764d4971259 to your computer and use it in GitHub Desktop.
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();
}
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