Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Run Selenium Tests with C# on pCloudy

pCloudy Selenium

Getting Started

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.

Prerequisites

  • .NET SDK 8.0 or higher
  • A pCloudy account with a valid email and access key
  • Network access to the pCloudy Selenium endpoint

Getting Started

Clone the project and restore dependencies:

git clone https://github.com/Pcloudy-Sample/PC-selenium-CSharp.git
cd PC-selenium-CSharp
dotnet restore

Configure your credentials

Open 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.

Running the Sample

Run the sample with:

dotnet run --project PC-selenium-CSharp.csproj

The sample launches a remote Chrome browser on pCloudy, opens https://www.wikipedia.org/, searches for Selenium, and captures a screenshot.

Key files

  • Program.cs — Selenium test runner and pCloudy capability configuration
  • PC-selenium-CSharp.csproj — .NET project file with Selenium dependencies

Capabilities used in this sample

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

Important notes

  • Do not set options.BrowserVersion on ChromeOptions if browserVersion is already specified in pcloudy:options.
  • The pCloudy Selenium hub URL is configured in Program.cs as _hubUrl.
  • Screenshots are saved to the Screenshots/ folder.

Troubleshooting

  • 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.

Customization

  • Change browserVersion inside pcloudyOptions to target a different browser version.
  • Update project, build, name, and tag to reflect your test run.
  • Add more Selenium actions after driver.Navigate().GoToUrl("https://www.wikipedia.org/").

Browser support

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.

Project Structure

PC-selenium-CSharp/
├── PC-selenium-CSharp.csproj    # .NET project file
├── Program.cs                   # Selenium test runner and pCloudy configuration
└── README.md                    # Project documentation

API Documentation

For more pCloudy integration information, see:

Learn More

Contributions

Contributions are welcome. Open an issue before submitting a pull request.

Releases

Packages

Contributors

Languages