Locked How to link the XML data attribute using Coded UI?

  • lunedì 12 marzo 2012 06:25
     
      Contiene codice

    I have a graphics application to draw different shapes. Drawing each shape is a Test Method in Coded UI. I am coverting these tests to data-driven using the XML data provided below..

    <?xml version="1.0" encoding="UTF-8" ?> 
    - <TestData>
    - <TestSuite>
    - <TestGroup Name="RectangularShapeObjectsDraw">
    - <TestCase ID="001">
      <Name>DrawRectangle</Name> 
      <X>200</X> 
      <Y>300</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="001">
      <Name>DrawRectangle</Name> 
      <X>200</X> 
      <Y>300</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="002">
      <Name>DrawEllipse</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="003">
      <Name>DrawButton</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="004">
      <Name>DrawCheckBox</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="005">
      <Name>DrawImage</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="006">
      <Name>DrawProgressBarButton</Name
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="007">
      <Name>DrawRadioButton</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="008">
      <Name>DrawRepeatButton</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="009">
      <Name>DrawSlider</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="010">
      <Name>DrawTextBlock</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="011">
      <Name>DrawTextBox</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
    - <TestCase ID="012">
      <Name>DrawToggleButton</Name> 
      <X>120</X> 
      <Y>200</Y> 
      <Width>50</Width> 
      <Height>20</Height> 
      </TestCase>
      </TestGroup>
      </TestSuite>
      </TestData>

    And I have a Test Method as below to draw the Rectangle

    [TestMethod]
            public void DrawRectangle()
            {
    Rectangle rectBtnLocation = new Rectangle(X, Y, Width, Height);
                this.MainWindow.DrawAndVerifyShapeRectangularObject(this.MainWindow.UIMap.UIOneGraphicWindow.UIItemMenu.UIRectangleToggleButton, rectBtnLocation);
            }

    I can attach the xml file table as a data connection string to this TestMethod.

    But I need to know how can i access and map the Rectangle Test Data alone to the method using this given example.


    Nanda


    • Modificato KB Nanda lunedì 12 marzo 2012 06:26
    •  

Tutte le risposte

  • martedì 13 marzo 2012 11:14
    Moderatore
     
     Con risposta

    Hi Nanda,

    The data-driven Coded UI Test will iterated your data source line by line or randomly, as what I see from your requirement you just want to read X, Y, Width, Height from XML file as parameters for your constructor.

    Due to that reason the Coded UI data-driven Test is not suitable for this issue, you could load your xml file into test by a normal way not using connect string of Coded UI Test. For more support you could go to XML develop forum.


    Tony Xiao [MSFT]
    MSDN Community Support | Feedback to us

    • Contrassegnato come risposta KB Nanda martedì 13 marzo 2012 12:15
    •  
  • martedì 13 marzo 2012 12:15
     
     

    Hi Tony,

    Thanks for your response.

    I understood the limitation in Coded UI and it's suitability. I decided to change either the input XML structure suitable for sequential access or try parsing the same XML file programatically in a normal way...


    Nanda