π Selenium Framework using C# (CSharp) development from scratch
- Visual Studio IDE
- Clone the repo
https://gitlab.com/the-ta-crowd/SeleniumUsingCSharp
- Once done, open the solution in Visual Studio IDE
SeleniumCSharpNetCore.sln
- Install Nuget packgae
Right-click on project and click "Manage NuGet Package" and install it
Selenium WebDriver
is an open-source web automation framework that permits you to execute cross-browser tests.Specflow
is a tool supporting BDD (Behavior Driven Development) practices in .NET frameworkExtentReport
allows to generate custom logs, snapshots along with pie chart and dashboard
Base
- Page Initialization with base classConfig
- Configuratio of config xml fileExtension
- WebDriver and WebElement extension methodFeature
- Feature reside hereHooks
- Specflow hooksPages
- Pages of POM (Page Object Model)Steps
- Step definition glue code reside hereResult
- Test result
- [π Page Initialization with Base Class]
- [π Page Navigation]
- [π Page Generator]
- [π WebDriver and WebElement Extension Methods]
Many times, we try to pass the WebDriver object over and over again from one class to another class.
By the means of Constructor or passing it as a parameter in the method where IWebDriver instance is required.
Created a base abstract class and create a private property
We create a function or method without any return type.
Ensure that business logic is embedded in our test code.
We can establish relationships between each page.
While an operation is performed on one method it may or may not return a page object.
How did we accomplish this? Generics in C# were used to accomplish this.
In the following section, we discuss this topic in more detail
Generics in C# give the user the ability to write classes or functions that can work with any data type easily.
We might say a generic class or function that is compatible with any other data type.
All we need to do is define it with a placeholder.
To put it simply, we have to write a set of methods or classes that take arguments based on the data type.
The constructor will therefore generate code to handle the specified data type when it encounters a compiler.
Extension Methods enable you to add methods to an existing type without creating a new derived type.
An extension method is a static method of a static class.
Where the βthisβ modifier is applied to the first parameter.
The type of the first parameter will be the type that is extended.
- Executing test in parallel