EnVisageOnline/Main/TestSystem/Prevu/Selenium/TeamBoardPage.cs

123 lines
5.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using System.Collections;
namespace Prevu
{
public class TeamBoardPage : BasePage
{
By btnPrimary = By.ClassName("btn-primary");
By chartProjectsByStatus = By.ClassName("fa-bar-chart-o");
By txtFirstName = By.Id("FirstName");
By txtLastName = By.Id("LastName");
By txtEmployeeID = By.Id("EmployeeID");
By txtEmailAddress = By.Id("EmailAddress");
By drdExpenditureCategory = By.Id("ExpenditureCategoryId");
By drdTeam = By.Id("TeamId");
By drdWorkWeek = By.Id("WorkWeekId");
By chbIsActiveEmployee = By.Id("IsActiveEmployee");
By chbChangeCapacity = By.Id("ChangeCapacity");
By chbPermanent = By.Id("PermanentResource");
By dtpStartDate = By.Id("StartDate");
By dtpEndDate = By.Id("EndDate");
By btnSave = By.Id("btnsave-peopleresource");
//By select = By.ClassName("select2-choice");
By lblWarning = By.ClassName("panel-body");
By btnDelete = By.Id("btnDelete");
By tblteamResources = By.ClassName("resourceTable");
WebDriver _driver;
public TeamBoardPage(WebDriver driver)
{
_driver = driver;
}
public bool OpenTeamBoard(string teamId)
{
_driver.OpenPage(string.Format("Team/Board?teamId={0}", teamId));
_driver.WaitElement(chartProjectsByStatus);
return _driver.GetElement(chartProjectsByStatus) != null;
}
public bool CreatePeopleResourceFromTeamBoardTeamResourcesWidget(string firstName, string lastName, string employeeID, string emailAddress,
string expenditureCategory, string team, string workWeek, bool employeeStatusIsActive, bool changePlannedCapacity, bool permanent,
DateTime startDate, DateTime endDate, out string id)
{
_driver.ClickElement(btnPrimary, "Add Resource");
_driver.SendKeys(txtFirstName, firstName);
_driver.SendKeys(txtLastName, lastName);
_driver.SendKeys(txtEmployeeID, employeeID);
_driver.SendKeys(txtEmailAddress, emailAddress);
_driver.SelectDropdownValue(drdExpenditureCategory, expenditureCategory);
_driver.SelectDropdownValue(drdTeam, team);
_driver.SelectDropdownValue(drdWorkWeek, workWeek);
if (!employeeStatusIsActive)
{
_driver.ClickElement(chbIsActiveEmployee);
}
if (!changePlannedCapacity)
{
_driver.ClickElement(chbChangeCapacity);
}
if (permanent)
{
_driver.ClickElement(chbPermanent);
}
_driver.SendKeys(dtpStartDate, string.Format("{0}/{1}/{2}", startDate.Month, startDate.Day, startDate.Year));
_driver.SendKeys(dtpEndDate, string.Format("{0}/{1}/{2}", endDate.Month, endDate.Day, endDate.Year));
_driver.ClickElement(btnSave);
id = "";
return _driver.FindTableRecord(tblteamResources, string.Format("{0} {1}", firstName, lastName), "PeopleResource/Details?resourceId=", "&teamId=", out id);
}
public bool DeletePeopleResource(string resourceId, string teamIs, string firstName, string lastName)
{
_driver.OpenPage(string.Format("PeopleResource/Delete?resourceId={0}&teamId={1}", resourceId, teamIs));
bool result = _driver.GetElement(lblWarning).Text.IndexOf("Are you sure you want to delete it?") > -1;
_driver.ClickElement(btnDelete);
string id = "";
return !_driver.FindTableRecord(tblteamResources, string.Format("{0} {1}", firstName, lastName), "PeopleResource/Details?resourceId=", "&teamId=", out id);
}
/*
public bool EditCompany(string companyId, string companyName, string[] clients, string[] views)
{
_driver.OpenPage(string.Format("Team/Board?teamId=c8090d7c-74d4-4036-9e17-b2d8695e1f7d{0}", companyId));
_driver.SendKeys(txtCompanyName, companyName);
SetClients(clients);
SetViews(views);
_driver.ClickElement(btnSave);
return CheckCompany(companyId, companyName, clients, views);
}
public bool FindCompany(string name, out string id)
{
return _driver.FindRecord("Company", name, out id);
}
private bool SetClients(string[] clients)
{
return _driver.SetCheckboxList("Clients", clients); ;
}
private bool CheckClients(string[] clients)
{
//TODO
return true;
}
private bool SetViews(string[] views)
{
return _driver.SetCheckboxList("Views", views); ;
}
private bool CheckViews(string[] views)
{
//TODO
return true;
}
*/
}
}