locked
Create Dynamic control RRS feed

  • Question

  • Is there a way to create a dynamic control.
    example:

    i have this web page in which items are organized in a list. this list changes from time to time.
    i can know the items in the list, before i run the test.

    i want to create a test to run over this list, and click on every single item in the list.
    items are recognised as HtmlCell. they differ from each other with their inner text.

    in order to click on the items, i need to pull the inner text ( from excel), and then create a new HtmlCell, define it's inner text attribute, and then do:
    click ( myHtmlCell)

    is there a way to do that? or a way to create my own control map on the fly?

    Thanks.
    Thursday, December 3, 2009 4:13 PM

Answers

  • Hi,

    There are two ways you can achieve this

    1) I think this is a table <td> ? Is yes you can do calls .Cells Properties on the table control which will return all the cells. Then you can filter out on which you want to click.
    2) Have a CSV or excel which has InnerText. Now under the table mentioned above you can search for the cell with the InnerText

    Something like

    // Populate the list from the CSV/excel file
    foreach(string innerText in list)
    {
       HTMLCell myCell = new HTMLCell(table)
       myCell.SearchProperties.Add("InnerText", innerText);
       Mouse.Click(myCell);
    }

    Hope this helps

    Thanks
    Siddhartha
    Thursday, December 3, 2009 4:25 PM
    Moderator

All replies

  • Hi,

    There are two ways you can achieve this

    1) I think this is a table <td> ? Is yes you can do calls .Cells Properties on the table control which will return all the cells. Then you can filter out on which you want to click.
    2) Have a CSV or excel which has InnerText. Now under the table mentioned above you can search for the cell with the InnerText

    Something like

    // Populate the list from the CSV/excel file
    foreach(string innerText in list)
    {
       HTMLCell myCell = new HTMLCell(table)
       myCell.SearchProperties.Add("InnerText", innerText);
       Mouse.Click(myCell);
    }

    Hope this helps

    Thanks
    Siddhartha
    Thursday, December 3, 2009 4:25 PM
    Moderator
  • and then i guess, put in the UI.map, right?
    Sunday, December 6, 2009 3:44 PM
  • Hi,

    Yes anything you manually write should go into UIMap.cs file. UiMap.Designer.cs is autogenerated hence any changes manually done on that will be over written.

    Thanks
    Siddhartha
    Sunday, December 6, 2009 6:22 PM
    Moderator