Giter VIP home page Giter VIP logo

csharp-xunit-selenium's Introduction

Run Selenium Tests With xUnit On LambdaTest

LambdaTest Logo

Learn how to run C# scripts using the xUnit framework.

Blog   ⋅   Docs   ⋅   Learning Hub   ⋅   Newsletter   ⋅   Certifications   ⋅   YouTube

     

Table of Contents:

Prerequisites

Before you start performing C# automation testing with Selenium using xUnit, you need to:

  • Download and install Selenium WebDriver from its official website.
  • Ensure you have the latest version of C#.
  • .NET framework for guidelines while developing a range of applications using C#.
  • Download Selenium WebDriver Language Binding for C# and extract them to the appropriate folder. Require a .NET Core SDK of 8.0 or greater version.

Installing Selenium Dependencies And Tutorial Repo

Step 1: Clone the LambdaTest CSharp-xUnit-Selenium GitHub repository and navigate to the code directory:

git clone https://github.com/LambdaTest/CSharp-xUnit-Selenium
cd CSharp-xUnit-Selenium

Setting up Your Authentication

Ensure you have your LambdaTest credentials to run C# automation scripts. Obtain these credentials from the LambdaTest Automation Dashboard or your LambdaTest Profile.

Step 2: Set your LambdaTest Username and Access Key in environment variables.

For Linux/macOS:

export LT_USERNAME="YOUR_USERNAME" 
export LT_ACCESS_KEY="YOUR_ACCESS_KEY"

For Windows:

set LT_USERNAME="YOUR_USERNAME"
set LT_ACCESS_KEY="YOUR_ACCESS_KEY"

Run Your First Test

Test Scenario: Check out the sample SingleTest.cs file. This xUnit Selenium script tests a sample to-do list app by marking a couple of items as done, adding a new item to the list, and finally displaying the count of pending items as output.

Step 3: Navigate to config.json using VSCode. Replace this code in the config.json file in your project.

Configuration of Your Test Capabilities

Step 4: In the config, update your test capabilities. We are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via the capabilities object.

Example capabilities object:

{
  "server": "hub.lambdatest.com",
  "user": "LT_USERNAME",
  "key": "LT_ACCESS_KEY",

  "capabilities": {
    "lt:options": {
      "buildName": "xunit build",
      "sessionName": "lambdatest xunit sample test",
      "visual": "true",
      "plugin": "xunit:sample"
    }
  },

  "environments": [
    {
      "browserName": "chrome"
    },
    {
      "browserName": "firefox"
    },
    {
      "browserName": "safari"
    }
  ],

  "TunnelOptions": {
    "tunnel": false
  }
}

Note: Generate capabilities for your test requirements with the help of the Desired Capability Generator.

Executing the Test

Step 5: Build the solution in Visual Studio.

Step 6: Run the

tests from the Test Explorer in Visual Studio.

Executing in Linux/macOS

  • Clean and rebuild the project.
dotnet clean
  • Execute Single Test
dotnet test --filter "profile=single"

Running Your Parallel Tests Using xUnit Testing Framework

Executing Parallel tests in Windows

Run all tests from the Test Explorer in Visual Studio for parallel execution.

Executing parallel tests in Linux/MacOS

dotnet test --filter "profile=parallel"

Testing Locally Hosted Or Privately Hosted Projects

For testing locally hosted or privately hosted projects with LambdaTest Selenium grid using LambdaTest Tunnel, follow the LambdaTest Tunnel documentation.

Download the LambdaTest Tunnel binary for your OS and run the following command:

LT -user {user’s login email} -key {user’s access key}

Tunnel Capability

"lt:options": {
      "buildName": "xunit build",
      "sessionName": "lambdatest xunit sample test",
      "visual": "true",
      "plugin": "xunit:sample",
      "tunnel": "true"
    }

Tutorials 📙

coming soon

Subscribe To Our LambdaTest YouTube Channel 🔔 for the latest video tutorials.

Documentation & Resources 📚

LambdaTest Community 👥

Join the LambdaTest Community to interact with tech enthusiasts. Connect, ask questions, and learn from professionals worldwide.

What's New At LambdaTest ❓

Stay updated with the latest features and product add-ons at Changelog.

About LambdaTest

LambdaTest is a leading test execution and orchestration platform. It allows users to run both manual and automated testing of web and mobile apps across various browsers, operating systems, and real device combinations. Over 500 enterprises and 1 million+ users across 130+ countries rely on LambdaTest for their testing needs.

Features

  • Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments.
  • Real-time Cross-browser testing on 3000+ environments.
  • Test on Real device cloud.
  • Blazing fast test automation with HyperExecute.
  • Accelerate testing, shorten job times, and get faster feedback on code changes with Test At Scale.
  • Smart Visual Regression Testing on the cloud.
  • 120+ third-party integration with your favorite tools for CI/CD, Project Management, Codeless Automation, and more.
  • Automated Screenshot testing across multiple browsers in a single click.
  • Local testing of web and mobile apps.
  • Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems.
  • Geolocation testing of web and mobile apps across 53+ countries.
  • LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports.

We Are Here to Help You 🎧

csharp-xunit-selenium's People

Contributors

4dvanceboy avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.