Skip to content

Commit

Permalink
Add page component to PageObjectModels
Browse files Browse the repository at this point in the history
  • Loading branch information
AsiaWi committed Jul 4, 2024
1 parent a06076c commit baf3ae5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ namespace DfE.Data.SearchPrototype.Web.Tests.Integration.PageObjectModel
public sealed class HomePage : DocumentObjectModelExtractor
{
private readonly PageHeader _pageHeader;
private readonly PageBody _pageBody;

private const string PageName = "Home";
private const string PrivacyLink = "Privacy";
private const string MainHeadingClass = "govuk-header__link govuk-header__service-name";
private const string containerId = "search-container";

public HomePage(WebApplicationFactory<Program> webApplicationFactory) :
base(webApplicationFactory, PageName)
{
_pageHeader = PageHeader.Create(DocumentObjectModel);
_pageBody = PageBody.Create(DocumentObjectModel);
}

public string GetHomePageHeading() =>
Expand All @@ -25,6 +28,10 @@ public string GetHomePageHeading() =>
public IHtmlAnchorElement GetHomePagePrivacyLink() =>
_pageHeader.GetHeaderLink(PrivacyLink);

//public string GetSearchComponent() =>
// _searchComponent.GetSearchComponentContainer(containerId);


public static HomePage Create(
WebApplicationFactory<Program> webApplicationFactory) => new(webApplicationFactory);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using AngleSharp.Dom;
using Dfe.Data.SearchPrototype.Web.Tests.Integration.PageObjectModel.PageComponents;

namespace DfE.Data.SearchPrototype.Web.Tests.Integration.PageObjectModel.PageComponents
{
public sealed class PageBody : PageComponent
{
private const string BodyElementTag = "body";

private PageBody(IDocument documentObjectModel) : base(documentObjectModel, BodyElementTag){
}

public static PageBody Create(IDocument documentObjectModel) => new(documentObjectModel);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//using AngleSharp.Dom;
//using AngleSharp.Html.Dom;
//using Dfe.Data.SearchPrototype.Web.Tests.Integration.PageObjectModel.PageComponents;

//namespace DfE.Data.SearchPrototype.Web.Tests.Integration.PageObjectModel.PageComponents
//{
// public sealed class SearchComponent : PageComponent
// {
// private const string searchComponentContainer = "div";

// private SearchComponent(IDocument documentObjectModel)
// : base(documentObjectModel, searchComponentContainer, isTagName: false)
// {
// }

// public string GetSearchComponentContainer(string containerId) =>
// PageElement == null ?
// throw new InvalidOperationException(
// "Unable to derive the main heading in page.") :
// PageElement
// .GetElementsByTagName("div").GetElementById(containerId).InnerHtml;

// public IHtmlAnchorElement GetHeaderLink(string linkName) =>
// PageElement == null ?
// throw new InvalidOperationException(
// $"Unable to derive the search link: {linkName} in page.") :
// (IHtmlAnchorElement)PageElement
// .GetElementsByTagName("a")
// .Single(anchorTags => anchorTags.TextContent.Contains(linkName));

// public static SearchComponent Create(IDocument documentObjectModel) => new(documentObjectModel);
// }
//}

0 comments on commit baf3ae5

Please sign in to comment.