locked
Select Pane based on Inner Text (or other properties) RRS feed

  • Question

  • I would appreciate if someone could assist me.  Below are methods I created to create something new in our system.  After it is created, I assert that it shows in a pane on the homepage.  I then want to make sure I select the correct pane because there could be any number of them on the page.  I know the inner text but I dont know how to tell the script to select that hidden text.

    Here is my Test Method, after I assert the newly created administration is there, I want to select it.  I want to create a new method and record the selection but I dont want it to just mimic what I am doing due to how dymanic the site can be.  So when I create a new method, how would I tell it to select the pane with "innertext = 'Automation Test'"?

    [TestMethod]
            public void CreateAdministration()
            {
                this.UIMap.EnterAdminDetails();
                this.UIMap.NewAdminPageFound();
                //this.UIMap.SetOpenTime();
                this.UIMap.SetOpenTime2013();
                this.UIMap.SetCloseTime4();
                this.UIMap.SelectDefaultMessages();
                this.UIMap.SelectNoCustomQuestions();
                this.UIMap.SaveAdministration();
                this.UIMap.AssertAutomationAdministration();
            }

    Monday, December 10, 2012 4:25 PM

Answers

  • Try the UIMap.uitest editor (in VS2010+FP2 and in VS2012). Find the UIMAP entry for the pane and view its properties. There you should see the "Search Properties" field with value shown as "(collection)". Click on the ellipsis and you should see many options for adjusting the search properties, these adjustments will be saved and incorporated into the designer.cs file on each regeneration. So you should be able to enter the InnerText property that you are concerned about, plus a value and which comparator you need.

    Regards

    Adrian

    Monday, December 10, 2012 4:57 PM
  • Hi Sv_kc,

    By default, the Coded UI test builder adds innertext to the filter properties. Filter properties are used in case of ambiguity when selecting between controls with same search properties. Nevertheless, you can make innertext as search property too. You can go to the UIMap.uitest, which is a XML file containing all your methods and the controls. You can select the control you want to add innertext as search property and go it properties. Select the search properties and add the innertext as search property. If innertext is already present as filter property, you may need to delete it from filter properties and then add it to search properties. Alternatively, you can add search property as follows : UIControl.SearchProperties.Add("InnerText","abcd"); But keep in mind that making this change in UIMap.designer will be lost if the UIMap is edited in future. 

    As to your question on how to select a pane in a dynamic site, can you verify what properties in the control is changing?. If you know for sure that some of the properties like innertext, class, id or name of the control remains constant irrespective of the run, then you can search for that control easily by using the property that is constant as search property. 

    Thank you

    Bharath 


    Bharath G P MSFT

    Monday, December 10, 2012 5:29 PM

All replies

  • Try the UIMap.uitest editor (in VS2010+FP2 and in VS2012). Find the UIMAP entry for the pane and view its properties. There you should see the "Search Properties" field with value shown as "(collection)". Click on the ellipsis and you should see many options for adjusting the search properties, these adjustments will be saved and incorporated into the designer.cs file on each regeneration. So you should be able to enter the InnerText property that you are concerned about, plus a value and which comparator you need.

    Regards

    Adrian

    Monday, December 10, 2012 4:57 PM
  • Hi Sv_kc,

    By default, the Coded UI test builder adds innertext to the filter properties. Filter properties are used in case of ambiguity when selecting between controls with same search properties. Nevertheless, you can make innertext as search property too. You can go to the UIMap.uitest, which is a XML file containing all your methods and the controls. You can select the control you want to add innertext as search property and go it properties. Select the search properties and add the innertext as search property. If innertext is already present as filter property, you may need to delete it from filter properties and then add it to search properties. Alternatively, you can add search property as follows : UIControl.SearchProperties.Add("InnerText","abcd"); But keep in mind that making this change in UIMap.designer will be lost if the UIMap is edited in future. 

    As to your question on how to select a pane in a dynamic site, can you verify what properties in the control is changing?. If you know for sure that some of the properties like innertext, class, id or name of the control remains constant irrespective of the run, then you can search for that control easily by using the property that is constant as search property. 

    Thank you

    Bharath 


    Bharath G P MSFT

    Monday, December 10, 2012 5:29 PM
  • Bharath,

    Here is my function call from the designer.cs file:

    public void SelectAutomatedAdministrationMaybe()
            {
                #region Variable Declarations
                HtmlDiv uIStudentStrengthsInvePane = this.UIDashboardBeaconCampuWindow.UIDashboardBeaconCampuDocument.UIAdminstrationlistPane.UIStudentStrengthsInvePane;
                #endregion
    
                // Click 'Student Strengths Inventory' pane
                Mouse.Click(uIStudentStrengthsInvePane, new Point(256, 2));
            }

    All this is doing is selecting what I just created from the pane.  The properties of the pane itself do not change as newer ones are added but as the list grows, I need to make sure I select the correct one.  When I go to the uimap.uitest file, I dont see any properties there to edit (search properties).  If I want to maipulate this call (knowing that It will change if I change the UI map later), how would the code look? Say I want to select the pane that has "automation" in its inner text?

    Monday, December 10, 2012 6:20 PM
  • Hello SV_KC,

    According to Bharath’s reply, you can add the “InnerText” property in the UIMap.uimap XML file. You can go to the <Maps> and find the UIobject UIStudentStrengthsInvePane. Then you can find some properties under the <AndCondition Id=”SearchCondition”> and you also can add the “InnerText” property under this tag.

    Also you can add the property as a search property like UIControl.SearchProperties.Add("InnerText","abcd") in the UIStudentStrengthsInvePane class in the UIMap.Designer.cs file. Note that you need to click the “Search Criteria” and then you will see the searchproperties used to search the control.

    Best regards,


    Amanda Zhu [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.

    Tuesday, December 11, 2012 4:09 AM
    Moderator
  • When I go to the uimap.uitest file, I dont see any properties there to edit (search properties).

    The UI Map editor shows two new panels. On the left is "UI Actions" and on the right is "UI Control Map". You can open open any UI Action by left-mouse-clicking on its little triangle. As you left-mouse-click on steps within the UI Actions, the related parts of the UI Control map are revealed and highlighted. You can right-mouse-click on almost everything in the two panels and select their properties for viewing and editing. The properties of entries in the UI Control map include the "Search Properties" property.

    Regards

    Adrian

    • Edited by AdrianHHH Tuesday, December 11, 2012 9:07 AM
    Tuesday, December 11, 2012 9:05 AM
  • Hello SV_KC,

    Have you resolved this issue? Could you get useful information from those replies?

    If you have resolved it, please mark the helpful reply as answer.

    If not, please let us know the latest news about this issue and the result of our suggestion.

    Best regards,


    Amanda Zhu [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.

    Wednesday, December 12, 2012 8:30 AM
    Moderator