Palak Shah
Well-known member
- Joined
- Apr 29, 2020
- Messages
- 97
- Programming Experience
- 1-3
Hello Everyone,
I have one file which is of common method and has too many methods inside a single class file, now I want to create hierarchy so it can be divided further with the help of abstraction, I tried few things but then I got confused on how to access different methods?
Now I want to create hierarchy such that main file common method will have on definitions of method and 2 separate class files will be there one for CMS Common Methods and one for WebSite Common methods
I am not sure for such thing what could be the proper architecture so that if in future we want to scale, it won't have any issue
I have one file which is of common method and has too many methods inside a single class file, now I want to create hierarchy so it can be divided further with the help of abstraction, I tried few things but then I got confused on how to access different methods?
Main Common Methods file which has lot of methods:
using Base;
using Constants;
using Entities;
using Extensions;
using SeleniumExtensions;
using Helpers;
using Model;
using AtlasNav;
using Model.PaymentOptions;
using Pages.DesignPages.DesignViews;
using Pages.UserAccount_Pages;
using Repositories;
using Pages;
using Pages.CheckoutPages;
using Pages.CMSPages;
using Pages.KlarnaCheckoutPages;
using Pages.SellerStorePages;
using Framework.DataAccessLayer.EntitiyFramework.Repositories;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using TestConfigurationCDO = Config.TestConfigurationCDO;
namespace ManualRegressionSuite.CommonMethods
{ public class CommonMethods : Base
{
public TestConfigurationCDO _testConfiguration;
WebDriverWait wait;
public IList<Site> _sites;
public string _bolUkSiteUrl;
public string _cmsSiteUrl;
public Site _site;
public CommonMethods(SharedParameters test_properties)
{
this.shared_parameters = test_properties;
this.Driver = test_properties.Driver;
this._testConfiguration = test_properties.testConfiguration;
this._sites = test_properties.sites;
this._bolUkSiteUrl = test_properties.SiteBag.domain_url;
this._cmsSiteUrl = test_properties.SiteBag.cms_url;
this._site = test_properties.site;
}
/// <summary>
///
/// </summary>
public void CommonMethod_SellerLogIn()
{
var site = shared_parameters.site.GetName();
var homePage = GetInstance<HomePage>();
homePage.To_SignInPage(site);
var signInPage = GetInstance<SignInPage>();
signInPage.To_SellerLandingPage();
}
/// <summary>
/// Below method will navigate to Product Page through Atlas Navigation
/// </summary>
/// <param name="productId"></param>
public void CommonMetho_GoToProductPage(int productId)
{
var homePage = GetInstance<HomePage>();
homePage.To_ProductPage(productId);
}
/// <summary>
/// Below method will:
///
/// </summary>
/// <param name="param"></param>
public void CommonMethod_DesignProduct(WorkflowParameters param)
{
var generalProductPage = GetInstance<MasterProductPage>();
generalProductPage.To_DesignPage();
var designPage = GetInstance<DesignPage, DesignPageArgs>(new DesignPageArgs());
designPage.basketToolbarView.UpdateProductQuantity(param.quantity.ToString());
designPage.Design(param.designMethod);
}
/// <summary>
/// Below method will Add product to Basket
/// </summary>
public void CommonMethod_AddToBasket()
{
var designPage = GetInstance<DesignPage, DesignPageArgs>(new DesignPageArgs());
designPage.AddToCart();
}
/// <summary>
/// Below method will review the basket item:
/// </summary>
/// <param name="productId"></param>
public void CommonMethod_BasketReview(int productId)
{
var basketPage = GetInstance<BasketPage, BasketPageArgs>(new BasketPageArgs());
var check = basketPage.BasketPriceView.CheckBasketPrice();
Assert.IsTrue(check);
var isPresent = basketPage.BasketItemsView.Validate_ItemIsInBasket(productId);
Assert.IsTrue(isPresent);
Assert.IsTrue(!ImageHelpers.IsEmpty(basketPage.BasketItemsView.GetItemImage(productId)));
}
/// <summary>
///
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public string CommonMethod_PurchaseItem(WorkflowParameters param)
{
var basketPage = GetInstance<BasketPage, BasketPageArgs>(new BasketPageArgs());
basketPage.To_CheckoutPage(param.paymentOptions.portal);
var checkoutPage = GetInstance<CheckoutPage>();
checkoutPage.To_OrderSummaryPage(param.paymentOptions);
var orderConfirmPage = GetInstance<OrderConfirmPage>();
var _order = orderConfirmPage.To_Self_CheckOrderDatabase();
return _order.OrderId.ToString(); ;
}
/// <summary>
///
/// </summary>
/// <param name="OrderId"></param>
public void CommonMethod_CMSVerification(string OrderId)
{
var cmsLoginPage = GetInstance<CMSLoginPage>();
cmsLoginPage.To_CMSLandingPage();
var cmsLandingPage = GetInstance<CMSLandingPage>();
cmsLandingPage.To_OrderPage_OrderCheck(OrderId);
var cmsOrderPage = GetInstance<CMSOrderPage>();
cmsOrderPage.orderDetailsView.To_Self_CheckPrices(shared_parameters.price);
var check = cmsOrderPage.orderDetailsView.IsOrderAuthorised(OrderId.ToInt());
Assert.IsTrue(check);
}
/// <summary>
///
/// </summary>
public void CommonMethod_CMSDespatchNoteVerification()
{
var cmsOrderPage = GetInstance<CMSOrderPage>();
cmsOrderPage.ChangeStatus_ByDropDown(OrderStatus.Dispatched);
cmsOrderPage.deliveryDetailsView.Check_DespatchNote();
}
/// <summary>
///
/// </summary>
public void CommonMethod_CreateStore()
{
var sellerLandingPage = GetInstance<SellerLandingPage>();
sellerLandingPage.To_SellerMyStoresPage();
var sellerMyStoresPage = GetInstance<SellerMyStoresPage>();
var uniqueName = sellerMyStoresPage.To_Self_CreateStore();
}
/// <summary>
///
/// </summary>
public void CommonMethod_NavigateToMyProductsPage()
{
}
/// <summary>
///
/// </summary>
public void CommonMethod_CreateProduct()
{
}
/// <summary>
///
/// </summary>
public void CommonMethod_AddProductToStore()
{
}
}
public class WorkflowParameters
{
public int productId = default(int);
public int orderId = default(int);
public DesignMethod designMethod = default(DesignMethod);
public bool signedIn = default(bool);
public bool increaseBasketQty = default(bool);
public bool signedInCMS = default(bool);
public bool editable = default(bool);
public Site _site = default(Site);
public PaymentOptions paymentOptions = default(PaymentOptions);
public bool checkOrderAuthorise = default(bool);
public int quantity = default(int);
}
}
Now I want to create hierarchy such that main file common method will have on definitions of method and 2 separate class files will be there one for CMS Common Methods and one for WebSite Common methods
CMSCommonMethod File:
using Base;
using Constants;
using Extensions;
using Pages.CMSPages;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ManualRegressionSuite.CommonMethods
{
public class CMSCommonMethods : Base
{
/// <summary>
///
/// </summary>
/// <param name="OrderId"></param>
public void CommonMethod_CMSVerification(string OrderId)
{
var cmsLoginPage = GetInstance<CMSLoginPage>();
cmsLoginPage.To_CMSLandingPage();
var cmsLandingPage = GetInstance<CMSLandingPage>();
cmsLandingPage.To_OrderPage_OrderCheck(OrderId);
var cmsOrderPage = GetInstance<CMSOrderPage>();
cmsOrderPage.orderDetailsView.To_Self_CheckPrices(shared_parameters.price);
var check = cmsOrderPage.orderDetailsView.IsOrderAuthorised(OrderId.ToInt());
Assert.IsTrue(check);
}
/// <summary>
///
/// </summary>
public void CommonMethod_CMSDespatchNoteVerification()
{
var cmsOrderPage = GetInstance<CMSOrderPage>();
cmsOrderPage.ChangeStatus_ByDropDown(OrderStatus.Dispatched);
cmsOrderPage.deliveryDetailsView.Check_DespatchNote();
}
}
}
WebSiteCommonMethod:
using Base;
using Entities;
using Helpers;
using Pages;
using Pages.CheckoutPages;
using Pages.SellerStorePages;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ManualRegressionSuite.CommonMethods
{
public class WebSiteCommonMethods:Base
{
/// <summary>
///
/// </summary>
public void CommonMethod_SellerLogIn()
{
var site = shared_parameters.site.GetName();
var homePage = GetInstance<HomePage>();
homePage.To_SignInPage(site);
var signInPage = GetInstance<SignInPage>();
signInPage.To_SellerLandingPage();
}
/// <summary>
/// Below method will navigate to Product Page through Atlas Navigation
/// </summary>
/// <param name="productId"></param>
public void CommonMetho_GoToProductPage(int productId)
{
var homePage = GetInstance<HomePage>();
homePage.To_ProductPage(productId);
}
/// <summary>
/// Below method will:
///
/// </summary>
/// <param name="param"></param>
public void CommonMethod_DesignProduct(WorkflowParameters param)
{
var generalProductPage = GetInstance<MasterProductPage>();
generalProductPage.To_DesignPage();
var designPage = GetInstance<DesignPage, DesignPageArgs>(new DesignPageArgs());
designPage.basketToolbarView.UpdateProductQuantity(param.quantity.ToString());
designPage.Design(param.designMethod);
}
/// <summary>
/// Below method will Add product to Basket
/// </summary>
public void CommonMethod_AddToBasket()
{
var designPage = GetInstance<DesignPage, DesignPageArgs>(new DesignPageArgs());
designPage.AddToCart();
}
/// <summary>
/// Below method will review the basket item:
/// </summary>
/// <param name="productId"></param>
public void CommonMethod_BasketReview(int productId)
{
var basketPage = GetInstance<BasketPage, BasketPageArgs>(new BasketPageArgs());
var check = basketPage.BasketPriceView.CheckBasketPrice();
Assert.IsTrue(check);
var isPresent = basketPage.BasketItemsView.Validate_ItemIsInBasket(productId);
Assert.IsTrue(isPresent);
Assert.IsTrue(!ImageHelpers.IsEmpty(basketPage.BasketItemsView.GetItemImage(productId)));
}
/// <summary>
///
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public string CommonMethod_PurchaseItem(WorkflowParameters param)
{
var basketPage = GetInstance<BasketPage, BasketPageArgs>(new BasketPageArgs());
basketPage.To_CheckoutPage(param.paymentOptions.portal);
var checkoutPage = GetInstance<CheckoutPage>();
checkoutPage.To_OrderSummaryPage(param.paymentOptions);
var orderConfirmPage = GetInstance<OrderConfirmPage>();
var _order = orderConfirmPage.To_Self_CheckOrderDatabase();
return _order.OrderId.ToString(); ;
}
/// <summary>
///
/// </summary>
public void CommonMethod_CreateStore()
{
var sellerLandingPage = GetInstance<SellerLandingPage>();
sellerLandingPage.To_SellerMyStoresPage();
var sellerMyStoresPage = GetInstance<SellerMyStoresPage>();
var uniqueName = sellerMyStoresPage.To_Self_CreateStore();
}
/// <summary>
///
/// </summary>
public void CommonMethod_NavigateToMyProductsPage()
{
}
/// <summary>
///
/// </summary>
public void CommonMethod_CreateProduct()
{
}
/// <summary>
///
/// </summary>
public void CommonMethod_AddProductToStore()
{
}
}
}
I am not sure for such thing what could be the proper architecture so that if in future we want to scale, it won't have any issue