95 lines
3.2 KiB
C#
95 lines
3.2 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 CompaniesPage : BasePage
|
|
{
|
|
By btnPrimary = By.ClassName("btn-primary");
|
|
By txtCompanyName = By.Id("IDDDD");
|
|
By btnSave = By.Id("btnsave");
|
|
By lblWarning = By.ClassName("panel-body");
|
|
By btnDelete = By.Id("btnDelete");
|
|
|
|
WebDriver _driver;
|
|
|
|
public CompaniesPage(WebDriver driver)
|
|
{
|
|
_driver = driver;
|
|
}
|
|
|
|
public bool OpenCompanies()
|
|
{
|
|
_driver.OpenPage("Company");
|
|
_driver.WaitElement(btnPrimary);
|
|
return _driver.GetElement(btnPrimary, "Add Company") != null;
|
|
}
|
|
public bool CreateCompany(string companyName, string[] clients, string[] views, out string id)
|
|
{
|
|
_driver.ClickElement(btnPrimary, "Add Company");
|
|
_driver.SendKeys(txtCompanyName, companyName);
|
|
SetClients(clients);
|
|
SetViews(views);
|
|
_driver.ClickElement(btnSave);
|
|
id = "";
|
|
return _driver.FindRecord("Company", companyName, out id, 2);
|
|
}
|
|
public bool CheckCompany(string company, string companyName, string[] clients, string[] views)
|
|
{
|
|
_driver.OpenPage(string.Format("Company/Edit/{0}", company));
|
|
return (_driver.GetElement(txtCompanyName).GetAttribute("value") == companyName) &&
|
|
(CheckClients(clients)) &&
|
|
(CheckViews(views));
|
|
}
|
|
|
|
public bool DeleteCompany(string companyId, string companyName)
|
|
{
|
|
_driver.OpenPage(string.Format("Company/Delete/{0}", companyId));
|
|
bool result = _driver.GetElement(lblWarning).Text.IndexOf("Are you sure you want to delete it?") > -1;
|
|
_driver.ClickElement(btnDelete);
|
|
string id = "";
|
|
_driver.FindRecord("Company", companyName, out id, 2);
|
|
return result && (id == "");
|
|
}
|
|
|
|
public bool EditCompany(string companyId, string companyName, string[] clients, string[] views)
|
|
{
|
|
_driver.OpenPage(string.Format("Company/Edit/{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;
|
|
}
|
|
}
|
|
}
|