public void GivenAWiltshireSearchResultDocument_CanExtractDetails() { // Arrange var planningApplications = new List <PlanningApplication>(); // Act _searchPageResponseDoc.Select("table tbody tr").Each(tr => { var planningApplication = new PlanningApplication(); WiltshireExtractor.GetSeachRowDetailAsync(tr, planningApplication, CancellationToken.None).GetAwaiter().GetResult(); planningApplications.Add(planningApplication); // Assert Assert.IsNotNull(planningApplication.ApplicationReference); Assert.IsNotNull(planningApplication.ApplicationLink); Assert.IsNotNull(planningApplication.SiteAddress); Assert.IsNotNull(planningApplication.Proposal); Assert.AreNotEqual(string.Empty, planningApplication.ApplicationReference); Assert.AreNotEqual(string.Empty, planningApplication.ApplicationLink); Assert.AreNotEqual(string.Empty, planningApplication.SiteAddress); Assert.AreNotEqual(string.Empty, planningApplication.Proposal); }); Assert.AreEqual(143, planningApplications.Count); }
public async Task GivenAWiltshireApplicationPage_CanExtractDetails() { // Arrange var planningApplication = new PlanningApplication(); // Act await WiltshireExtractor.ExtractPlanningApplicationData(planningApplication, _planningApplicationDoc); // Assert Assert.IsNotNull(planningApplication.RegisteredDate); Assert.IsNotNull(planningApplication.ConsultationExpiryDate); Assert.IsNotNull(planningApplication.TargetDate); Assert.IsNotNull(planningApplication.ApplicationType); Assert.IsNotNull(planningApplication.CurrentStatus); Assert.IsNotNull(planningApplication.NameOfApplicant); Assert.IsNotNull(planningApplication.AgentName); Assert.IsNotNull(planningApplication.Wards); Assert.IsNotNull(planningApplication.Parishes); Assert.IsNotNull(planningApplication.CaseOfficer); Assert.IsNotNull(planningApplication.DocumentsLink); Assert.AreNotEqual(string.Empty, planningApplication.RegisteredDate); Assert.AreNotEqual(string.Empty, planningApplication.ConsultationExpiryDate); Assert.AreNotEqual(string.Empty, planningApplication.TargetDate); Assert.AreNotEqual(string.Empty, planningApplication.ApplicationType); Assert.AreNotEqual(string.Empty, planningApplication.CurrentStatus); Assert.AreNotEqual(string.Empty, planningApplication.NameOfApplicant); Assert.AreNotEqual(string.Empty, planningApplication.AgentName); Assert.AreNotEqual(string.Empty, planningApplication.Wards); Assert.AreNotEqual(string.Empty, planningApplication.Parishes); Assert.AreNotEqual(string.Empty, planningApplication.CaseOfficer); Assert.AreNotEqual(string.Empty, planningApplication.DocumentsLink); }
public static async Task GetSeachRowDetailAsync(IDomObject tr, PlanningApplication planningApplication, CancellationToken cancellationToken) { var cellPos = 0; foreach (var cell in tr.ChildElements) { switch (cellPos) { // Application case 0: planningApplication.ApplicationReference = cell.InnerText.Clean(); planningApplication.ApplicationLink = cell.FirstElementChild.Attributes["href"].CleanApplicationUrl(); break; // Site case 1: planningApplication.SiteAddress = cell.InnerText.Trim().Clean(); break; // Proposal case 2: planningApplication.Proposal = cell.InnerText.Trim().Clean(); break; } cellPos++; } await Task.CompletedTask; }
public static async Task ExtractPlanningApplicationData(PlanningApplication planningApplication, CQ applicationPageDoc) { applicationPageDoc.Select(".planappkd dl dt").Each(dt => { switch (dt.InnerText) { case "Registered (validated)": planningApplication.RegisteredDate = dt.NextElementSibling.InnerText.Clean(); break; case "Consultation expiry": planningApplication.ConsultationExpiryDate = dt.NextElementSibling.InnerText.Clean(); break; case "Target date for decision": planningApplication.TargetDate = dt.NextElementSibling.InnerText.Clean(); break; } }); applicationPageDoc.Select("#wrapper dl:nth-of-type(2) dt").Each(dt => { switch (dt.InnerText) { case "Application type": planningApplication.ApplicationType = dt.NextElementSibling.InnerText.Clean(); break; case "Current status of application": planningApplication.CurrentStatus = dt.NextElementSibling.InnerText.Clean(); break; case "Name of applicant": planningApplication.NameOfApplicant = dt.NextElementSibling.InnerText.Clean(); break; case "Name of agent": planningApplication.AgentName = dt.NextElementSibling.InnerText.Clean(); break; case "Wards": planningApplication.Wards = dt.NextElementSibling.InnerText.Clean(); break; case "Parishes": planningApplication.Parishes = dt.NextElementSibling.InnerText.Clean(); break; case "Case officer": planningApplication.CaseOfficer = dt.NextElementSibling.InnerText.Clean(); break; } }); planningApplication.DocumentsLink = applicationPageDoc.Select(".documentlink a").Attr("href"); await Task.CompletedTask; }
public async Task <IEnumerable <PlanningApplication> > ExtractDataAsync(string searchArea, List <HttpResponseMessage> searchResultPages, CookieContainer cookieContainer, CancellationToken cancellationToken) { try { _configuration = _configResolver.ResolveConfig(searchArea); var currentPage = 0; await _logger.LogInformationAsync($"Processing {searchResultPages.Count} search result pages for {searchArea.ToUpper()}", cancellationToken); var client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer); foreach (var searchResults in searchResultPages) { currentPage++; var searchResultsHtml = await searchResults.Content.ReadAsStringAsync(); var searchPageResponseDoc = CQ.Create(searchResultsHtml); var appSummaryPaths = GetAppSummaryPaths(searchPageResponseDoc); await _logger.LogInformationAsync($"Found {appSummaryPaths.Count} planning applications in page {currentPage}...", cancellationToken); var row = 0; foreach (var appSummaryPath in appSummaryPaths) { row++; var planningApplication = new PlanningApplication(); await _logger.LogInformationAsync($"Getting application detail for result number {row} application {appSummaryPath}", cancellationToken); await ExtractApplicationSummary(cancellationToken, appSummaryPath, client, planningApplication); var appDetailsPath = await ExtractApplicationDetails(cancellationToken, appSummaryPath, client, planningApplication); await ExtractApplicationContact(cancellationToken, appDetailsPath, client, planningApplication); _planningApplications.Add(planningApplication); if (_configuration.UseProxy) { // refresh client/handler to get a new IP address client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer); } } } await _logger.LogInformationAsync($"Finished extracting planning data for {searchArea.ToUpper()}...", cancellationToken); client.Dispose(); return(_planningApplications); } catch (Exception ex) { throw new ExtractDataFailedException(ex.Message, ex.InnerException); } }
public void GivenAIdoxApplicationSummaryResponse_CanExtractApplicationSummaryDetails() { var planningApplication = new PlanningApplication(); _applicationSummaryResponseDoc.Select("#simpleDetailsTable tr").Each(row => { if (row.ChildNodes[1].InnerText.Contains("Reference") && !row.ChildNodes[1].InnerText.Contains("Alternative Reference")) { planningApplication.ApplicationReference = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Application Validated")) { planningApplication.RegisteredDate = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Address")) { planningApplication.SiteAddress = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Proposal")) { planningApplication.Proposal = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Status") && !row.ChildNodes[1].InnerText.Contains("Appeal Status")) { planningApplication.CurrentStatus = row.ChildNodes[3].InnerText.Clean(); } }); if (string.IsNullOrEmpty(planningApplication.Proposal)) { planningApplication.Proposal = _applicationSummaryResponseDoc.Select(".description").Text().Clean(); } if (string.IsNullOrEmpty(planningApplication.SiteAddress)) { planningApplication.SiteAddress = _applicationSummaryResponseDoc.Select(".address").Text().Clean(); } Assert.IsNotNull(planningApplication.ApplicationReference); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.ApplicationReference)); Assert.IsNotNull(planningApplication.RegisteredDate); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.RegisteredDate)); Assert.IsNotNull(planningApplication.SiteAddress); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.SiteAddress)); Assert.IsNotNull(planningApplication.Proposal); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.Proposal)); Assert.IsNotNull(planningApplication.CurrentStatus); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.CurrentStatus)); }
public async Task GivenWiltshireDocumentSearchResults_CanExtractDocumentLinks() { // Arrange var planningApplication = new PlanningApplication(); // Act await WiltshireExtractor.ExtractDocumentLinksAsync(planningApplication, _documentSearchResultsDoc, CancellationToken.None); // Assert Assert.IsNotNull(planningApplication.AllDocumentLinks); Assert.AreNotEqual(string.Empty, planningApplication.AllDocumentLinks); }
public static async Task ExtractDocumentLinksAsync(PlanningApplication planningApplication, CQ documentSeachDoc, CancellationToken cancellationToken) { documentSeachDoc.Select(".multiFilePanelContainer").Each(fileContainer => { var fileDiv = CQ.Create(fileContainer); var docTitle = fileDiv.Select(".filePanel div").Attr("title").Clean(); var docLink = fileDiv.Select("a").Attr("href").Clean(); planningApplication.AllDocumentLinks = planningApplication.AllDocumentLinks + $"{docTitle} - http://unidoc.wiltshire.gov.uk{docLink} "; }); await Task.CompletedTask; }
public async Task <IEnumerable <PlanningApplication> > ExtractDataAsync(string searchArea, List <HttpResponseMessage> searchResultPages, CookieContainer cookieContainer, CancellationToken cancellationToken) { try { var searchResults = searchResultPages.First(); var client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer); client.DefaultRequestHeaders.Add("Referer", $"{searchResults.RequestMessage.RequestUri}"); var searchResultsHtml = await searchResults.Content.ReadAsStringAsync(); var searchPageResponseDoc = CQ.Create(searchResultsHtml); await _logger.LogInformationAsync($"Found {searchPageResponseDoc.Select("table tbody tr").Length} planning applications for {searchArea.ToUpper()}...", cancellationToken); var row = 1; searchPageResponseDoc.Select("table tbody tr").Each(tr => { var planningApplication = new PlanningApplication(); GetSeachRowDetailAsync(tr, planningApplication, cancellationToken).GetAwaiter().GetResult(); _logger.LogInformationAsync($"Getting application detail for result number {row} application reference {planningApplication.ApplicationReference} from {Environment.NewLine}{planningApplication.ApplicationLink}", cancellationToken).GetAwaiter().GetResult(); GetPlanningApplicationDetailAsync(client, planningApplication, cancellationToken).GetAwaiter().GetResult(); // can cause too much data and not really required. //GetPlanningApplicationDocumentLinksAsync(client, planningApplication, cancellationToken).GetAwaiter().GetResult(); _planningApplications.Add(planningApplication); if (_configuration.UseProxy) { // refresh client/handler to get a new IP address client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer); } row++; }); await _logger.LogInformationAsync($"Finished extracting planning data for {searchArea.ToUpper()}...", cancellationToken); client.Dispose(); return(_planningApplications); } catch (Exception ex) { throw new ExtractDataFailedException(ex.Message, ex.InnerException); } }
public void GivenAIdoxApplicationContactsResponse_CanExtractAgentEmail() { var planningApplication = new PlanningApplication(); _applicationContactsResponseDoc.Select(".agents tr").Each(row => { if ((string.IsNullOrEmpty(planningApplication.AgentEmail) || planningApplication.AgentEmail == "Not Available") && row.ChildNodes[1].InnerText.ToLower().Contains("email")) { planningApplication.AgentEmail = row.ChildNodes[3].InnerText.Clean(); } if ((string.IsNullOrEmpty(planningApplication.AgentPhoneNumber) || planningApplication.AgentEmail == "Not Available") && row.ChildNodes[1].InnerText.ToLower().Contains("phone")) { planningApplication.AgentPhoneNumber = row.ChildNodes[3].InnerText.Clean(); } }); Assert.IsNotNull(planningApplication.AgentEmail); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.AgentEmail)); }
public async Task GetPlanningApplicationDetailAsync(HttpClientWrapper client, PlanningApplication planningApplication, CancellationToken cancellationToken) { var applicationPageResponse = await client.GetAsync($"{_configuration.ApplicationPageRoute}{planningApplication.ApplicationLink}", new CancellationToken()); var applicationHtml = applicationPageResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult(); var applicationPageDoc = CsQuery.CQ.Create(applicationHtml); await ExtractPlanningApplicationData(planningApplication, applicationPageDoc); }
private static async Task ExtractApplicationSummary(CancellationToken cancellationToken, string appSummaryPath, HttpClientWrapper client, PlanningApplication planningApplication) { var applicationSummaryResponse = await client.GetAsync(appSummaryPath, cancellationToken); var applicationSummaryResponseDoc = CQ.Create(await applicationSummaryResponse.Content.ReadAsStringAsync()); applicationSummaryResponseDoc.Select("#simpleDetailsTable tr").Each(row => { if (row.ChildNodes[1].InnerText.Contains("Reference") && !row.ChildNodes[1].InnerText.Contains("Alternative Reference")) { planningApplication.ApplicationReference = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Application Validated")) { planningApplication.RegisteredDate = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Address")) { planningApplication.SiteAddress = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Proposal")) { planningApplication.Proposal = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Status") && !row.ChildNodes[1].InnerText.Contains("Appeal Status")) { planningApplication.CurrentStatus = row.ChildNodes[3].InnerText.Clean(); } }); if (string.IsNullOrEmpty(planningApplication.Proposal)) { planningApplication.Proposal = applicationSummaryResponseDoc.Select(".description").Text().Clean(); } if (string.IsNullOrEmpty(planningApplication.SiteAddress)) { planningApplication.SiteAddress = applicationSummaryResponseDoc.Select(".address").Text().Clean(); } }
private static async Task <string> ExtractApplicationDetails(CancellationToken cancellationToken, string appSummaryPath, HttpClientWrapper client, PlanningApplication planningApplication) { var appDetailsPath = appSummaryPath.Replace("activeTab=summary", "activeTab=details"); var applicationDetailsResponse = await client.GetAsync(appDetailsPath, cancellationToken); var applicationDetailsResponseDoc = CQ.Create(await applicationDetailsResponse.Content.ReadAsStringAsync()); applicationDetailsResponseDoc.Select("#applicationDetails tr").Each(row => { if (row.ChildNodes[1].InnerText.Contains("Application Type")) { planningApplication.ApplicationType = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Case Officer")) { planningApplication.CaseOfficer = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Parish")) { planningApplication.Parishes = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Ward")) { planningApplication.Wards = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Applicant Name")) { planningApplication.NameOfApplicant = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Name")) { planningApplication.AgentName = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Company Name")) { planningApplication.AgentCompanyName = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Address")) { planningApplication.AgentAddress = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Phone Number")) { planningApplication.AgentPhoneNumber = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Email")) { planningApplication.AgentEmail = row.ChildNodes[3].InnerText.Clean(); } }); return(appDetailsPath); }
private static async Task ExtractApplicationContact(CancellationToken cancellationToken, string appDetailsPath, HttpClientWrapper client, PlanningApplication planningApplication) { var appContactsPath = appDetailsPath.Replace("activeTab=details", "activeTab=contacts"); var applicationContactsResponse = await client.GetAsync(appContactsPath, cancellationToken); var applicationContactsResponseDoc = CQ.Create(await applicationContactsResponse.Content.ReadAsStringAsync()); applicationContactsResponseDoc.Select(".agents tr").Each(row => { if ((string.IsNullOrEmpty(planningApplication.AgentEmail) || planningApplication.AgentEmail == "Not Available") && row.ChildNodes[1].InnerText.ToLower().Contains("email")) { planningApplication.AgentEmail = row.ChildNodes[3].InnerText.Clean(); } if ((string.IsNullOrEmpty(planningApplication.AgentPhoneNumber) || planningApplication.AgentEmail == "Not Available") && row.ChildNodes[1].InnerText.ToLower().Contains("phone")) { planningApplication.AgentPhoneNumber = row.ChildNodes[3].InnerText.Clean(); } }); }
public async Task <IEnumerable <PlanningApplication> > ExtractDataAsync(string searchArea, List <HttpResponseMessage> searchResultPages, CookieContainer cookieContainer, CancellationToken cancellationToken) { try { var currentPage = 0; await _logger.LogInformationAsync($"Processing {searchResultPages.Count} search result pages for {searchArea.ToUpper()}", cancellationToken); var client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer); foreach (var searchResults in searchResultPages) { currentPage++; var searchResultsHtml = await searchResults.Content.ReadAsStringAsync(); var searchPageResponseDoc = CQ.Create(searchResultsHtml); var row = 0; searchPageResponseDoc.Select("table tbody tr").Each(searchRow => { row++; // Filter by proposal text containing search term. if (searchRow.ChildNodes[4].InnerText.Contains(_configuration.SearchTerm)) { var planningApplication = new PlanningApplication(); var appLink = searchRow.ChildNodes[2].ChildNodes[1].Attributes["href"]; _logger.LogInformationAsync($"Getting application detail for result number {row} application {appLink}", cancellationToken).GetAwaiter().GetResult(); var appDetailsResponse = client.GetAsync(appLink, cancellationToken).GetAwaiter().GetResult(); var content = appDetailsResponse.Content.ReadAsStringAsync().GetAwaiter().GetResult(); var appDetailsResponseDoc = CQ.Create(content); appDetailsResponseDoc.Select("#MainContent_RadPageView1 .form tr").Each(tr => { foreach (var childnodes in tr.ChildNodes) { if (childnodes.HasChildren) { foreach (var child in childnodes.ChildNodes) { if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Application No") { planningApplication.ApplicationReference = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Type") { planningApplication.ApplicationType = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Applicant") { planningApplication.NameOfApplicant = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Agent") { planningApplication.AgentName = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Case Officer") { planningApplication.CaseOfficer = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Proposal") { planningApplication.Proposal = childnodes.NextSibling.NextSibling.ChildNodes[1].TextContent.Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Received Date") { planningApplication.RegisteredDate = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } } } } }); appDetailsResponseDoc.Select("#MainContent_RadPageView2 .form tr").Each(tr => { foreach (var childnodes in tr.ChildNodes) { if (childnodes.HasChildren) { foreach (var child in childnodes.ChildNodes) { if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Address") { planningApplication.SiteAddress = childnodes.NextSibling.NextSibling.ChildNodes[1].TextContent.Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Ward") { planningApplication.Wards = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Parish") { planningApplication.Parishes = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } } } } }); _planningApplications.Add(planningApplication); if (_configuration.UseProxy) { // refresh client/handler to get a new IP address client = HttpClientHelpers.CreateClient(_configuration.BaseUri, _systemConfig, _configuration, _logger, cookieContainer); } } }); } await _logger.LogInformationAsync($"Finished extracting planning data for {searchArea.ToUpper()}...", cancellationToken); client.Dispose(); return(_planningApplications); } catch (Exception ex) { throw new ExtractDataFailedException(ex.Message, ex.InnerException); } }
public async Task GetPlanningApplicationDocumentLinksAsync(HttpClientWrapper client, PlanningApplication planningApplication, CancellationToken cancellationToken) { var documentSearchResponse = await client.GetAsync($"{planningApplication.DocumentsLink}", new CancellationToken()); var documentSearchHtml = await documentSearchResponse.Content.ReadAsStringAsync(); var documentSeachDoc = CQ.Create(documentSearchHtml); await ExtractDocumentLinksAsync(planningApplication, documentSeachDoc, cancellationToken); }
public void GivenAIdoxApplicationDetailsResponse_CanExtractApplicationDetails() { var planningApplication = new PlanningApplication(); _applicationDetailsResponseDoc.Select("#applicationDetails tr").Each(row => { if (row.ChildNodes[1].InnerText.Contains("Application Type")) { planningApplication.ApplicationType = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Case Officer")) { planningApplication.CaseOfficer = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Parish")) { planningApplication.Parishes = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Ward")) { planningApplication.Wards = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Applicant Name")) { planningApplication.NameOfApplicant = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Name")) { planningApplication.AgentName = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Company Name")) { planningApplication.AgentCompanyName = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Address")) { planningApplication.AgentAddress = row.ChildNodes[3].InnerText.Clean(); } if (row.ChildNodes[1].InnerText.Contains("Agent Phone Number")) { planningApplication.AgentPhoneNumber = row.ChildNodes[3].InnerText.Clean(); } }); Assert.IsNotNull(planningApplication.ApplicationType); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.ApplicationType)); Assert.IsNotNull(planningApplication.CaseOfficer); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.CaseOfficer)); Assert.IsNotNull(planningApplication.Parishes); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.Parishes)); Assert.IsNotNull(planningApplication.Wards); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.Wards)); Assert.IsNotNull(planningApplication.NameOfApplicant); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.NameOfApplicant)); Assert.IsNotNull(planningApplication.AgentName); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.AgentName)); Assert.IsNotNull(planningApplication.AgentCompanyName); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.AgentCompanyName)); Assert.IsNotNull(planningApplication.AgentAddress); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.AgentAddress)); Assert.IsNotNull(planningApplication.AgentPhoneNumber); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.AgentPhoneNumber)); }
public void GivenABournemouthMainDetailsPage_CanExtractDetails() { var planningApplication = new PlanningApplication(); _bournemouthMainDetailsPageDoc.Select("#MainContent_RadPageView1 .form tr").Each(tr => { foreach (var childnodes in tr.ChildNodes) { if (childnodes.HasChildren) { foreach (var child in childnodes.ChildNodes) { if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Application No") { planningApplication.ApplicationReference = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Type") { planningApplication.ApplicationType = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Applicant") { planningApplication.NameOfApplicant = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Agent") { planningApplication.AgentName = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Case Officer") { planningApplication.CaseOfficer = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Proposal") { planningApplication.Proposal = childnodes.NextSibling.NextSibling.ChildNodes[1].TextContent.Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Received Date") { planningApplication.RegisteredDate = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } } } } }); _bournemouthMainDetailsPageDoc.Select("#MainContent_RadPageView2 .form tr").Each(tr => { foreach (var childnodes in tr.ChildNodes) { if (childnodes.HasChildren) { foreach (var child in childnodes.ChildNodes) { if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Address") { planningApplication.SiteAddress = childnodes.NextSibling.NextSibling.ChildNodes[1].TextContent.Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Ward") { planningApplication.Wards = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } if (child.NodeType == NodeType.ELEMENT_NODE && child.InnerText == "Parish") { planningApplication.Parishes = childnodes.NextSibling.NextSibling.ChildNodes[1].Attributes["Value"].Clean(); break; } } } } }); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.ApplicationReference)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.AgentName)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.ApplicationType)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.ApplicationReference)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.CaseOfficer)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.NameOfApplicant)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.Proposal)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.RegisteredDate)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.SiteAddress)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.Wards)); Assert.IsFalse(string.IsNullOrEmpty(planningApplication.Parishes)); }