pCloudy is a cloud testing platform that gives you access to real browsers and devices directly from your automation scripts. This project is a simple C# Selenium example showing how to run browser automation on pCloudy’s remote Selenium grid.
- .NET SDK 8.0 or higher
- A pCloudy account with a valid email and access key
- Network access to the pCloudy Selenium endpoint
Clone the project and restore dependencies:
git clone https://github.com/Pcloudy-Sample/PC-selenium-CSharp.git
cd PC-selenium-CSharp
dotnet restoreOpen Program.cs and update the pcloudyOptions dictionary with your pCloudy account values.
var pcloudyOptions = new Dictionary<string, object>
{
["userName"] = "YOUR_PLOUDY_EMAIL",
["accessKey"] = "YOUR_PLOUDY_ACCESS_KEY",
["os"] = "Windows",
["osVersion"] = "11",
["browserVersion"] = "127",
["seleniumVersion"] = "4.18.1",
["project"] = "Project_1",
["build"] = "Production Run",
["name"] = "Wikipedia Test",
["tag"] = "Wikipedia",
["local"] = false,
["pCloudy_EnableVideo"] = true,
["idleTimeout"] = 10
};Note: These values are hardcoded for the sample. For real use, replace them with environment variables or a secure secret store.
Run the sample with:
dotnet run --project PC-selenium-CSharp.csprojThe sample launches a remote Chrome browser on pCloudy, opens https://www.wikipedia.org/, searches for Selenium, and captures a screenshot.
Program.cs— Selenium test runner and pCloudy capability configurationPC-selenium-CSharp.csproj— .NET project file with Selenium dependencies
| Capability | Description |
|---|---|
userName |
pCloudy account email |
accessKey |
pCloudy access key |
os |
Operating system to run on pCloudy |
osVersion |
OS version to target |
browserVersion |
Browser version to use |
seleniumVersion |
Selenium version to use |
project |
pCloudy project name |
build |
Build name displayed in pCloudy |
name |
Test name displayed in pCloudy |
tag |
Test tag |
local |
Local testing flag |
pCloudy_EnableVideo |
Enable video recording |
idleTimeout |
Idle session timeout in minutes |
- Do not set
options.BrowserVersiononChromeOptionsifbrowserVersionis already specified inpcloudy:options. - The pCloudy Selenium hub URL is configured in
Program.csas_hubUrl. - Screenshots are saved to the
Screenshots/folder.
- If the session fails during creation, verify your pCloudy credentials and hub URL.
- If the browser does not start, check your network access to the pCloudy Selenium endpoint.
- If the build fails, make sure the project is restored and the correct .NET SDK is installed.
- Change
browserVersioninsidepcloudyOptionsto target a different browser version. - Update
project,build,name, andtagto reflect your test run. - Add more Selenium actions after
driver.Navigate().GoToUrl("https://www.wikipedia.org/").
This sample is designed to work with any browser supported by pCloudy. To target a different browser, update the Selenium options object, set the appropriate browserName, and adjust pcloudyOptions["browserVersion"] for the browser/version you want to use.
PC-selenium-CSharp/
├── PC-selenium-CSharp.csproj # .NET project file
├── Program.cs # Selenium test runner and pCloudy configuration
└── README.md # Project documentation
For more pCloudy integration information, see:
Contributions are welcome. Open an issue before submitting a pull request.