From f0a48e25f4ce7ccfa567d8459de2d853dd190b08 Mon Sep 17 00:00:00 2001 From: programmingPug <36635276+programmingPug@users.noreply.github.com> Date: Sat, 15 Aug 2020 22:08:58 -0400 Subject: [PATCH] Example code --- pom.sln | 17 ++++ pom/.DS_Store | Bin 0 -> 6148 bytes pom/Components/LandingComponent.cs | 20 +++++ pom/Components/LoginComponent.cs | 36 ++++++++ pom/Components/NavigationComponent.cs | 32 +++++++ pom/Components/VideoComponent.cs | 37 ++++++++ pom/Components/VideosComponent.cs | 29 ++++++ pom/Features/.DS_Store | Bin 0 -> 6148 bytes pom/Features/Login/Login.cs | 59 +++++++++++++ pom/Features/Login/Login.feature | 10 +++ pom/Features/Login/Login.feature.cs | 121 ++++++++++++++++++++++++++ pom/Features/Videos/.DS_Store | Bin 0 -> 6148 bytes pom/Features/Videos/Videos.cs | 68 +++++++++++++++ pom/Features/Videos/Videos.feature | 10 +++ pom/Features/Videos/Videos.feature.cs | 121 ++++++++++++++++++++++++++ pom/pom.csproj | 51 +++++++++++ 16 files changed, 611 insertions(+) create mode 100644 pom.sln create mode 100644 pom/.DS_Store create mode 100644 pom/Components/LandingComponent.cs create mode 100644 pom/Components/LoginComponent.cs create mode 100644 pom/Components/NavigationComponent.cs create mode 100644 pom/Components/VideoComponent.cs create mode 100644 pom/Components/VideosComponent.cs create mode 100644 pom/Features/.DS_Store create mode 100644 pom/Features/Login/Login.cs create mode 100644 pom/Features/Login/Login.feature create mode 100644 pom/Features/Login/Login.feature.cs create mode 100644 pom/Features/Videos/.DS_Store create mode 100644 pom/Features/Videos/Videos.cs create mode 100644 pom/Features/Videos/Videos.feature create mode 100644 pom/Features/Videos/Videos.feature.cs create mode 100644 pom/pom.csproj diff --git a/pom.sln b/pom.sln new file mode 100644 index 0000000..31cafef --- /dev/null +++ b/pom.sln @@ -0,0 +1,17 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pom", "pom\pom.csproj", "{EC01B297-C25B-446E-96A4-E2153A5305CC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EC01B297-C25B-446E-96A4-E2153A5305CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC01B297-C25B-446E-96A4-E2153A5305CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC01B297-C25B-446E-96A4-E2153A5305CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC01B297-C25B-446E-96A4-E2153A5305CC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/pom/.DS_Store b/pom/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..06b90bd8fb6692eccd6c029fb03da906f1861192 GIT binary patch literal 6148 zcmeHK%Sr=55bREJ2ztrU;~YH+{=pKX;5k2F5=D^BPDo77d+}rZO0Al11FH+-MMS!x zr+TIzvs1A15D}g3?=M9rA~J>&l}3+nxYsrC;1N(ujVz5kK%ZsTQ|K=a@!L=2O0ukF zgZB9Sw{>1E>%4@YwX7RgSHprHlIGLw)9t$BUNPQ9qS% z(aJE|U?3RiGBC96gy;V?ewp4!em5n0!9XzZ&lu3rY(AS}QGT|5Ssu^Y1igb&7}wH( m!0ucE(BVFER-EQfv=LW1wuY?2@sbXVi$EbHnqc4;7 drv.FindElement(By.ClassName("video-loop-video-title"))); + + var videos = webDriver.FindElements(By.ClassName("video-loop-video-title")); + var video = videos[0]; + video.Click(); + } + } +} \ No newline at end of file diff --git a/pom/Features/.DS_Store b/pom/Features/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6ed9a50da1d31aeaf74a1e8521a814da0bd29e27 GIT binary patch literal 6148 zcmeHKu}TC%3{CWu1Dh)?r?j=U8IHR`usg7p^W+egT~M^%-?^{U_mU{Px~(FTK;~s; zlI+ZbotcP;E?;(+A`20jLy1abLO47*brjAspjwXhy6Nt>O}Cv$^EZdM_7l00PWJLB z!}XJrE9k|Wi7kKN`MP;(o37ns9DA2jxkda=9+2sIzyh-zpu;R9-!FOKnvx781Ia)# zkPQ4N1H88&^E1b6lYwL)8Te#?=R<)KYhdqaM+X`!0f2l)o51FimoX)<2KJ7afvAT9 zJyfH_P!Gp=3BMZHJ9@Zi6dxL2{wQA5zK;CG+(oNnw#h&;FlOM`y9?g`Yy2{kMgBM> zd&xjD@Xr{~*=n;|VpDOqe%l`J+5)|UQs~#yfWRI-0?^?(a&D78UueUx2KJ83!f^`+ P=0m^;$tD^21qR*$3T-hE literal 0 HcmV?d00001 diff --git a/pom/Features/Login/Login.cs b/pom/Features/Login/Login.cs new file mode 100644 index 0000000..7f2c79f --- /dev/null +++ b/pom/Features/Login/Login.cs @@ -0,0 +1,59 @@ +using FluentAssertions; +using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; +using pom.Components; +using TechTalk.SpecFlow; + +namespace pom.Features.Login +{ + [Binding] + public class Login + { + private IWebDriver webDriver; + private LoginComponent loginComponent; + private NavigationComponent navigationComponent; + + [BeforeScenario] + public void SetupTest() + { + webDriver = GetWebDriver(); + + loginComponent = new LoginComponent(webDriver); + navigationComponent = new NavigationComponent(webDriver); + } + + public IWebDriver GetWebDriver() + { + /* Yes we could put this into a factory and use DI but KISS for now. */ + ChromeOptions options = new ChromeOptions(); + options.AddArguments("start-maximized"); + + IWebDriver ChromeWebDriver = new ChromeDriver(options); + return ChromeWebDriver; + } + + [Given(@"I am at the login page")] + public void GivenIAmAtTheLoginPage() + { + loginComponent.GoToLogin(); + } + + [Given(@"I have entered my credentials")] + public void AndIHaveEnteredMyCredentials() + { + loginComponent.EnterUserCredentials("Information", "Information"); + } + + [When(@"I press login")] + public void WhenIPressLogin() + { + loginComponent.SubmitLoginForm(); + } + + [Then(@"the I have logged into the application")] + public void ThenTheIHaveLoggedIntoTheApplication() + { + navigationComponent.GetNavAccountName().Should().Be("user"); + } + } +} \ No newline at end of file diff --git a/pom/Features/Login/Login.feature b/pom/Features/Login/Login.feature new file mode 100644 index 0000000..14cd228 --- /dev/null +++ b/pom/Features/Login/Login.feature @@ -0,0 +1,10 @@ +Feature: Login + In order to use the application + As a user + I want to log into the application + +Scenario: Log into the application + Given I am at the login page + And I have entered my credentials + When I press login + Then the I have logged into the application \ No newline at end of file diff --git a/pom/Features/Login/Login.feature.cs b/pom/Features/Login/Login.feature.cs new file mode 100644 index 0000000..c852109 --- /dev/null +++ b/pom/Features/Login/Login.feature.cs @@ -0,0 +1,121 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.3.0.0 +// SpecFlow Generator Version:3.1.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace pom.Features.Login +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.3.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Login")] + public partial class LoginFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private string[] _featureTags = ((string[])(null)); + +#line 1 "Login.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Login", "\tIn order to use the application\n\tAs a user\n\tI want to log into the application", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Log into the application")] + public virtual void LogIntoTheApplication() + { + string[] tagsOfScenario = ((string[])(null)); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Log into the application", null, tagsOfScenario, argumentsOfScenario); +#line 6 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + testRunner.Given("I am at the login page", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 8 + testRunner.And("I have entered my credentials", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 9 + testRunner.When("I press login", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 10 + testRunner.Then("the I have logged into the application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/pom/Features/Videos/.DS_Store b/pom/Features/Videos/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 +// This code was generated by SpecFlow (https://www.specflow.org/). +// SpecFlow Version:3.3.0.0 +// SpecFlow Generator Version:3.1.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +#pragma warning disable +namespace pom.Features.Videos +{ + using TechTalk.SpecFlow; + using System; + using System.Linq; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.3.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Video Controls")] + public partial class VideoControlsFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + + private string[] _featureTags = ((string[])(null)); + +#line 1 "Videos.feature" +#line hidden + + [NUnit.Framework.OneTimeSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Video Controls", "\tIn order to control a video\n\tAs a user\n\tI want to manipulate video controls", ProgrammingLanguage.CSharp, ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.OneTimeTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + [NUnit.Framework.SetUpAttribute()] + public virtual void TestInitialize() + { + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void TestTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioInitialize(scenarioInfo); + testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs(NUnit.Framework.TestContext.CurrentContext); + } + + public virtual void ScenarioStart() + { + testRunner.OnScenarioStart(); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Pause video playback")] + public virtual void PauseVideoPlayback() + { + string[] tagsOfScenario = ((string[])(null)); + System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Pause video playback", null, tagsOfScenario, argumentsOfScenario); +#line 6 +this.ScenarioInitialize(scenarioInfo); +#line hidden + bool isScenarioIgnored = default(bool); + bool isFeatureIgnored = default(bool); + if ((tagsOfScenario != null)) + { + isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((this._featureTags != null)) + { + isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); + } + if ((isScenarioIgnored || isFeatureIgnored)) + { + testRunner.SkipScenario(); + } + else + { + this.ScenarioStart(); +#line 7 + testRunner.Given("I have logged into the application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line hidden +#line 8 + testRunner.And("I have started playing a video", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden +#line 9 + testRunner.When("I press pause", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line hidden +#line 10 + testRunner.Then("the video should be paused", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + } + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/pom/pom.csproj b/pom/pom.csproj new file mode 100644 index 0000000..667900b --- /dev/null +++ b/pom/pom.csproj @@ -0,0 +1,51 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + + + + + + + + + + + + Login.feature + + + Videos.feature + + + + + False + SpecFlowSingleFileGenerator + Login.feature.cs + + + False + SpecFlowSingleFileGenerator + Landing.feature.cs + + + False + SpecFlowSingleFileGenerator + Videos.feature.cs + + +