Today we look at the actual code that we have. Dont worry I will give you the link (GIT) link for the entire code framework I have written. There I list some code
ACCNTGROUPLISTPAGE.CS
/*
* Test Case Name: Accnt Group List Page
* Author: Rahul A. Dhakate
* Created Date: 09-12-2023
* Updated By: Rahul A. Dhakate
* Updated Date: 23-12-2023
* Comments:
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jkrux.TestAutomation.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
using System.Diagnostics;
using Jkrux.TestAutomation.Tests.Pages;
using Jkrux.TestAutomation.Tests.Tests;
namespace Jkrux.TestAutomation.Tests.Pages.Accounts.AccntGroup
{
class AccntGroupListPage : BasePage
{
public List<string> accntListFields = new List<string>();
#region Objects for Account List Page
// LIST PAGE ELEMENTS PROPERTIES --
[FindsBy(How = How.Id, Using = "__tab_cphPageContent_TabContainer_Menu_tabpanel1")]
private IWebElement TabAccnts { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_TabContainer_Menu_tabpanel1_tabpanel1_Table3""]/tbody/tr[2]/td[2]/a")]
private IWebElement LstAccntGroup { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphQueryPanelContent_txtAccntGroupName")]
private IWebElement TxtAccntGroupName { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphQueryPanelContent_txtAccntGroupCode")]
private IWebElement TxtAccntGroupCode { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphQueryPanelContent_ddlAccntGroupType")]
private IWebElement DdlAccntGroupType { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphQueryPanelContent_ddlAccntGroupSubType")]
private IWebElement DdlAccntGroupSubType { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphQueryPanelContent_ddlAccntGroupStatus")]
private IWebElement DdlStatus { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_cphQueryPanelContent_ddlAccntGroupType""]/option[2]")]
private IWebElement DdlAccntGroupTypeOptionBalanceSheet { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_cphQueryPanelContent_ddlAccntGroupStatus""]/option[3]")]
private IWebElement DdlStatusOptionEnabled { get; set; }
[FindsBy(How = How.Id, Using = "lnk04")]
private IWebElement BtnFetch { get; set; }
[FindsBy(How = How.Id, Using = "lnk02")]
private IWebElement BtnEdit { get; set; }
[FindsBy(How = How.Id, Using = "lnk01")]
private IWebElement BtnClose { get; set; }
[FindsBy(How = How.Id, Using = "lnk04")]
private IWebElement BtnListDelete { get; set; }
[FindsBy(How = How.Id, Using = "imgCenter")]
private IWebElement BtnListConfirm { get; set; }
[FindsBy(How = How.Id, Using = "lnk05")]
private IWebElement BtnListDisable { get; set; }
[FindsBy(How = How.Id, Using = "lnk06")]
private IWebElement BtnListEnable { get; set; }
[FindsBy(How = How.Id, Using = "lblErrorMssge")]
private IWebElement LblMessage { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphListPanelContent_grdTableField01_lnkGrid_AccntGroupName_0")]
private IWebElement LnkAccntNameRow1 { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphListPanelContent_grdTableField01_chkSelectedItem_0")]
private IWebElement ChkAccntGroupListRow1 { get; set; }
#endregion
#region Account List Page Methods
public AccntGroupListPage InitPage()
{
PageFactory.InitElements(DriverContext.Driver, this);
return this;
}
public string GetActualMssge()
{
return ReadText(LblMessage);
}
public AccntGroupListPage ClickAccntsTab()
{
TabAccnts.Click();
return this;
}
public AccntGroupListPage ClickAccntGroupListLink()
{
LstAccntGroup.Click();
return this;
}
public AccntGroupListPage ClickCloseButton()
{
BtnClose.Click();
return this;
}
public AccntGroupListPage ClickEditButton()
{
BtnEdit.Click();
return this;
}
public AccntGroupListPage ClickFetchButton()
{
BtnFetch.Click();
return this;
}
public AccntGroupListPage ClickConfirmButton()
{
BtnListConfirm.Click();
return this;
}
public AccntGroupListPage ClickDeleteButton()
{
BtnListDelete.Click();
return this;
}
public AccntGroupListPage ClickDisableButton()
{
BtnListDisable.Click();
return this;
}
public AccntGroupListPage ClickEnableButton()
{
BtnListEnable.Click();
return this;
}
public AccntGroupListPage EnterAccntGroupName(string sAccntGroupName)
{
Enter(TxtAccntGroupName, sAccntGroupName);
return this;
}
public AccntGroupListPage EnterAccntGroupCode(string sAccntGroupCode)
{
Enter(TxtAccntGroupCode, sAccntGroupCode);
return this;
}
public AccntGroupListPage SelectAccntGroupType(string sAccntGroupTypeOption)
{
SelectDropDownOption(DdlAccntGroupType, sAccntGroupTypeOption);
return this;
}
public AccntGroupListPage SelectAccntGroupSubType(string sAccntGroupSubTypeOption)
{
SelectDropDownOption(DdlAccntGroupSubType, sAccntGroupSubTypeOption);
return this;
}
public AccntGroupListPage SelectAccntGroupStatus(string sAccntGroupStatus)
{
SelectDropDownOption(DdlStatus, sAccntGroupStatus);
return this;
}
public AccntGroupListPage ClickAccntNameRow1Link()
{
LnkAccntNameRow1.Click();
return this;
}
public AccntGroupListPage ClickAccntGroupListRow1Checkbox()
{
ChkAccntGroupListRow1.Click();
return this;
}
#endregion
}
}
ACCNTGROUPADDPAGE.CS
/*
* Test Case Name: Accnt Group Add Page
* Author: Rahul A. Dhakate
* Created Date: 22-12-2023
* Updated By:
* Updated Date:
* Comments:
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jkrux.TestAutomation.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
using System.Diagnostics;
using Jkrux.TestAutomation.Tests.Pages;
using Jkrux.TestAutomation.Tests.Tests;
using NUnit.Framework;
namespace Jkrux.TestAutomation.Tests.Pages.Accounts.AccntGroup
{
class AccntGroupAddPage : BasePage
{
#region Objects for Add New Account Page
// ADD PAGE ELEMENTS --
[FindsBy(How = How.Id, Using = "__tab_cphPageContent_TabContainer_Menu_tabpanel1")]
private IWebElement TabAccnts { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_TabContainer_Menu_tabpanel1_tabpanel1_Table3""]/tbody/tr[2]/td[3]/a")]
private IWebElement LnkAccntGroupNew { get; set; }
[FindsBy(How = How.Id, Using = "lnk03")]
private IWebElement BtnSave { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphPageContent_txtAccntGroupName")]
private IWebElement TxtNewAccntGroupName { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphPageContent_txtAccntGroupCode")]
private IWebElement TxtNewAccntGroupCode { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphPageContent_ddlAccntGroupType")]
private IWebElement DdlNewAccntGroupType { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_cphPageContent_ddlAccntGroupType""]/option[2]")]
private IWebElement DdlNewAccntGroupTypeOptionBalanceSheet { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_cphPageContent_ddlAccntGroupType""]/option[3]")]
private IWebElement DdlNewAccntGroupTypeOptionProfitAndLoss { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphPageContent_ddlAccntGroupSubType")]
private IWebElement DdlNewAccntGroupSubType { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_cphPageContent_ddlAccntGroupSubType""]/option[2]")]
private IWebElement DdlNewAccntGroupSubTypeOptionAssets { get; set; }
[FindsBy(How = How.XPath, Using = @"//*[@id=""cphPageContent_cphPageContent_ddlAccntGroupSubType""]/option[3]")]
private IWebElement DdlNewAccntGroupSubTypeOptionLiabilities { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphPageContent_ddlAccntGroupStatus")]
private IWebElement DdlNewAccntGroupStatus { get; set; }
[FindsBy(How = How.Id, Using = "cphPageContent_cphPageContent_ddlAccntGrpLbl")]
private IWebElement DdlNewAccntGroupLabel { get; set; }
[FindsBy(How = How.Id, Using = "lblErrorMssge")]
private IWebElement LblMessage { get; set; }
[FindsBy(How = How.Id, Using = "lnk01")]
private IWebElement BtnClose { get; set; }
#endregion
#region Add New Account Group Page Methods
public AccntGroupAddPage InitPage()
{
PageFactory.InitElements(DriverContext.Driver, this);
return this;
}
public string GetAccntGroupSubTypeText()
{
return ReadDropDownText(DdlNewAccntGroupSubType);
}
public string GetActualMssge()
{
return ReadText(LblMessage);
}
public string GetNewAccntGroupCodeValue()
{
return TxtNewAccntGroupCode.GetAttribute("value");
}
public AccntGroupAddPage ClickAccntsTab()
{
TabAccnts.Click();
return this;
}
public AccntGroupAddPage ClickAccntsGroupNewLink()
{
LnkAccntGroupNew.Click();
return this;
}
public AccntGroupAddPage ClickSaveButton()
{
ClickButton(BtnSave);
return this;
}
public AccntGroupAddPage EnterAccntGroupName(string sAccntGroupName)
{
Enter(TxtNewAccntGroupName, sAccntGroupName);
return this;
}
public AccntGroupAddPage EnterAccntGroupCode(string sAccntGroupCode)
{
Enter(TxtNewAccntGroupCode, sAccntGroupCode);
return this;
}
public AccntGroupAddPage SelectAccntGroupType(string sAccntGroupTypeOption)
{
SelectDropDownOption(DdlNewAccntGroupType, sAccntGroupTypeOption);
return this;
}
public AccntGroupAddPage SelectAccntGroupSubType(string sAccntGroupSubTypeOption)
{
SelectDropDownOption(DdlNewAccntGroupSubType, sAccntGroupSubTypeOption);
return this;
}
public bool VerifyMssge(string sExpctdMssge)
{
bool bRetval = false;
string sActualMssge = null;
try
{
sActualMssge = ReadText(LblMessage);
Assert.AreEqual(sActualMssge, sExpctdMssge);
bRetval = true;
}
catch(AssertionException ex)
{
bRetval = false;
}
return bRetval;
}
public AccntGroupAddPage ClickCloseButton()
{
ClickButton(BtnClose);
return this;
}
#endregion
}
}