diff --git a/AgeRanger_Automation/AgeRangerWebUi/AgeRangerWebUi.csproj b/AgeRanger_Automation/AgeRangerWebUi/AgeRangerWebUi.csproj new file mode 100644 index 0000000..f886e93 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/AgeRangerWebUi.csproj @@ -0,0 +1,104 @@ + + + + + Debug + AnyCPU + {E82ADCC4-BD7A-4659-8B5F-7A79B0C4B25C} + Library + AgeRangerWebUi + AgeRangerWebUi + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + + + + + + + + + + + ..\packages\SpecFlow.2.2.1\lib\net45\TechTalk.SpecFlow.dll + + + ..\packages\Selenium.WebDriver.3.7.0\lib\net45\WebDriver.dll + + + ..\packages\Selenium.Support.3.7.0\lib\net45\WebDriver.Support.dll + + + + + + AddNewPerson.feature + True + True + + + DeletePerson.feature + True + True + + + EditPerson.feature + True + True + + + + + + + + + SpecFlowSingleFileGenerator + AddNewPerson.feature.cs + + + SpecFlowSingleFileGenerator + DeletePerson.feature.cs + + + SpecFlowSingleFileGenerator + EditPerson.feature.cs + + + + + + + + \ No newline at end of file diff --git a/AgeRanger_Automation/AgeRangerWebUi/App.config b/AgeRanger_Automation/AgeRangerWebUi/App.config new file mode 100644 index 0000000..fde1b9b --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/App.config @@ -0,0 +1,11 @@ + + + +
+ + + + + + + \ No newline at end of file diff --git a/AgeRanger_Automation/AgeRangerWebUi/Driver/Driver.cs b/AgeRanger_Automation/AgeRangerWebUi/Driver/Driver.cs new file mode 100644 index 0000000..4340ec9 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Driver/Driver.cs @@ -0,0 +1,23 @@ +using OpenQA.Selenium; +using OpenQA.Selenium.Remote; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgeRangerWebUi.Driver +{ + public class Driver + { + public IWebDriver GetRemoteDriver() + { + var capabilities = new DesiredCapabilities(); + capabilities.SetCapability("browserName", "Chrome"); + capabilities.SetCapability("platform", "Windows 10"); + capabilities.SetCapability("version", "62.0"); + return new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities, + TimeSpan.FromSeconds(60)); + } + } +} diff --git a/AgeRanger_Automation/AgeRangerWebUi/Features/AddNewPerson.feature b/AgeRanger_Automation/AgeRangerWebUi/Features/AddNewPerson.feature new file mode 100644 index 0000000..685d1b1 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Features/AddNewPerson.feature @@ -0,0 +1,25 @@ +Feature: Add New Person + This feature will cover the different tests for Adding a New Person to the system + +@basicFlow +Scenario Outline: AddNewPersonComplete + Given I navigate to http://ageranger.azurewebsites.net + When I click on the AddPerson button + And I add a new person with as a FirstName, as a LastName and as Age + Then I can see a new person the Landing page with ,, and + + Examples: + | FirstName | LastName | Age | AgeRange | + | MyName | MyLastName | 40 | Very adult | + +@exceptionFlow +Scenario Outline: AddNewPersonFail + Given I navigate to http://ageranger.azurewebsites.net + And I click on the AddPerson button + When I type in the First Name field + And I clear the First Name field + Then I can see an inline error with message + + Examples: + | something | FirstNameInlineError | + | something | First name is required." | \ No newline at end of file diff --git a/AgeRanger_Automation/AgeRangerWebUi/Features/AddNewPerson.feature.cs b/AgeRanger_Automation/AgeRangerWebUi/Features/AddNewPerson.feature.cs new file mode 100644 index 0000000..dd1fa29 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Features/AddNewPerson.feature.cs @@ -0,0 +1,125 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:2.2.0.0 +// SpecFlow Generator Version:2.2.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 AgeRangerWebUi.Features +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.2.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Add New Person")] + public partial class AddNewPersonFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "AddNewPerson.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"), "Add New Person", "\tThis feature will cover the different tests for Adding a New Person to the syste" + + "m", 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 ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("AddNewPersonComplete")] + [NUnit.Framework.CategoryAttribute("basicFlow")] + [NUnit.Framework.TestCaseAttribute("MyName", "MyLastName", "40", "Very adult", null)] + public virtual void AddNewPersonComplete(string firstName, string lastName, string age, string ageRange, string[] exampleTags) + { + string[] @__tags = new string[] { + "basicFlow"}; + if ((exampleTags != null)) + { + @__tags = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Concat(@__tags, exampleTags)); + } + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("AddNewPersonComplete", @__tags); +#line 5 +this.ScenarioSetup(scenarioInfo); +#line 6 + testRunner.Given("I navigate to http://ageranger.azurewebsites.net", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 7 + testRunner.When("I click on the AddPerson button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 8 + testRunner.And(string.Format("I add a new person with {0} as a FirstName, {1} as a LastName and {2} as Age", firstName, lastName, age), ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 9 + testRunner.Then(string.Format("I can see a new person the Landing page with {0},{1},{2} and {3}", firstName, lastName, age, ageRange), ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("AddNewPersonFail")] + [NUnit.Framework.CategoryAttribute("exceptionFlow")] + [NUnit.Framework.TestCaseAttribute("something", "First name is required.\"", null)] + public virtual void AddNewPersonFail(string something, string firstNameInlineError, string[] exampleTags) + { + string[] @__tags = new string[] { + "exceptionFlow"}; + if ((exampleTags != null)) + { + @__tags = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Concat(@__tags, exampleTags)); + } + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("AddNewPersonFail", @__tags); +#line 16 +this.ScenarioSetup(scenarioInfo); +#line 17 + testRunner.Given("I navigate to http://ageranger.azurewebsites.net", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 18 + testRunner.And("I click on the AddPerson button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 19 + testRunner.When(string.Format("I type {0} in the First Name field", something), ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 20 + testRunner.And("I clear the First Name field", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 21 + testRunner.Then(string.Format("I can see an inline error with message {0}", firstNameInlineError), ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/AgeRanger_Automation/AgeRangerWebUi/Features/DeletePerson.feature b/AgeRanger_Automation/AgeRangerWebUi/Features/DeletePerson.feature new file mode 100644 index 0000000..cb774f4 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Features/DeletePerson.feature @@ -0,0 +1,9 @@ +Feature: DeletePerson + This feature will cover the different tests for Deleting a Person to the system + +@basicFlow +Scenario: DeletePersonComplete + Given I navigate to http://ageranger.azurewebsites.net + When I delete the first Person in the list + And I click on Confirm + Then the count of people should decrease by one diff --git a/AgeRanger_Automation/AgeRangerWebUi/Features/DeletePerson.feature.cs b/AgeRanger_Automation/AgeRangerWebUi/Features/DeletePerson.feature.cs new file mode 100644 index 0000000..cf43335 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Features/DeletePerson.feature.cs @@ -0,0 +1,89 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:2.2.0.0 +// SpecFlow Generator Version:2.2.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 AgeRangerWebUi.Features +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.2.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("DeletePerson")] + public partial class DeletePersonFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "DeletePerson.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"), "DeletePerson", "\tThis feature will cover the different tests for Deleting a Person to the system", 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 ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("DeletePersonComplete")] + [NUnit.Framework.CategoryAttribute("basicFlow")] + public virtual void DeletePersonComplete() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("DeletePersonComplete", new string[] { + "basicFlow"}); +#line 5 +this.ScenarioSetup(scenarioInfo); +#line 6 + testRunner.Given("I navigate to http://ageranger.azurewebsites.net", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 7 + testRunner.When("I delete the first Person in the list", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 8 + testRunner.And("I click on Confirm", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 9 + testRunner.Then("the count of people should decrease by one", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/AgeRanger_Automation/AgeRangerWebUi/Features/EditPerson.feature b/AgeRanger_Automation/AgeRangerWebUi/Features/EditPerson.feature new file mode 100644 index 0000000..66d20b8 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Features/EditPerson.feature @@ -0,0 +1,10 @@ +Feature: EditPerson + This feature will cover the different tests for Editing a Person to the system + +@basicFlow +Scenario: EditPersonComplete + Given I navigate to http://ageranger.azurewebsites.net + And I edit the first Person in the list + When I change the Age for that Person to a higher value + And I click on Confirm + Then the age of the first person will have changed diff --git a/AgeRanger_Automation/AgeRangerWebUi/Features/EditPerson.feature.cs b/AgeRanger_Automation/AgeRangerWebUi/Features/EditPerson.feature.cs new file mode 100644 index 0000000..1fdbc92 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Features/EditPerson.feature.cs @@ -0,0 +1,91 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:2.2.0.0 +// SpecFlow Generator Version:2.2.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 AgeRangerWebUi.Features +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "2.2.0.0")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("EditPerson")] + public partial class EditPersonFeature + { + + private TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "EditPerson.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"), "EditPerson", "\tThis feature will cover the different tests for Editing a Person to the system", 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 ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + public virtual void ScenarioCleanup() + { + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("EditPersonComplete")] + [NUnit.Framework.CategoryAttribute("basicFlow")] + public virtual void EditPersonComplete() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("EditPersonComplete", new string[] { + "basicFlow"}); +#line 5 +this.ScenarioSetup(scenarioInfo); +#line 6 + testRunner.Given("I navigate to http://ageranger.azurewebsites.net", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 7 + testRunner.And("I edit the first Person in the list", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 8 + testRunner.When("I change the Age for that Person to a higher value", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 9 + testRunner.And("I click on Confirm", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 10 + testRunner.Then("the age of the first person will have changed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + } +} +#pragma warning restore +#endregion diff --git a/AgeRanger_Automation/AgeRangerWebUi/PageObjects/AgeRangerMainPage.cs b/AgeRanger_Automation/AgeRangerWebUi/PageObjects/AgeRangerMainPage.cs new file mode 100644 index 0000000..ba262a8 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/PageObjects/AgeRangerMainPage.cs @@ -0,0 +1,64 @@ +using OpenQA.Selenium; +using OpenQA.Selenium.Support.PageObjects; +using System.Collections.Generic; +using System.Threading; + +namespace AgeRangerWebUi.PageObjects +{ + public class AgeRangerMainPage + + { + public AgeRangerMainPage(IWebDriver driver) + { + PageFactory.InitElements(driver, this); + } + + [FindsBy(How = How.XPath, Using = "//input[@id='searchText']")] + public IWebElement SearchTextField { get; set; } + + [FindsBy(How = How.XPath, Using = "//table")] + public IWebElement PeopleTable { get; set; } + + [FindsBy(How = How.XPath, Using = "//td[@class='col-md-7 ng-binding']")] + public IList ExistingUserName { get; set; } + + [FindsBy(How = How.XPath, Using = "//td[@class='col-md-2 ng-binding']")] + public IList ExistingUserAge { get; set; } + + [FindsBy(How = How.XPath, Using = "//a[@ng-click='openEditForm(person)']")] + public IWebElement EditPerson { get; set; } + + [FindsBy(How = How.XPath, Using = "//a[@ng-click='delete(person)']")] + public IWebElement DeletePerson { get; set; } + + [FindsBy(How = How.XPath, Using = "//a[@ng-click='openNewPersonForm()']")] + public IWebElement AddPerson { get; set; } + + [FindsBy(How = How.XPath, Using = "//input[@name='FirstName']")] + public IWebElement FirstName { get; set; } + + [FindsBy(How = How.XPath, Using = "//p[@class='help-block']")] + public IWebElement FirstNameInlineError { get; set; } + + [FindsBy(How = How.XPath, Using = "//input[@name='LastName']")] + public IWebElement LastName { get; set; } + + [FindsBy(How = How.XPath, Using = "//input[@name='Age']")] + public IWebElement Age { get; set; } + + [FindsBy(How = How.XPath, Using = "//button[@ng-click='submit()']")] + public IWebElement SubmitButton { get; set; } + + [FindsBy(How = How.XPath, Using = "//button[@ng-click='close()']")] + public IWebElement CloseButton { get; set; } + + [FindsBy(How = How.XPath, Using = "//button[@data-bb-handler='confirm']")] + public IWebElement OkButton { get; set; } + + [FindsBy(How = How.XPath, Using = "//button[@data-bb-handler='cancel']")] + public IWebElement CancelButton { get; set; } + + [FindsBy(How = How.XPath, Using = "//button[@class='bootbox-close-button close']")] + public IWebElement CrossButton { get; set; } + } +} diff --git a/AgeRanger_Automation/AgeRangerWebUi/Properties/AssemblyInfo.cs b/AgeRanger_Automation/AgeRangerWebUi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0f24134 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AgeRangerWebUi")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AgeRangerWebUi")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e82adcc4-bd7a-4659-8b5f-7a79b0c4b25c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AgeRanger_Automation/AgeRangerWebUi/Steps/PersonSteps.cs b/AgeRanger_Automation/AgeRangerWebUi/Steps/PersonSteps.cs new file mode 100644 index 0000000..a4ea98f --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/Steps/PersonSteps.cs @@ -0,0 +1,169 @@ +using AgeRangerWebUi.Driver; +using AgeRangerWebUi.PageObjects; +using NUnit.Framework; +using OpenQA.Selenium; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using TechTalk.SpecFlow; +using TechTalk.SpecFlow.Assist; + +namespace AgeRangerWebUi.Steps +{ + [Binding] + public sealed class PersonSteps + { + + private AgeRangerMainPage mainPage; + public PersonSteps() + { + var driverFactory = new Driver.Driver(); + Driver = driverFactory.GetRemoteDriver(); + mainPage = new AgeRangerMainPage(Driver); + } + + public static IWebDriver Driver { get; set; } + + [AfterScenario] + public void AfterScenario() + { + Driver.Quit(); + Driver = null; + } + + [StepDefinition(@"I navigate to (.*)")] + public void GivenINavigateTo(string url) + { + Driver.Navigate().GoToUrl(url); + Thread.Sleep(2000); + } + + [StepDefinition(@"I click on the AddPerson button")] + public void WhenIClickOnTheAddPersonButton() + { + var pageObject = new AgeRangerMainPage(Driver); + pageObject.AddPerson.Click(); + Thread.Sleep(1000); + } + + [StepDefinition(@"I add a new person with (.*) as a FirstName, (.*) as a LastName and (.*) as Age")] + public void GivenIAddANewPersonWithAsAFirstNameAsALastNameAndAsAge(string firstName, string lastName, int age) + { + var pageObject = new AgeRangerMainPage(Driver); + pageObject.FirstName.SendKeys(firstName); + pageObject.LastName.SendKeys(lastName); + pageObject.Age.SendKeys(age.ToString()); + pageObject.SubmitButton.Click(); + Thread.Sleep(1000); + pageObject.OkButton.Click(); + Thread.Sleep(1000); + } + + [StepDefinition(@"I can see a new person the Landing page with (.*),(.*),(.*) and (.*)")] + public void ThenICanSeeANewPersonTheLandingPageWithMyNameMyLastNameAndVeryAdult(string firstName, string lastName, int age, string ageRange) + { + var pageObject = new AgeRangerMainPage(Driver); + string firstLastName = (firstName + ' ' + lastName); + string userFound = "false"; + IList tableRow = pageObject.PeopleTable.FindElements(By.TagName("tr")); + foreach (IWebElement row in tableRow) + { + if (row.Text.Contains(firstLastName) && row.Text.Contains(age.ToString()) && row.Text.Contains(ageRange)) + { + userFound = "true"; + break; + } + } + Assert.AreEqual("true", userFound, "User was not Found."); + } + + [StepDefinition(@"I type (.*) in the First Name field")] + public void WhenITypeInTheFirstNameField(string firstName) + { + var pageObject = new AgeRangerMainPage(Driver); + pageObject.FirstName.SendKeys(firstName); + } + + [StepDefinition(@"I clear the First Name field")] + public void WhenIClearTheFirstNameField() + { + var pageObject = new AgeRangerMainPage(Driver); + pageObject.FirstName.Clear(); + } + + [StepDefinition(@"I can see an inline error with message (.*).")] + public void ThenICanSeeAnInlineErrorWithMessageFirstNameIsRequired_(string FirstNameInlineError) + { + var pageObject = new AgeRangerMainPage(Driver); + string errorMessage = pageObject.FirstNameInlineError.Text; + Assert.AreEqual(FirstNameInlineError, errorMessage, "Inline Error is not displayed or not matching."); + } + + [StepDefinition(@"I delete the first Person in the list")] + public void WhenIDeleteTheFirstPersonInTheList() + { + var pageObject = new AgeRangerMainPage(Driver); + int countBeforeDelete = pageObject.ExistingUserName.Count; + ScenarioContext.Current.Add("countBeforeDelete", countBeforeDelete); + pageObject.DeletePerson.Click(); + Thread.Sleep(1000); + } + + [StepDefinition(@"I click on Confirm")] + public void WhenIClickOnConfirm() + { + var pageObject = new AgeRangerMainPage(Driver); + pageObject.OkButton.Click(); + Thread.Sleep(1000); + } + + [StepDefinition(@"the count of people should decrease by one")] + public void ThenTheCountOfPeopleShouldDecreaseByOne() + { + var pageObject = new AgeRangerMainPage(Driver); + int countAfterDelete = pageObject.ExistingUserName.Count; + int countBeforeDelete = ScenarioContext.Current.Get("countBeforeDelete"); + if (countAfterDelete != null) + { + Assert.AreEqual(countAfterDelete, (countBeforeDelete - 1)); + } + else + Console.WriteLine("No Results left to Delete."); + + } + + [StepDefinition(@"I edit the first Person in the list")] + public void GivenIEditTheFirstPersonInTheList() + { + var pageObject = new AgeRangerMainPage(Driver); + int ageBeforeEdit = Int32.Parse(pageObject.ExistingUserAge.First().Text); + ScenarioContext.Current.Add("ageBeforeEdit", ageBeforeEdit); + pageObject.EditPerson.Click(); + Thread.Sleep(1000); + } + + [StepDefinition(@"I change the Age for that Person to a higher value")] + public void WhenIChangeTheAgeForThatPersonTo() + { + var pageObject = new AgeRangerMainPage(Driver); + int newAge = ScenarioContext.Current.Get("ageBeforeEdit"); + newAge = ++newAge; + pageObject.Age.Clear(); + pageObject.Age.SendKeys(newAge.ToString()); + pageObject.SubmitButton.Click(); + Thread.Sleep(1000); + } + + [StepDefinition(@"the age of the first person will have changed")] + public void ThenTheAgeOfTheFirstPersonWillHaveChanged() + { + var pageObject = new AgeRangerMainPage(Driver); + int ageAfterEdit = Int32.Parse(pageObject.ExistingUserAge.First().Text); + int ageBeforeEdit = ScenarioContext.Current.Get("ageBeforeEdit"); + Assert.AreNotEqual(ageBeforeEdit, ageAfterEdit, "Age is still the same."); + } + + } +} \ No newline at end of file diff --git a/AgeRanger_Automation/AgeRangerWebUi/packages.config b/AgeRanger_Automation/AgeRangerWebUi/packages.config new file mode 100644 index 0000000..dbc9472 --- /dev/null +++ b/AgeRanger_Automation/AgeRangerWebUi/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/AgeRanger_Automation/AgeRanger_Automation.sln b/AgeRanger_Automation/AgeRanger_Automation.sln new file mode 100644 index 0000000..25fef16 --- /dev/null +++ b/AgeRanger_Automation/AgeRanger_Automation.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2009 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgeRangerWebUi", "AgeRangerWebUi\AgeRangerWebUi.csproj", "{E82ADCC4-BD7A-4659-8B5F-7A79B0C4B25C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E82ADCC4-BD7A-4659-8B5F-7A79B0C4B25C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E82ADCC4-BD7A-4659-8B5F-7A79B0C4B25C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E82ADCC4-BD7A-4659-8B5F-7A79B0C4B25C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E82ADCC4-BD7A-4659-8B5F-7A79B0C4B25C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B5261534-D330-41DE-894F-1FB189C09E64} + EndGlobalSection +EndGlobal diff --git a/AgeRanger_Automation/AgeRanger_TestPlan.xls b/AgeRanger_Automation/AgeRanger_TestPlan.xls new file mode 100644 index 0000000..8a5753f Binary files /dev/null and b/AgeRanger_Automation/AgeRanger_TestPlan.xls differ diff --git a/AgeRanger_Automation/README.md b/AgeRanger_Automation/README.md new file mode 100644 index 0000000..ff8a022 --- /dev/null +++ b/AgeRanger_Automation/README.md @@ -0,0 +1,14 @@ +Running this project. + +* Prerequisites: + * Node.js is installed + * Webdriver-manager is installed and configured (npm install webdriver-manager -g) + * dependency on JDK being installed + * Chrome version 62 is installed + +* How to: +1. Open solution in Visual Studio +2. Open a powershell command prompt windows + 1. Run the following command: webdriver-manager start +3. Build solution +4. Execute Tests from Test Explorer in VS