Skip to content

Commit

Permalink
Merge pull request #9 from RohitM-IN/dev
Browse files Browse the repository at this point in the history
Fixes for IE and typos
  • Loading branch information
RohitM-IN authored Aug 11, 2023
2 parents 5fef3c1 + 3aecb4b commit 18b13fe
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 23 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow will build, test, sign and package a WPF or Windows Forms desktop application
# built on .NET Core.
# To learn how to migrate your existing application to .NET Core,
# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
#
# To configure this workflow:
#
# 1. Configure environment variables
# GitHub sets default environment variables for every workflow run.
# Replace the variables relative to your project in the "env" section below.
#
# 2. Signing
# Generate a signing certificate in the Windows Application
# Packaging Project or add an existing signing certificate to the project.
# Next, use PowerShell to encode the .pfx file using Base64 encoding
# by running the following Powershell script to generate the output string:
#
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
#
# Open the output file, SigningCertificate_Encoded.txt, and copy the
# string inside. Then, add the string to the repo as a GitHub secret
# and name it "Base64_Encoded_Pfx."
# For more information on how to configure your signing certificate for
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
#
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
# See "Build the Windows Application Packaging project" below to see how the secret is used.
#
# For more information on GitHub Actions, refer to https://github.com/features/actions
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
# refer to https://github.com/microsoft/github-actions-for-desktop-apps

name: .NET Core Desktop

on:
push:
branches: [ "master","dev" ]
pull_request:
branches: [ "master" ]

jobs:

build:

strategy:
matrix:
configuration: [Release]

runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on

env:
Solution_Name: SeleniumManager.sln
#Test_Project_Path: SeleniumManager.Tests\SeleniumManager.Tests.csproj


steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/[email protected]

# Execute all unit tests in the solution
# - name: Execute unit tests
# run: dotnet test

# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}

