当前位置: 首页>>代码示例>>C#>>正文


C# WebPage.Get方法代码示例

本文整理汇总了C#中WebPage.Get方法的典型用法代码示例。如果您正苦于以下问题:C# WebPage.Get方法的具体用法?C# WebPage.Get怎么用?C# WebPage.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebPage的用法示例。


在下文中一共展示了WebPage.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetChildren_UsingHyperlinks_CanFindHyperlinkByInnerText

        public void GetChildren_UsingHyperlinks_CanFindHyperlinkByInnerText()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div id=""div1"">
            <a href=""#"">A - B - C</a>
            <a href=""#"">A - F - E</a>
            <a href=""#"">A - D - E</a>
            <a href=""#"">Z - B - C</a>
            <a href=""#"">Z - D - E</a>
        </div>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                //Act
                var collection = window.Get<EnhancedHtmlDiv>("id=div1").GetChildren();
                foreach (var control in collection)
                {
                    if (control is EnhancedHtmlHyperlink)
                    {
                        var link = (EnhancedHtmlHyperlink) control;
                        if (link.InnerText.StartsWith("A"))
                        {
                            Trace.WriteLine(string.Format("found: {0}", link.InnerText));
                        }
                    }
                }

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:39,代码来源:HtmlControlTests.cs

示例2: HtmlHyperlink_OnSharePoint2010_Succeeds

 public void HtmlHyperlink_OnSharePoint2010_Succeeds()
 {
     WebPage.Launch("http://myasia/sites/sureba/Default.aspx");
     WebPage.Authenticate("username", "passwd");
     var bWin = new WebPage("Suresh Balasubramanian");
     bWin.Get<EnhancedHtmlHyperlink>("Id=idHomePageNewDocument").Click();
     var closeLink = bWin.Get<EnhancedHtmlHyperlink>("Title=Close;class=ms-dlgCloseBtn");
     //clicking closeLink directly doesn't work as the maximizeLink is clicked due to the controls being placed too close to each other
     Mouse.Click(closeLink.UnWrap().GetChildren()[0].GetChildren()[0]);
     bWin.RunScript(@"STSNavigate2(event,'/sites/sureba/_layouts/SignOut.aspx');");
 }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:11,代码来源:HtmlControlTests.cs

示例3: Click_OnHtmlInputButtonWithEqualsSignInSearchParameterValue_Succeeds

        public void Click_OnHtmlInputButtonWithEqualsSignInSearchParameterValue_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <input type=""submit"" value=""="" onclick=""alert('onclick');""/>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlInputButton button = window.Get<EnhancedHtmlInputButton>("Value==");

                //Act
                button.Click();

                window.PerformDialogAction(BrowserDialogAction.Ok);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:26,代码来源:HtmlControlTests.cs

示例4: LabelFor_OnHtmlLabel_Succeeds

        public void LabelFor_OnHtmlLabel_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <form>
          <label for=""male"">Male</label>
          <input type=""radio"" name=""sex"" id=""male"" value=""male""><br>
          <label for=""female"">Female</label>
          <input type=""radio"" name=""sex"" id=""female"" value=""female""><br>
          <label id=""other"" for=""other"">Other</label>
          <input type=""radio"" name=""sex"" id=""other"" value=""other""><br>
          <input type=""submit"" value=""Submit"">
        </form> 
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlLabel label = window.Get<EnhancedHtmlLabel>("id=other");

                //Assert
                Assert.AreEqual("other", label.LabelFor);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:32,代码来源:HtmlControlTests.cs

示例5: SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds

        public void SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <select id=""selectId"" onchange=""alert('onchange');"">
            <option>Apple</option>
            <option>Banana</option>
            <option>Carrot</option>
        </select>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlComboBox comboBox = window.Get<EnhancedHtmlComboBox>("Id=selectId");

                //Act
                comboBox.SelectItem("Banana");

                window.PerformDialogAction(BrowserDialogAction.Ok);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:30,代码来源:HtmlControlTests.cs

示例6: SetText_OnHtmlEditWithOverlappedDiv_Succeeds

        public void SetText_OnHtmlEditWithOverlappedDiv_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""textbox"" id=""idDiv_PWD_UsernameTb"" style=""margin-bottom: 8px;"">
            <div style=""width: 100%; position: relative;"">
                <input name=""login"" id=""i0116"" style=""ime-mode: inactive;"" type=""email"" maxLength=""113""/>
                <div class=""phholder"" style=""left: 0px; top: 0px; width: 100%; position: absolute; z-index: 5;"">
                    <div class=""placeholder"" id=""idDiv_PWD_UsernameExample"" style=""cursor: text;"">
                    Text - [email protected]
                    </div>
                </div>
            </div>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var bWin = new WebPage("test");
                EnhancedHtmlEdit txtUserName = bWin.Get<EnhancedHtmlEdit>("id=i0116");

                //Act
                txtUserName.SetText("hello");

                //Assert
                Assert.AreEqual("hello", txtUserName.GetText());

                bWin.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:34,代码来源:HtmlControlTests.cs

