Skip to content

Commit

Permalink
Merge pull request #10 from RohitM-IN/dev
Browse files Browse the repository at this point in the history
Release 1.1
  • Loading branch information
RohitM-IN authored Aug 15, 2023
2 parents 69109f0 + 00bdaff commit ce6185c
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 130 deletions.
88 changes: 60 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,89 @@
# Selenium Grid Manager
# Selenium Manager

Selenium Grid Manager is a C# library designed to efficiently manage multiple Selenium WebDriver instances in parallel, making use of Selenium Grid.

> Note: As a solo developer I only got time on weekends as I do have a job so you can only expect any updates on this project on weekends.
Selenium Manager is a .NET library designed to simplify parallel testing and dynamic browser instance management using Selenium WebDriver.

## Table of Contents

- [Overview](#overview)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Contributing](#contributing)
- [Initializing Selenium Manager](#initializing-selenium-manager)
- [Enqueuing Actions](#enqueuing-actions)
- [Parallel Testing](#parallel-testing)
- [API Reference](doc/API_REFERENCE.md)
- [Contributing](doc/CONTRIBUTING.md)
- [License](#license)

## Overview

Selenium Grid Manager is a library which simplifies the management of Selenium WebDriver instances in parallel using Selenium Grid. It provides a convenient interface for enqueueing test actions and executing them on available WebDriver instances in parallel.

## Features

- Efficient management of multiple WebDriver instances in parallel
- Automatic scaling of WebDriver instances based on the test queue
- Retry mechanism for handling test failures
- Configuration options for customizing the behavior
- Simplifies parallel testing with Selenium WebDriver
- Dynamic browser instance management
- Automatic browser selection based on statistics
- Customizable browser options
- Easily integrate with your existing Selenium projects

## Installation

To use Selenium Grid Manager in your C# project, you can install it via NuGet. Open the NuGet Package Manager console and run the following command:
To use Selenium Manager, you need to install the NuGet package `SeleniumManager.Core`.

## Usage

### Initializing Selenium Manager

```bash
Install-Package SeleniumManager.Core
To get started, you'll need to initialize the Selenium Manager by creating an instance of the `SeleniumManager` class. You can provide a custom configuration file path or use the default configuration included in the library.

```csharp
using SeleniumManager.Core;

// Initialize Selenium Manager with default configuration
var configManager = new ConfigManager();
var seleniumManager = new SeleniumManager(configManager);
```

Alternatively, you can manually add the SeleniumGridManager package reference to your project file.
### Enqueuing Actions

> Note: this package is still in developement
Enqueuing an action allows you to add a function to the execution queue, which will be processed in parallel on available browser instances.

## Usage
```csharp
// Enqueue an action without specifying a browser
var result = await seleniumManager.EnqueueAction(BrowseWebsite);

// Enqueue an action and specify the browser
var chromeResult = await seleniumManager.EnqueueAction(BrowseWebsite, WebDriverType.Chrome.GetDescription());
```

Provide instructions and examples for using the project. Explain how to run tests, execute commands, or perform any relevant actions. Include code snippets or screenshots if applicable.
### Parallel Testing

## Configuration
Selenium Manager makes it easy to perform parallel testing by enqueuing multiple actions simultaneously.

Explain any configuration options or settings that can be customized. Provide details on how to modify the configuration and what each option does. If applicable, include sample configuration files or templates.
```csharp
using System.Threading.Tasks;
using System.Collections.Generic;

## Contributing
// Perform parallel testing with multiple tasks
List<Task> tasks = new List<Task>();

for (int i = 0; i < 10; i++)
{
Task task = Task.Run(async () =>
{
await seleniumManager.EnqueueAction(BrowseWebsite);
});

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.
tasks.Add(task);
}

When contributing to this project, please follow the existing coding style, write clear commit messages, and provide appropriate documentation or tests for your changes.
await Task.WhenAll(tasks);

```

## API Reference

For detailed information about the available classes, methods, and options, please refer to the [API Reference](/doc/API_REFERENCE.md).

## Contributing
Contributions to this project are welcome! For more information on how to contribute, please read the [Contributing Guidelines](/doc/CONTRIBUTING.md).

## License

This project is licensed under the MIT License.
This project is licensed under the [MIT License](/LICENSE.txt).
10 changes: 2 additions & 8 deletions SeleniumManager.Core/ConfigManager.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
using Newtonsoft.Json;
using SeleniumManager.Core.DataContract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace SeleniumManager.Core
{
public class ConfigManager
{
#region Declaration

public readonly ConfigurationSettings configSettings;

#endregion
Expand Down Expand Up @@ -62,7 +56,7 @@ private ConfigurationSettings LoadConfigSettingsFromFile(string configFilePath)
{
string configJson = File.ReadAllText(configFilePath);
return JsonConvert.DeserializeObject<ConfigurationSettings>(configJson);
}
}
catch (FileNotFoundException)
{
// Handle missing config file
Expand Down
9 changes: 1 addition & 8 deletions SeleniumManager.Core/DataContract/Browser.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumManager.Core.DataContract
namespace SeleniumManager.Core.DataContract
{
public class Browser
{
Expand All @@ -14,4 +8,3 @@ public class Browser
public bool IsExcluded { get; set; } = false;
}
}

11 changes: 2 additions & 9 deletions SeleniumManager.Core/DataContract/ConfigurationSettings.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumManager.Core.DataContract
namespace SeleniumManager.Core.DataContract
{
public class ConfigurationSettings
{
public string GridHost { get; set; }
public Dictionary<string,int> statistics { get; set; }
public Dictionary<string, int> statistics { get; set; }
public List<string> Drivers { get; set; }
public string Secret { get; set; }
public int MaxConcurrency { get; set; }
Expand Down
8 changes: 1 addition & 7 deletions SeleniumManager.Core/DataContract/Endpoints.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumManager.Core.DataContract
namespace SeleniumManager.Core.DataContract
{
public class Endpoints
{
Expand Down
20 changes: 7 additions & 13 deletions SeleniumManager.Core/DataContract/Options.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Chromium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Safari;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumManager.Core.DataContract
{
Expand Down Expand Up @@ -37,11 +30,12 @@ public static ChromeOptions GetChromeOptions()
public static FirefoxOptions GetFirefoxOptions()
{
var firefoxOptions = new FirefoxOptions();

#if !DEBUG
firefoxOptions.AddArgument("headless");
firefoxOptions.AddArgument("-headless");
#endif
//firefoxOptions.AddArgument("disable-gpu");
//firefoxOptions.AddArgument("no-sandbox");
firefoxOptions.AddArgument("-disable-gpu");
firefoxOptions.AddArgument("-no-sandbox");
firefoxOptions.AddArgument("--blink-settings=imagesEnabled=false");
return firefoxOptions;
}
Expand All @@ -60,7 +54,7 @@ public static EdgeOptions GetEdgeOptions()

public static InternetExplorerOptions GetInternetExplorerOptions() => new InternetExplorerOptions();

public static SafariOptions GetSafariOptions() => new SafariOptions();
public static SafariOptions GetSafariOptions() => new SafariOptions();

}
}
8 changes: 1 addition & 7 deletions SeleniumManager.Core/Enum/AdjustType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumManager.Core.Enum
namespace SeleniumManager.Core.Enum
{
/// <summary>
/// Tells the selenium manager to Create or destroy a instance
Expand Down
7 changes: 1 addition & 6 deletions SeleniumManager.Core/Enum/WebDriverType.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace SeleniumManager.Core.Enum
{
Expand Down
5 changes: 0 additions & 5 deletions SeleniumManager.Core/Interface/ISeleniumManager.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using OpenQA.Selenium;
using SeleniumManager.Core.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SeleniumManager.Core.Interface
{
Expand Down
4 changes: 2 additions & 2 deletions SeleniumManager.Core/SeleniumManager.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
This include managing Queues, Parallel Tests, etc.</Description>
<Copyright>MIT License</Copyright>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyVersion>0.0.0.5</AssemblyVersion>
<Version>0.0.0.5-alpha</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<Version>1.1.0.0</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
Loading

0 comments on commit ce6185c

Please sign in to comment.