diff --git a/CynkyAutomation/Models/UI/EmployeeProfile.cs b/CynkyAutomation/Models/UI/EmployeeProfile.cs index 4d47968..1cb0bb5 100644 --- a/CynkyAutomation/Models/UI/EmployeeProfile.cs +++ b/CynkyAutomation/Models/UI/EmployeeProfile.cs @@ -1,21 +1,10 @@ using CynkyUtilities; -using System.Collections.Generic; namespace CynkyAutomation.Models.UI { public class EmployeeProfile { - public static string Firstname { get; set; } = $"{StringGenerator.GetRandomString()}"; - public static string Lastname { get; set; } = $"{StringGenerator.GetRandomString()}"; - public string FullName { get; set; } = $"{Firstname} {Lastname}"; - public string Email { get; set; } = StringGenerator.GetRandomEmail("mailinator.com"); - public string MobilePhone { get; set; } = StringGenerator.GetRandomUkMobileNumber(); - public string Address1 { get; set; } = StringGenerator.GetRandomString(); - public string Postcode { get; set; } = "W9 3DE"; - public string CardType { get; set; } = "Visa"; - public string CardNumber { get; set; } = "4242424242424242"; - public string CardExpiryDate { get; set; } = $"01{DateTimeGenerator.GetTodaysDateTime().AddYears(1).ToString("yy")}"; - public string CardCvv { get; set; } = "123"; - public List OrderIds { get; set; } = new List() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public string Firstname { get; set; } = $"{StringGenerator.GetRandomString()}"; + public string Lastname { get; set; } = $"{StringGenerator.GetRandomString()}"; } } diff --git a/CynkyAutomation/PageObjects/OrangeHRM/PIMPage.cs b/CynkyAutomation/PageObjects/OrangeHRM/PIMPage.cs index 5f1a7bd..4c47340 100644 --- a/CynkyAutomation/PageObjects/OrangeHRM/PIMPage.cs +++ b/CynkyAutomation/PageObjects/OrangeHRM/PIMPage.cs @@ -1,4 +1,5 @@ -using CynkyAutomation.PageObjects.CommonPages; +using CynkyAutomation.Models.UI; +using CynkyAutomation.PageObjects.CommonPages; using CynkyWrapper; using OpenQA.Selenium; using System.Collections.Generic; @@ -44,11 +45,11 @@ public string GetFirstNameOfEmployeeWithoutEmploymentStatus(string status) return Row_label(status, i).GetText(); } - public void AddEmployee(string firstName, string lastName) + public void AddEmployee(EmployeeProfile employeeProfile) { ClickButton("Add"); - FormInput_textbox("firstName").SendKeys(firstName); - FormInput_textbox("lastName").SendKeys(lastName); + FormInput_textbox("firstName").SendKeys(employeeProfile.Firstname); + FormInput_textbox("lastName").SendKeys(employeeProfile.Lastname); ClickButton("Save"); } diff --git a/CynkyAutomation/StepDefinitions/UI/OrangeHRM_UISteps.cs b/CynkyAutomation/StepDefinitions/UI/OrangeHRM_UISteps.cs index e6ea975..1bb49cf 100644 --- a/CynkyAutomation/StepDefinitions/UI/OrangeHRM_UISteps.cs +++ b/CynkyAutomation/StepDefinitions/UI/OrangeHRM_UISteps.cs @@ -65,10 +65,9 @@ public void ThenTheEmployeeShouldNotBeDisplayed() [StepDefinition(@"user adds a new employee")] public void WhenUserAddsANewEmployee() { - var employee = new { EmployeeProfile.Firstname, EmployeeProfile.Lastname }; - _ScenarioContext.Set(employee.Firstname, "firstname"); - _ScenarioContext.Set(employee.Lastname, "lastname"); - _PIMPage.AddEmployee(employee.Firstname, employee.Lastname); + var employee = new EmployeeProfile(); + _ScenarioContext.Set(employee, "employee"); + _PIMPage.AddEmployee(employee); _SideNavBar.ClickOnOption("PIM"); } @@ -76,8 +75,8 @@ public void WhenUserAddsANewEmployee() public void ThenTheEmployeeCanBeSeenOnTheList() { var listOfEmployees = _PIMPage.GetAllEmployees(); - listOfEmployees.Contains(_ScenarioContext.Get("firstname")); - listOfEmployees.Contains(_ScenarioContext.Get("lastname")); + listOfEmployees.Contains(_ScenarioContext.Get("employee").Firstname); + listOfEmployees.Contains(_ScenarioContext.Get("employee").Lastname); } [StepDefinition(@"user updates info")]