# Create the app package by building and packaging the Windows Application Packaging project
- name: Create the app package
run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
env:
Appx_Bundle: Always
Appx_Bundle_Platforms: x86|x64
Appx_Package_Build_Mode: StoreUpload
Configuration: ${{ matrix.configuration }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Selenium Grid Manager

Selenium Grid Manager is a C# library for managing multiple Selenium WebDriver instances in parallel using Selenium Grid.
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.
> 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.
## Table of Contents

Expand All @@ -16,7 +16,7 @@ Selenium Grid Manager is a C# library for managing multiple Selenium WebDriver i

## Overview

Selenium Grid Manager is a library that 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.
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

Expand Down
4 changes: 2 additions & 2 deletions SeleniumManager.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ internal class Program
static Process p;
static void Main(string[] args)
{
string jarName = "selenium-server-4.9.1.jar"; // Name of your JAR file
string jarName = "selenium-server-4.11.0.jar"; // Name of your JAR file
string jarPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), jarName); // Path to your JAR file
string arguments = $@" -jar {jarPath} standalone ";// --config D:\dev\C#\SeleniumManager\SeleniumManager.ConsoleApp\myconfig.toml";//--driver-implementation \"Chrome\"";
string arguments = $@" -jar {jarPath} standalone ";// --selenium-manager true --log-level FINE --log ./trace.log";// --config D:\dev\C#\SeleniumManager\SeleniumManager.ConsoleApp\myconfig.toml";//--driver-implementation \"Chrome\"";
ProcessStartInfo psi = new ProcessStartInfo("java", arguments);
psi.CreateNoWindow = false; // Hide the console window
psi.UseShellExecute = false; // Do not use the operating system shell to start the process
Expand Down
4 changes: 2 additions & 2 deletions SeleniumManager.ConsoleApp/SeleniumManager.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<None Update="selenium-server-4.9.1.jar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<None Update="selenium-server-4.11.0.jar">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="start.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion SeleniumManager.Core/Configuration/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"statistics": {
"Chrome": 2,
"MicrosoftEdge": 1,
"Firefox": 0,
"Firefox": 1,
"Internet Explorer": 0
},
"drivers": [
Expand Down
14 changes: 7 additions & 7 deletions SeleniumManager.Core/Enum/WebDriverType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ namespace SeleniumManager.Core.Enum
public enum WebDriverType
{
None = 0,
[Description("Chrome")]
[Description("chrome")]
Chrome = 1,
[Description("Microsoft Edge")]
Microsoft_Edge = 2,
[Description("Firefox")]
[Description("MicrosoftEdge")]
MicrosoftEdge = 2,
[Description("firefox")]
Firefox = 3,
[Description("Safari")]
[Description("safari")]
Safari = 4,
[Description("InternetExplorer")]
[Description("internet explorer")]
InternetExplorer = 5,
[Description("Opera")]
[Description("opera")]
Opera = 6,
[Description("Custom")]
Custom = 7,
Expand Down
5 changes: 2 additions & 3 deletions SeleniumManager.Core/SeleniumManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,9 @@ public async void TryExecuteNext()
FieldInfo browserNameField = action.Target.GetType().GetField("browserName");
browserName = (string?)browserNameField?.GetValue(action.Target);
}
// TODO: make it like get the driver first and then process the action
IWebDriver _driver = CreateDriverInstance(browserName);
try
{
// for now only using chrome for testing
IWebDriver _driver = CreateDriverInstance(browserName);
ICapabilities capabilities = ((RemoteWebDriver)_driver).Capabilities;
browserName = capabilities.GetCapability("browserName").ToString();
action(_driver, browserName);
Expand All @@ -151,6 +149,7 @@ public async void TryExecuteNext()
{
// Release the semaphore even if an exception occurs
_semaphore.Release();
_driver?.Dispose();

// Recursively call TryExecuteNext to process the next action in the queue
TryExecuteNext();
Expand Down
41 changes: 36 additions & 5 deletions SeleniumManager.Tests/BrowsingTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using OpenQA.Selenium;
using SeleniumManager.Core;
using SeleniumManager.Core.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -24,7 +25,7 @@ public void init()
[TestMethod]
public async Task TestBrouse()
{
var data = await _seleniumManager.EnqueueAction(BrouseWebsite);
var data = await _seleniumManager.EnqueueAction(BrowseWebsite);

// Start processing the actions
_seleniumManager.TryExecuteNext();
Expand All @@ -34,12 +35,42 @@ public async Task TestBrouse()
[TestMethod]
public async Task TestBrouseChrome()
{
var data = await _seleniumManager.EnqueueAction(BrouseWebsite, "chrome");
// or pass 'chrome' case sensitive
var data = await _seleniumManager.EnqueueAction(BrowseWebsite, WebDriverType.Chrome.GetDescription());

// Start processing the actions
_seleniumManager.TryExecuteNext();

}
[TestMethod]
public async Task TestBrouseFirefox()
{
// or pass 'firefox' case sensitive
var data = await _seleniumManager.EnqueueAction(BrowseWebsite, WebDriverType.Firefox.GetDescription());

// Start processing the actions
_seleniumManager.TryExecuteNext();

}
[TestMethod]
public async Task TestBrouseIE()
{
// or pass 'firefox' case sensitive
var data = await _seleniumManager.EnqueueAction(BrowseGoogleWebsite, WebDriverType.InternetExplorer.GetDescription());

// Start processing the actions
_seleniumManager.TryExecuteNext();

}
[TestMethod]
public async Task TestBrouseEdge()
{
// or pass 'MicorsoftEdge' case sensitive
var data = await _seleniumManager.EnqueueAction(BrowseWebsite, WebDriverType.MicrosoftEdge.GetDescription());

// Start processing the actions
_seleniumManager.TryExecuteNext();
}

[TestMethod]
public async Task ParallelTestBrouse()
Expand All @@ -51,7 +82,7 @@ public async Task ParallelTestBrouse()
Task task = Task.Run(async () =>
{
// Enqueue the action and wait for its completion
await _seleniumManager.EnqueueAction(BrouseGoogleWebsite);
await _seleniumManager.EnqueueAction(BrowseGoogleWebsite);
Thread.Sleep(3000);
});

Expand Down Expand Up @@ -80,7 +111,7 @@ public async Task TestBrouseFail()
}

}
private string BrouseGoogleWebsite(IWebDriver driver)
private string BrowseGoogleWebsite(IWebDriver driver)
{
//
try
Expand All @@ -97,7 +128,7 @@ private string BrouseGoogleWebsite(IWebDriver driver)
return string.Empty;
}

private string BrouseWebsite(IWebDriver driver)
private string BrowseWebsite(IWebDriver driver)
{
//
try
Expand Down

0 comments on commit 18b13fe

Please sign in to comment.