Skip to content

Commit

Permalink
Merge pull request #82 from ERNI-Academy/feature/selenoid
Browse files Browse the repository at this point in the history
Add Selenoid engine
  • Loading branch information
mg-diego committed May 23, 2024
2 parents 6b4dfb6 + d37eb54 commit 1ee6cf1
Show file tree
Hide file tree
Showing 90 changed files with 1,345 additions and 231 deletions.
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ Testware provides capabilities to automate:
<img src="https://github.com/devicons/devicon/blob/master/icons/chrome/chrome-original-wordmark.svg" title="Chrome" alt="Chrome" width="40" height="40"/>
<img src="https://github.com/devicons/devicon/blob/master/icons/firefox/firefox-original-wordmark.svg" title="Firefox" alt="Firefox" width="40" height="40"/>
<img src="https://github.com/devicons/devicon/blob/master/icons/ie10/ie10-original.svg" title="IE" alt="IE" width="40" height="40"/>
<img src="https://upload.wikimedia.org/wikipedia/commons/9/98/Microsoft_Edge_logo_%282019%29.svg" title="Edge" alt="Edge" width="40" height="40"/>

<img src="https://upload.wikimedia.org/wikipedia/commons/3/32/Microsoft_Edge_Dev_Icon_%282019%29.svg" title="Edge" alt="Edge" width="40" height="40"/>
- **Websites** (using Selenoid)
- Supported Browsers:
<img src="https://github.com/devicons/devicon/blob/master/icons/chrome/chrome-original-wordmark.svg" title="Chrome" alt="Chrome" width="40" height="40"/>
<img src="https://github.com/devicons/devicon/blob/master/icons/firefox/firefox-original-wordmark.svg" title="Firefox" alt="Firefox" width="40" height="40"/>
<img src="https://upload.wikimedia.org/wikipedia/commons/3/32/Microsoft_Edge_Dev_Icon_%282019%29.svg" title="Edge" alt="Edge" width="40" height="40"/>
- **Mobile Applications** (using Appium)
- **Windows Desktop applications** (using WinAppDriver)
- **API Rest** (using Restsharp)
Expand Down Expand Up @@ -155,6 +159,53 @@ Evidence collection:
}
]
},
{
"Tag": "RemoteDriver",
"Capabilities": [
{
"Name": "Chrome",
"Uri": "http://localhost:4444/wd/hub",
"BrowserName": "Chrome",
"BrowserVersion": "111.0",
"Resolution": "1920x1080x24",
"EnableLog": false,
"EnableVnc": true,
"EnableVideo": false,
"CommandTimeOutInMinutes": 5,
"Arguments": [
"--start-maximized"
]
},
{
"Name": "Firefox",
"Uri": "http://localhost:4444/wd/hub",
"BrowserName": "Firefox",
"BrowserVersion": "110.0",
"Resolution": "1920x1080x24",
"EnableLog": false,
"EnableVnc": true,
"EnableVideo": false,
"CommandTimeOutInMinutes": 5,
"Arguments": [
"--start-maximized"
]
},
{
"Name": "Edge",
"Uri": "http://localhost:4444/wd/hub",
"BrowserName": "Edge",
"BrowserVersion": "111.0",
"Resolution": "1920x1080x24",
"EnableLog": false,
"EnableVnc": true,
"EnableVideo": false,
"CommandTimeOutInMinutes": 5,
"Arguments": [
"--start-maximized"
]
}
]
},
{
"Name": "Appiumdriver",
"AppiumUrl": "http://127.0.0.1:4723/wd/hub",
Expand Down
25 changes: 23 additions & 2 deletions TestWare.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.ExtentReport", "sr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reporting", "Reporting", "{DCCEF363-0EBE-46EA-B02B-CD59010626F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.Engines.Selenoid", "src\Engines\TestWare.Engines.Selenoid\TestWare.Engines.Selenoid.csproj", "{0B7E3DFE-AB55-4C0C-81C6-6A6F517475EE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.Samples.Selenoid.Web", "samples\TestWare.Samples.Selenoid.Web\TestWare.Samples.Selenoid.Web.csproj", "{672C5D48-DD50-4AA3-8974-50B95746EA07}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.Engines.MongoDB", "src\Engines\TestWare.Engines.MongoDB\TestWare.Engines.MongoDB.csproj", "{4DFC2BE5-D3EF-4F39-AAD4-B8213DE92A11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWare.Samples.MongoDB", "samples\TestWare.Samples.MongoDB\TestWare.Samples.MongoDB.csproj", "{5378DE68-675E-440D-AAA9-7D3AF8AA680E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.Samples.MongoDB", "samples\TestWare.Samples.MongoDB\TestWare.Samples.MongoDB.csproj", "{5378DE68-675E-440D-AAA9-7D3AF8AA680E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.AllureReport", "src\Core\TestWare.AllureReport\TestWare.AllureReport.csproj", "{91F2B723-A68B-4711-969B-89897B3C6161}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWare.AllureReport", "src\Core\TestWare.AllureReport\TestWare.AllureReport.csproj", "{91F2B723-A68B-4711-969B-89897B3C6161}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWare.Engines.Common", "src\Engines\TestWare.Engines.Common\TestWare.Engines.Common\TestWare.Engines.Common.csproj", "{FFD6A200-D2F1-4CBE-8FDC-320C7839AAB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -90,6 +96,14 @@ Global
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A}.Release|Any CPU.Build.0 = Release|Any CPU
{0B7E3DFE-AB55-4C0C-81C6-6A6F517475EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B7E3DFE-AB55-4C0C-81C6-6A6F517475EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B7E3DFE-AB55-4C0C-81C6-6A6F517475EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B7E3DFE-AB55-4C0C-81C6-6A6F517475EE}.Release|Any CPU.Build.0 = Release|Any CPU
{672C5D48-DD50-4AA3-8974-50B95746EA07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{672C5D48-DD50-4AA3-8974-50B95746EA07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{672C5D48-DD50-4AA3-8974-50B95746EA07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{672C5D48-DD50-4AA3-8974-50B95746EA07}.Release|Any CPU.Build.0 = Release|Any CPU
{4DFC2BE5-D3EF-4F39-AAD4-B8213DE92A11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DFC2BE5-D3EF-4F39-AAD4-B8213DE92A11}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DFC2BE5-D3EF-4F39-AAD4-B8213DE92A11}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -102,6 +116,10 @@ Global
{91F2B723-A68B-4711-969B-89897B3C6161}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91F2B723-A68B-4711-969B-89897B3C6161}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91F2B723-A68B-4711-969B-89897B3C6161}.Release|Any CPU.Build.0 = Release|Any CPU
{FFD6A200-D2F1-4CBE-8FDC-320C7839AAB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFD6A200-D2F1-4CBE-8FDC-320C7839AAB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFD6A200-D2F1-4CBE-8FDC-320C7839AAB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFD6A200-D2F1-4CBE-8FDC-320C7839AAB9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -120,9 +138,12 @@ Global
{71120454-DD7A-484C-93F2-699B4C363297} = {58B1446D-98A3-46A2-A668-305F0170B39F}
{94025C6B-DF0D-4AC4-BBC5-A94A9FA3AB0A} = {DCCEF363-0EBE-46EA-B02B-CD59010626F6}
{DCCEF363-0EBE-46EA-B02B-CD59010626F6} = {4678C707-68DB-4E06-9184-A07FB398832C}
{0B7E3DFE-AB55-4C0C-81C6-6A6F517475EE} = {A2E4E1F7-CB61-48DC-AA38-A74F7DC74CA2}
{672C5D48-DD50-4AA3-8974-50B95746EA07} = {58B1446D-98A3-46A2-A668-305F0170B39F}
{4DFC2BE5-D3EF-4F39-AAD4-B8213DE92A11} = {A2E4E1F7-CB61-48DC-AA38-A74F7DC74CA2}
{5378DE68-675E-440D-AAA9-7D3AF8AA680E} = {58B1446D-98A3-46A2-A668-305F0170B39F}
{91F2B723-A68B-4711-969B-89897B3C6161} = {DCCEF363-0EBE-46EA-B02B-CD59010626F6}
{FFD6A200-D2F1-4CBE-8FDC-320C7839AAB9} = {A2E4E1F7-CB61-48DC-AA38-A74F7DC74CA2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4F88CB24-23C8-4E0E-8B83-29023C1642B8}
Expand Down
6 changes: 3 additions & 3 deletions samples/TestWare.Samples.API/TestWare.Samples.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ExtentReports" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="RestSharp" Version="107.1.1" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.40" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="FluentAssertions" Version="6.3.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenQA.Selenium;
using TestWare.Engines.Appium.Pages;
using TestWare.Engines.Appium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Appium.Factory;
using TestWare.Core.Libraries;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OpenQA.Selenium;
using TestWare.Engines.Appium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Appium.Factory;
using TestWare.Engines.Appium.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenQA.Selenium;
using TestWare.Engines.Appium.Pages;
using TestWare.Engines.Appium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Appium.Factory;

namespace TestWare.Samples.Appium.Mobile.POM.Menu;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using TestWare.Core.Libraries;
using TestWare.Engines.Appium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Appium.Factory;
using TestWare.Engines.Appium.Pages;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="5.0.0-beta01" />
<PackageReference Include="ExtentReports" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.40" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="FluentAssertions" Version="6.3.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenQA.Selenium;
using TestWare.Core.Libraries;
using TestWare.Engines.Selenium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Selenium.Factory;
using TestWare.Engines.Selenium.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OpenQA.Selenium;
using TestWare.Engines.Selenium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Selenium.Factory;
using TestWare.Engines.Selenium.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OpenQA.Selenium;
using TestWare.Engines.Selenium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Selenium.Factory;
using TestWare.Engines.Selenium.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using OpenQA.Selenium;
using TestWare.Core.Libraries;
using TestWare.Engines.Selenium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Selenium.Factory;
using TestWare.Engines.Selenium.Pages;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using OpenQA.Selenium;
using TestWare.Engines.Selenium.Extras;
using TestWare.Engines.Common.Extras;
using TestWare.Engines.Selenium.Factory;
using TestWare.Engines.Selenium.Pages;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<SpecFlowObsoleteCodeBehindFiles Remove="Support\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExtentReports" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.40" />
<PackageReference Include="FluentAssertions" Version="6.3.0" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@RemoteDriver
Feature: Login

Scenario Outline: Login
Given the user enters username '<username>'
And the user enters password '<password>'
When the user clicks submit
Then the user can login

@Chrome
Examples:
| Example Description | username | password |
| standard | standard_user | secret_sauce |
| problem | problem_user | secret_sauce |

@Firefox
Examples:
| Example Description | username | password |
| standard | standard_user | secret_sauce |
| problem | problem_user | secret_sauce |

@Edge
Examples:
| Example Description | username | password |
| standard | standard_user | secret_sauce |
| problem | problem_user | secret_sauce |

@Chrome
Scenario: Logout
Given user 'standard_user' is logged with 'secret_sauce' into SwagLabs
When the user clicks Logout button
Then the user is at Login page
110 changes: 110 additions & 0 deletions samples/TestWare.Samples.Selenoid.Web/Hook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using TestWare.Reporting.ExtentReport;

namespace TestWare.Samples.Selenoid.Web;

[Binding]
public sealed class Hook
{
private readonly TestContext _testContext;
private int _stepCounter;
private static readonly LifeCycle _lifeCycle = new();
private static ExtentReport _testReport;

public Hook(TestContext testContext)
{
_testContext = testContext;
}

[BeforeFeature]
public static void BeforeFeature(FeatureContext featureContext)
{
var name = featureContext.FeatureInfo.Title;
var tags = featureContext.FeatureInfo.Tags;

_lifeCycle.BeginTestSuite(name);
_testReport.CreateFeature(name, tags);
}

[AfterFeature]
public static void AfterFeature(FeatureContext featureContext)
{
_lifeCycle.EndTestSuite();
}

[BeforeScenario]
public void BeforeScenario(FeatureContext featureContext, ScenarioContext scenarioContext)
{
var name = scenarioContext.ScenarioInfo.Arguments.Count > 0
? $"{DateTime.UtcNow.ToString("yyy-MM-dd HH-mm-ss", CultureInfo.InvariantCulture)} - {scenarioContext.ScenarioInfo.Title}"
: scenarioContext.ScenarioInfo.Title;

var description = scenarioContext.ScenarioInfo.Description ?? "";
var scenarioTags = scenarioContext.ScenarioInfo.Tags;
_testReport.CreateTestCase(name, description, scenarioTags);

_testContext.WriteLine("----------------------------------------- \r\n");
_testContext.WriteLine($"Feature: {featureContext.FeatureInfo.Title}");
_testContext.WriteLine($" Scenario: {scenarioContext.ScenarioInfo.Title} \r\n");

_stepCounter = 1;
var tags = GetTags(featureContext, scenarioContext);
_lifeCycle.BeginTestCase(name, tags);
}

[AfterScenario]
public void AfterScenario()
{
_testReport.SetTestcaseOutcome(_testContext.CurrentTestOutcome);
_lifeCycle.EndTestCase();
}

[BeforeTestRun]
public static void BeforeTestRun()
{
_lifeCycle.BeginTestExecution();
_testReport = new ExtentReport(_lifeCycle.GetCurrentResultsDirectory());
}

[AfterTestRun]
public static void AfterTestRun()
{
_lifeCycle.EndTestExecution();
_testReport.CreateTestReportFile();
}

[BeforeStep]
public void BeforeStep(ScenarioContext scenarioContext)
{
var name = scenarioContext.CurrentScenarioBlock.ToString();
var description = scenarioContext.StepContext.StepInfo.Text;
_testReport.CreateStep(name, description);

var stepId = $"{_stepCounter:00} {description}";
_stepCounter++;
_lifeCycle.BeginTestStep(stepId);
}

[AfterStep]
public void AfterStep(ScenarioContext scenarioContext)
{
_lifeCycle.EndTestStep();
var evidencesPath = _lifeCycle.GetStepEvidences();

foreach (var evidence in evidencesPath)
{
_testReport.AddScreenshotToStep(evidence);
_testContext.AddResultFile(evidence);
}
}

private static List<string> GetTags(FeatureContext featureContext, ScenarioContext scenarioContext)
{
var tags = featureContext.FeatureInfo.Tags.ToList();
tags.AddRange(scenarioContext.ScenarioInfo.Tags.ToList());
return tags;
}
}
Loading

0 comments on commit 1ee6cf1

Please sign in to comment.