private static void GetAgencyOfficeLocation(ref AgencyOfficeLocation agencyOfficeLocation, IWebElement item) { var text = item.Text.Split("\r\n"); agencyOfficeLocation.Agency = text[0]; if (text.Length == 2) { agencyOfficeLocation.Office = text[1]; } if (text.Length == 3) { agencyOfficeLocation.Location = text[2]; } }
public Post GetPost(int j) { var columns = _driver .FindElement(By.ClassName("solr-lst")) .FindElement(By.ClassName("list")) .FindElement(By.Id($"row_{j}")) .FindElements(By.TagName("td")); var post = new Post(); var opportunity = new Opportunity(); var agencyOfficeLocation = new AgencyOfficeLocation(); foreach (var item in columns) { switch (item.GetAttribute("headers")) { case "lh_id": GetOpportunity(ref opportunity, item); break; case "lh_agency_name": GetAgencyOfficeLocation(ref agencyOfficeLocation, item); break; case "lh_base_type": post.Type = item.Text; break; case "lh_current_posted_date": post.PostedDate = Convert.ToDateTime(item.Text); break; } } post.Opportunity = opportunity; post.AgencyOfficeLocation = agencyOfficeLocation; return(post); }