示例7: HtmlTable_GetColumnHeaders_Succeeds

 public void HtmlTable_GetColumnHeaders_Succeeds()
 {
     WebPage.Launch(CurrentDirectory + "/TestHtmlPage.html");
     var bWin = new WebPage("A Test");
     EnhancedHtmlTable tbl = bWin.Get<EnhancedHtmlTable>("id=calcWithHeaders");
     var saExpectedValues = new[] {"Header1", "Header2", "Header3"};
     string[] saHeaders = tbl.GetColumnHeaders();
     Assert.AreEqual(saExpectedValues[0], saHeaders[0]);
     Assert.AreEqual(saExpectedValues[1], saHeaders[1]);
     Assert.AreEqual(saExpectedValues[2], saHeaders[2]);
     bWin.Close();
 }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:12,代码来源:HtmlControlTests.cs

示例8: HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle

        public void HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <button id=""buttonId"" style=""display: none;"" >Hidden</button>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                //Act
                EnhancedHtmlButton button = window.Get<EnhancedHtmlButton>("id=buttonId");

                //Assert
                Assert.IsTrue(button.Exists);

                Assert.IsTrue(button.UnWrap().ControlDefinition.Contains("style=\"display: none;\""));

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:27,代码来源:HtmlControlTests.cs

示例9: GetHtmlDiv_ByClass_Succeeds

        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();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:35,代码来源:HtmlControlTests.cs

示例10: GetHtmlRow_ById_Succeeds

        public void GetHtmlRow_ById_Succeeds()
        {
            // Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table class=""cart"" cellspacing=""0"">
          <tbody>
            <tr id=""555002_gp2"">
                <td>
                    banana
                </td>
            </tr>
          </tbody>
        </table>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                // Act
                EnhancedHtmlRow row = window.Get<EnhancedHtmlRow>("id=555002_gp2");

                // Assert
                Assert.IsTrue(row.Exists);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:33,代码来源:HtmlControlTests.cs

示例11: Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength

        public void Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength()
        {
            // Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <input id=""input"" type=""text"" maxlength=10 />
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlEdit input = window.Get<EnhancedHtmlEdit>("id=input");

                // Act
                string inputText = "12345678901";
                string outputText = "1234567890";
                Keyboard.SendKeys(input.UnWrap(), inputText);

                // Assert
                Assert.AreEqual(input.GetText(), outputText);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:29,代码来源:HtmlControlTests.cs

示例12: Launch_TempHtmlFile_CanFindHyperlinkByHref

        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();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:27,代码来源:HtmlControlTests.cs

示例13: Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle

        public void Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test 1 2 3</title>
    </head>
    <body>
        <button id=""buttonId"" >Button</button>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                //Act
                EnhancedHtmlButton button = window.Get<EnhancedHtmlButton>("id=buttonId");

                //Assert
                Assert.AreEqual(button.InnerText, "Button");

                Trace.WriteLine(window.Uri.ToString());

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:27,代码来源:HtmlControlTests.cs

示例14: SelectItem_ByIndexOnHtmlComboBox_Succeeds

        public void SelectItem_ByIndexOnHtmlComboBox_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <select id=""selectId"">
            <option>Cricket</option>
            <option>Football</option>
            <option>Tennis</option>
        </select>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                //Act
                EnhancedHtmlComboBox comboBox = window.Get<EnhancedHtmlComboBox>("Id=selectId");

                comboBox.SelectItem(1);

                //Assert
                Assert.AreEqual("Football", comboBox.SelectedItem);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:31,代码来源:HtmlControlTests.cs

示例15: HtmlTable_FindHeaderAndClick_Succeeds

        public void HtmlTable_FindHeaderAndClick_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <table style=""width: 100%;"" id=""tableId"">
            <tbody>
                <tr>
                    <td>Commitment</td>
                    <th>September</th>
                    <th>October</th>
                    <th>November</th>
                    <td>Total</td>
                </tr>
                <tr>
                    <td>Beginning Balance</td>
                    <td>¥21,570,253</td>
                    <td>¥21,375,491</td>
                    <td>¥21,200,873</td>
                    <td></td>
                </tr>
                <tr>
                    <td>New Purchases</td>
                    <td>¥0</td>
                    <td>¥0</td>
                    <td>¥0</td>
                    <td></td>
                </tr>
                <tr>
                    <td>Utilized</td>
                    <td>¥194,762</td>
                    <td>¥174,618</td>
                    <td>¥0</td>
                    <td>¥369,380</td>
                </tr>
                <tr>
                    <td>Ending Balance</td>
                    <td>¥21,375,491</td>
                    <td>¥21,200,873</td>
                    <td>¥21,200,873</td>
                    <td></td>
                </tr>
                <tr>
                    <td><b>Overage</b></td> 
                    <td>¥0</td>
                    <td>¥0</td>
                    <td>¥0</td>
                    <td>¥0</td>
                    <td></td>
                </tr>
                <tr>
                    <td><b>Total Usage</b></td>
                    <td>¥194,762</td>
                    <td>¥174,618</td>
                    <td>¥0</td>
                    <td>¥369,380</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlTable table = window.Get<EnhancedHtmlTable>("id=tableId");

                //Act
                table.FindHeaderAndClick(0, 2);

                window.Close();
            }
        }
开发者ID:HighwayFramework,项目名称:Highway.Insurance,代码行数:77,代码来源:HtmlControlTests.cs


注:本文中的WebPage.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。