locked
Scanning page for coded ui RRS feed

  • Question

  • Hi,

    I'm building a robot for testing my website, i want to build some generic tests for ewample testing a form. What i want to do is :

    Robot scan the page, find every textBox/links ..., click on each one and go back to my homepage

    I actually now how to build a test with the generator, but i have to do a test for each form and i got a lot !

    sorry for my english, i'm french ...

    Thanks

    • Moved by Youen Zen Friday, May 3, 2013 5:28 AM From Visual Basic
    Thursday, May 2, 2013 9:29 AM

Answers

  • Having got the UITestControl object for the browser or the webpage, you can try a recursive traversal of the whole page with code based on:

    void TraverseUIControls(UITestControl parent)
    {
        ... // Process this control
        UITestControlCollection children = parent.GetChildren();
        foreach ( UITestControl child in children ) {
            TraverseUIControls(child);
        }
    }

    You can then examine the various properties of each control to determine what, if any, action is needed.

    In my experience this kind of traversal can be very slow, so do not expect the test to run quickly.

    Regards

    Adrian

    Friday, May 3, 2013 9:17 AM

All replies

  • On 5/2/2013 5:29 AM, jocelynIsi wrote:

    <snipped>
     You don't test a page or form directly. You unit test/integration test the MVC, MVP or MVVM, which are UI design patterns and the middle-men for the UI. The form or page should be kept as dumb as possible with very little or no code in it with separation of concerns.
     <http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller>
    <http://en.wikipedia.org/wiki/Model-view-presenter>
    <http://en.wikipedia.org/wiki/Model_View_ViewModel>

    Thursday, May 2, 2013 11:11 AM
  • Hi,

    The coded UI tests provide functional testing of the user interface and validation of user interface controls. If you want to create the coded UI test, please see “How to: Create a Coded UI Test”.

    In addition, if you want to create a coded UI test for different forums, as my understanding, it will hard to achieve it, since different forums will have different controls, every control will have different properties, the coded UI test builder will record the action you run in your UI, so if we change the UI, it will be failed when we run it.

    So my suggestion is that you could create a Coded UI test project, but you could create different test methods for different forms in different project. Hope it could help. But if you want to test the same App UI with different data, you might want to run your coded UI test multiple times with different sets of data to test different conditions. To do this you can add parameter values from a data source to create a data-driven coded UI test. Reference: How to: Create a Data-Driven Coded UI Test.

    Have a nice weekend,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, May 3, 2013 8:51 AM
  • Having got the UITestControl object for the browser or the webpage, you can try a recursive traversal of the whole page with code based on:

    void TraverseUIControls(UITestControl parent)
    {
        ... // Process this control
        UITestControlCollection children = parent.GetChildren();
        foreach ( UITestControl child in children ) {
            TraverseUIControls(child);
        }
    }

    You can then examine the various properties of each control to determine what, if any, action is needed.

    In my experience this kind of traversal can be very slow, so do not expect the test to run quickly.

    Regards

    Adrian

    Friday, May 3, 2013 9:17 AM