开发者

Testing paging with Telerik's WebAii framework

开发者 https://www.devze.com 2023-03-14 20:18 出处:网络
I need to find every HtmlAnchor inside a Span with a specific id: <span id=\"ctl05_dpInci开发者_开发知识库dentFailures\">

I need to find every HtmlAnchor inside a Span with a specific id:

<span id="ctl05_dpInci开发者_开发知识库dentFailures">
<span>1</span> // page 1
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=2">2</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=3">3</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=4">4</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=5">5</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=6">6</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=7">7</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=8">8</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=9">9</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=10">10</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=11">11</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=12">12</a>
    <a href="/DesktopDefault.aspx?ptabindex=7&ptabid=31&tabindex=14&tabid=214&pageid=13">13</a>
</span>

How could I do this using WebAii? This is what I have tried up to now:

IList<Element> allbtns = Find.AllByAttributes("href=~pageid"); // not working

var _pagingList = Find.ById<HtmlSpan>("~dpIncidentFailures"); // not working either


I have solved my issue:

    [TestMethod]
    public void TestPagingCauseFailure()
    {
        // act
        OpenPage(true);

        // get the hidden fields on this page
        IList<HtmlInputHidden> _hiddenFieldsList = Find.AllByAttributes<HtmlInputHidden>("~hfFailureID");

        IList<HtmlAnchor> _pageIndexes = Find.AllByAttributes<HtmlAnchor>("href=~pageid");

        // there are 12 pages (not including page 1)
        Assert.IsTrue(Equals(12,_pageIndexes.Count));

        // goto last page
        _pageIndexes.Last().Click();

        //get the hidden fields on this page
        IList<HtmlInputHidden> _hiddenFieldsList2 = Find.AllByAttributes<HtmlInputHidden>("~hfFailureID");

        string value1 = _hiddenFieldsList.Last().ID;
        string value2 = _hiddenFieldsList2.Last().ID;

        //compare the two last items in boths lists
        Assert.IsFalse(Equals(value1, value2));

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号