This is a migrated thread and some comments may be shown as answers.

Order of elements

1 Answer 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sandeep Endapally
Top achievements
Rank 1
Sandeep Endapally asked on 03 Sep 2009, 07:49 PM

Is there is any way to test the order of elements on a web page. I mean, if the developer changes the order of elements

on a webpage and runs the previous created test script, it should fail. Is that possible?

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 04 Sep 2009, 04:46 PM
Hello Sandeep Endapally,

Yes there are a couple of methods you can use to verify the order of elements. The quick method would be to select the element and craft a verification step that would verify the InnerMarkup or the InnerText equals a specific value. For example, if you have a UL element that contains a number of LI elements, you would locate the UL element in DOM explorer, right click on it and select Record Options, select Verification, then constuct a verification of the InnerText or the InnerMarkup is exact to some value.

The other method is to add a code behind method that does something like this:

[CodedStep(@"Verify 'InnerMarkup' 'Exact' '<LI class=chooseSample jQuery1252081125277=\7\>Choose sample</LI><LI class=active jQuery1252081125277=\8\><A id=demo1 href=\#\ jQuery1252081125277=\2\>Editor with all features</A></LI><LI jQuery1252081125277=\9\><A id=demo_uicolor href=\#\ jQuery1252081125277=\3\>Interface color</A></LI><LI jQuery1252081125277=\10\><A id=demo2 href=\#\ jQuery1252081125277=\4\>Multi-language interface</A></LI><LI jQuery1252081125277=\11\><A id=demo3 href=\#\ jQuery1252081125277=\5\>Custom toolbar</A></LI><LI jQuery1252081125277=\12\><A id=demo4 href=\#\ jQuery1252081125277=\6\>Skins</A><!--            <li class=\moreSamples\><a href=\#\>More samples</a></li>  --></LI>' on 'ul_1'")]  
public void webaiitest1_CodedStep()  
{  
 
    // Verify 'InnerMarkup' 'Exact' '<LI class=chooseSample jQuery1252081125277="7">Choose sample</LI><LI class=active jQuery1252081125277="8"><A id=demo1 href="#" jQuery1252081125277="2">Editor with all features</A></LI><LI jQuery1252081125277="9"><A id=demo_uicolor href="#" jQuery1252081125277="3">Interface color</A></LI><LI jQuery1252081125277="10"><A id=demo2 href="#" jQuery1252081125277="4">Multi-language interface</A></LI><LI jQuery1252081125277="11"><A id=demo3 href="#" jQuery1252081125277="5">Custom toolbar</A></LI><LI jQuery1252081125277="12"><A id=demo4 href="#" jQuery1252081125277="6">Skins</A><!--            <li class="moreSamples"><a href="#">More samples</a></li>  --></LI>' on 'ul_1'  
    HtmlControl ul_1 = Pages.Demo__CKEditor.ul_1;  
    ul_1.Wait.ForExists(10000);  
    Assert.AreEqual(7, ul_1.BaseElement.ChildNodes.Count, "Selection menu count is incorrect");  
    Assert.AreEqual("Choose sample", ul_1.BaseElement.ChildNodes[0].InnerText);  
    Assert.AreEqual("Editor with all features", ul_1.BaseElement.ChildNodes[1].InnerText);  
    Assert.AreEqual("Interface color", ul_1.BaseElement.ChildNodes[2].InnerText);  
    Assert.AreEqual("Multi-language interface", ul_1.BaseElement.ChildNodes[3].InnerText);  
    Assert.AreEqual("Custom toolbar", ul_1.BaseElement.ChildNodes[4].InnerText);  
    Assert.AreEqual("Skins", ul_1.BaseElement.ChildNodes[5].InnerText);  
    Assert.AreEqual("", ul_1.BaseElement.ChildNodes[6].InnerMarkup);  
}

If you still need assistance, I need more details of what/where exactly you'd like to verify the order of something, along with sample HTML code to study. Then I can give you better assistance for your speciric test case.

Best wishes,
Cody
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Sandeep Endapally
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or