Esempio n. 1
0
        public void GetHtmlDiv_ByClass_Succeeds()
        {
            // Arrange
            using (var tempFile = new TempFile(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""button""><a href=""/main"">main text</a></div>
        <div class=""button""><a href=""/about"">about text</a></div>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                // Act
                EnhancedHtmlDiv div = window.Get <EnhancedHtmlDiv>("class=button");

                EnhancedHtmlHyperlink about = window.Get <EnhancedHtmlHyperlink>("InnerText=about text;href~about");
                var div2 = about.Parent as EnhancedHtmlDiv;

                // Assert
                Assert.IsTrue(div.Exists);
                Assert.AreEqual("main text", div.UnWrap().InnerText);

                Assert.IsTrue(about.Exists);

                Assert.IsTrue(div2.Exists);
                Assert.AreEqual("about text", div2.UnWrap().InnerText);

                window.Close();
            }
        }
Esempio n. 2
0
        public void Launch_TempHtmlFile_CanFindHyperlinkByHref()
        {
            // Arrange
            using (var tempFile = new TempFile(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""login"" style=""border: none;"">
        <div class=""member_box"">
            <span>APPLY FOR MEMBERSHIP</span> <a href=""/registration""> </a>
        </div>
    </body>
</html>"))
            {
                // Act
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                // Assert
                EnhancedHtmlHyperlink SignUpHyperLink = window.Get <EnhancedHtmlHyperlink>("href~registration");
                Assert.IsTrue(SignUpHyperLink.Exists, "SignUp not found");

                window.Close();
            }
        }