Welcome to the SmartUI SDK sample for Selenium C#. This repository demonstrates how to integrate SmartUI visual regression testing with Selenium C#.
smartui-csharp-sample/
├── LambdaTest.Selenium.Driver.Test/
│ ├── LTCloudTest.cs # Cloud test
│ ├── LocalTest.cs # Local test
│ ├── LTCloudOptionsTest.cs # Cloud test with options
│ ├── LocalOptionsTest.cs # Local test with options
│ ├── Program.cs # Main entry point
│ ├── LambdaTest.Selenium.Driver.Test.csproj
│ └── smartui-web.json # SmartUI config (create with npx smartui config:create)
└── README.md
- .NET SDK 8.0 or higher
- Node.js installed (for SmartUI CLI)
- LambdaTest account credentials (for Cloud tests)
- Chrome browser (for Local tests)
For Cloud:
export LT_USERNAME='your_username'
export LT_ACCESS_KEY='your_access_key'
export PROJECT_TOKEN='your_project_token'For Local:
export PROJECT_TOKEN='your_project_token'git clone https://github.com/LambdaTest/smartui-csharp-sample
cd smartui-csharp-sample/LambdaTest.Selenium.Driver.TestThe repository already includes the required dependencies in LambdaTest.Selenium.Driver.Test.csproj. Restore them:
dotnet restore
dotnet buildDependencies included:
LambdaTest.Selenium.Driver- SmartUI SDK for Selenium C#Selenium.WebDriver- Selenium WebDriverSelenium.WebDriver.ChromeDriver- ChromeDriver for local testingLambdaTest.Sdk.Utils- LambdaTest SDK utilities
npm install @lambdatest/smartui-clinpx smartui config:create smartui-web.jsonThe SmartUI screenshot function is already implemented in the repository.
Cloud Test (LTCloudTest.cs):
driver.Navigate().GoToUrl("https://www.lambdatest.com");
await SmartUISnapshot.CaptureSnapshot(driver, "screenshot");Local Test (LocalTest.cs):
driver.Navigate().GoToUrl("https://www.lambdatest.com");
await SmartUISnapshot.CaptureSnapshot(driver, "screenshot");Note: The code is already configured and ready to use. You can modify the URL and screenshot name if needed.
npx smartui exec -- dotnet run -- localnpx smartui exec -- dotnet run -- cloud- Connects to LambdaTest Cloud using Selenium Remote WebDriver
- Reads credentials from environment variables (
LT_USERNAME,LT_ACCESS_KEY) - Takes screenshot with name:
screenshot
- Runs Selenium locally using Chrome
- Requires Chrome browser installed
- ChromeDriver is automatically managed
- Takes screenshot with name:
screenshot
LTCloudOptionsTest.cs- Cloud test with SmartUI optionsLocalOptionsTest.cs- Local test with SmartUI options
After running the tests, visit your SmartUI project dashboard to view the captured screenshots and compare them with baseline builds.
For detailed onboarding instructions, see the SmartUI Selenium C# Onboarding Guide.