Skip to content

Commit

Permalink
refactor employee profile object
Browse files Browse the repository at this point in the history
  • Loading branch information
DeLaphante committed Nov 15, 2023
1 parent 97cd221 commit ffb2106
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
15 changes: 2 additions & 13 deletions CynkyAutomation/Models/UI/EmployeeProfile.cs
Original file line number Diff line number Diff line change
@@ -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<string> OrderIds { get; set; } = new List<string>() { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
public string Firstname { get; set; } = $"{StringGenerator.GetRandomString()}";
public string Lastname { get; set; } = $"{StringGenerator.GetRandomString()}";
}
}
9 changes: 5 additions & 4 deletions CynkyAutomation/PageObjects/OrangeHRM/PIMPage.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down
11 changes: 5 additions & 6 deletions CynkyAutomation/StepDefinitions/UI/OrangeHRM_UISteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ public void ThenTheEmployeeShouldNotBeDisplayed()
[StepDefinition(@"user adds a new employee")]
public void WhenUserAddsANewEmployee()
{
var employee = new { EmployeeProfile.Firstname, EmployeeProfile.Lastname };
_ScenarioContext.Set<string>(employee.Firstname, "firstname");
_ScenarioContext.Set<string>(employee.Lastname, "lastname");
_PIMPage.AddEmployee(employee.Firstname, employee.Lastname);
var employee = new EmployeeProfile();
_ScenarioContext.Set<EmployeeProfile>(employee, "employee");
_PIMPage.AddEmployee(employee);
_SideNavBar.ClickOnOption("PIM");
}

[StepDefinition(@"the employee can be seen on the list")]
public void ThenTheEmployeeCanBeSeenOnTheList()
{
var listOfEmployees = _PIMPage.GetAllEmployees();
listOfEmployees.Contains(_ScenarioContext.Get<string>("firstname"));
listOfEmployees.Contains(_ScenarioContext.Get<string>("lastname"));
listOfEmployees.Contains(_ScenarioContext.Get<EmployeeProfile>("employee").Firstname);
listOfEmployees.Contains(_ScenarioContext.Get<EmployeeProfile>("employee").Lastname);
}

[StepDefinition(@"user updates info")]
Expand Down

0 comments on commit ffb2106

Please sign in to comment.