70 lines
2.6 KiB
C#
70 lines
2.6 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 CapacityManagementPage : BasePage
|
|
{
|
|
By btnPrimary = By.ClassName("btn-primary");
|
|
By tblCapacity = By.Id("dataTable2_CFB");
|
|
By drdTeam = By.Id("s2id_autogen7"); // By.Id("s2id_autogen6");// By.ClassName("select2-choice");// By.Id("TeamId");
|
|
By drdiSearchTeam = By.ClassName("select2-match");
|
|
By dtpStartDate = By.Id("filterStartDate");
|
|
By dtpEndDate = By.Id("filterEndDate");
|
|
By btnReloadCapacityCalendar = By.Id("btnReloadCapacityCalendar");
|
|
|
|
WebDriver _driver;
|
|
|
|
public CapacityManagementPage(WebDriver driver)
|
|
{
|
|
_driver = driver;
|
|
}
|
|
|
|
public bool OpenCapacityManagement()
|
|
{
|
|
_driver.OpenPage("CapacityManagement");
|
|
_driver.WaitElement(btnPrimary);
|
|
return _driver.GetElement(btnPrimary, "Save Changes") != null;
|
|
}
|
|
public float GetPlannedCapacity(string team, string expenditureCategory)
|
|
{
|
|
OpenCapacityManagement();
|
|
DateTime startDate = DateTime.Today.AddDays(-110);
|
|
DateTime endDate = DateTime.Today.AddDays(110);
|
|
_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.SendKeys(drdTeam, team);
|
|
_driver.ClickElement(drdiSearchTeam);
|
|
_driver.ClickElement(btnReloadCapacityCalendar);
|
|
|
|
//IWebElement tableCapacity = _driver.GetElement(tblCapacity);
|
|
IList<IWebElement> rows = _driver.GetElements(By.XPath("tbody/tr"), tblCapacity);
|
|
foreach(IWebElement row in rows)
|
|
{
|
|
try {
|
|
IList<IWebElement> columns = row.FindElements(By.XPath("td"));
|
|
bool found = false;
|
|
foreach (IWebElement column in columns)
|
|
{
|
|
if (found)
|
|
{
|
|
return float.Parse(column.Text.Replace(",", "").Replace(".", ","));
|
|
}
|
|
if (column.Text == expenditureCategory)
|
|
{
|
|
found = true;
|
|
}
|
|
}
|
|
} catch { }
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
}
|