Struggling to set up cross-browser testing in our .NET CI/CD pipeline with Selenium and Azure DevOps
I'm integrating two systems and After trying multiple solutions online, I still can't figure this out. I'm stuck on something that should probably be simple. During development of a web application using ASP.NET Core, integrating cross-browser testing into our CI/CD pipeline has become a significant concern. Currently, we are utilizing Azure DevOps for our CI/CD workflows, and I want to ensure that browser compatibility is thoroughly validated with automated tests. My initial approach involved using Selenium WebDriver for testing but didn't yield the expected results. Hereβs what I have in place: 1. A basic Selenium setup with Chrome and Firefox drivers. 2. Defined test cases in a separate project using NUnit. 3. Attempted to configure Azure Pipelines to run these tests after the build step. My pipeline definition looks something like this: ```yaml trigger: branches: include: - main pool: vmImage: 'windows-latest' steps: - task: DotNetCoreCLI@2 inputs: command: 'build' projects: '**/*.csproj' - task: DotNetCoreCLI@2 inputs: command: 'test' projects: '**/*.Tests.csproj' arguments: '--logger:trx' - task: PublishTestResults@1 inputs: testResultsFiles: '**/*.trx' testRunTitle: 'Unit Tests' - script: | dotnet test --logger "console;verbosity=detailed" --configuration $(BuildConfiguration) --filter "Category=BrowserTests" displayName: 'Run Browser Tests' ``` Adding to this, I tried using BrowserStack for testing across different browsers and devices. However, I am unclear on how to properly configure the BrowserStack credentials in Azure DevOps without exposing sensitive information. Iβm using environment variables, but the setup feels convoluted and I am not certain if Iβm using best practices. Additionally, I also want to ensure that the tests run on both headless and standard browser instances, to account for different environments. Here are the snippets from the test cases: ```csharp [TestFixture] public class CrossBrowserTests { private IWebDriver driver; [SetUp] public void Setup() { var browser = Environment.GetEnvironmentVariable("BROWSER") ?? "chrome"; driver = browser.ToLower() switch { "firefox" => new FirefoxDriver(), "chrome" => new ChromeDriver(), _ => throw new ArgumentException("Browser not supported") }; } [Test] public void TestHomePage() { driver.Navigate().GoToUrl("https://myapp.com"); var title = driver.Title; Assert.AreEqual("Expected Title", title); } [TearDown] public void Teardown() { driver.Quit(); } } ``` It's essential for our team to have reliable cross-browser coverage. Suggestions on streamlining the integration of Selenium and BrowserStack in Azure DevOps would be greatly appreciated. Any insights into managing the credentials securely and ensuring the tests execute seamlessly would be invaluable. Any help would be greatly appreciated! The stack includes C# and several other technologies. I'd be grateful for any help. I'm developing on macOS with C#. What are your experiences with this? I've been using C# for about a year now. Is there a better approach?