Example #1
0
 public static IEnumerable <TopicModel> ParseTopics(INonElementParentNode dom)
 {
     return(dom.GetElementById("Main").GetElementsByClassName("cell item").Select(node =>
     {
         var hrefs = node.QuerySelectorAll("a");
         var imgs = node.QuerySelector("img.avatar");
         var topic = new TopicModel
         {
             Title = hrefs[1].TextContent,
             NodeName = hrefs[2].TextContent,
             Member = new MemberModel
             {
                 Username = hrefs[3].TextContent,
                 Image = imgs.GetAttribute("src")
             },
             Id = int.Parse(hrefs[1].GetAttribute("href").Split('/', '#')[2])
         };
         if (hrefs.Length == 6)
         {
             topic.LastUsername = $"{hrefs[4].TextContent}";
             topic.Replies = int.Parse(hrefs[5].TextContent);
             topic.LastReply =
                 $"{node.QuerySelector("span.topic_info").TextContent.Split('•')[2].Trim()}";
         }
         return topic;
     }));
 }
Example #2
0
        private static void AssertError(INonElementParentNode responseContent, string errorMessage)
        {
            var companyNameInput = responseContent.GetElementById("CompanyName");
            var companyNameDiv   = companyNameInput.ParentElement;

            companyNameDiv.ClassName.Should().Be("govuk-form-group govuk-form-group--error");
            companyNameDiv.QuerySelector(".govuk-error-message").TextContent.Should()
            .Be(errorMessage);
        }