5 Replies Latest reply on Dec 13, 2011 10:25 AM by Gregory Lafrance

    How to use the automationName in Silk tests for Flex apps?

    Gregory Lafrance Level 6

      We're using Silk to test our Flex app, but for some reason ids and automationName property values added in ActionScript cannot be detected by Silk.

       

      I thought the automationName property was a way to guarantee access to Flex sub-components in Silk (or other automation frameworks), but in Flex we often add components in ActionScript, so how can I do this.

       

      So in the app below, S

       

      ilk does not seem to be able to detect the Buttons added via ActionScript, unless I look for the Button label, seen as the "caption" in Silk. I have some scenarios where I don't want to do this, so please help.

       

      This web page discusses using automationName property, but in my app it does not work.

       

      http://community.microfocus.com/blogs/29_Silk/65_How_to_Improve_the_Testability_of_Your_Ap plications_Using_SilkTest

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
          creationComplete="init();" layout="vertical" horizontalAlign="center">
          <mx:Script>
              <![CDATA[
                  private function init():void{
                      var i:int;
                      for(i=0; i<buttonsAC1.length; i++) {
                          var buttonObj1:Object = buttonsAC1.getItemAt(i);
                          var acButton1:Button = new Button();
                          acButton1.label = buttonObj1.name;
                          acButton1.id = buttonObj1.id;
                          acButton1.automationName = buttonObj1.id; 
                          hb.addChild(acButton1);
                      }
                      for(i=0; i<buttonsAC2.length; i++) {
                          var buttonObj2:Object = buttonsAC2.getItemAt(i);
                          var acButton2:Button = new Button();
                          acButton2.label = buttonObj2.name;
                          acButton2.automationName = buttonObj2.id; 
                          hb.addChild(acButton2);
                      }
                  }
              ]]>
          </mx:Script>
          <mx:ArrayCollection id="buttonsAC1">
              <mx:Object name="AS Button1" id="as_button1"/>
              <mx:Object name="AS Button2" id="as_button2"/>
              <mx:Object name="AS Button3" id="as_button3"/>
          </mx:ArrayCollection>
          <mx:ArrayCollection id="buttonsAC2">
              <mx:Object name="No ID AS Button1" id="no_id_as_button1"/>
              <mx:Object name="No ID AS Button2" id="no_id_as_button2"/>
              <mx:Object name="No ID AS Button3" id="no_id_as_button3"/>
          </mx:ArrayCollection>
          <mx:HBox id="hb">
              <mx:Button label="MX Button1" automationName="mx_button1"/>
              <mx:Button label="MX Button2" automationName="mx_button2"/>
              <mx:Button label="MX Button3" automationName="mx_button3"/>
          </mx:HBox>
          <mx:TextArea width="65%" height="100%">
              <mx:htmlText>
                  <![CDATA[The goal of this app is to see if you can access the Button automationName property values in Silk tests via the Silk "caption" property.<br /><br />First, try to access all the buttons like this (you know Silk, I don't, so syntax may be different):<br /><br />…//FlexApplication//FlexButton[@caption='mx_button1']<br /><br />…//FlexApplication//FlexButton[@caption='mx_button2']<br /><br />…//FlexApplication//FlexButton[@caption='mx_button3']<br /><br />…//FlexApplication//FlexButton[@caption='as_button1']<br /><br />…//FlexApplication//FlexButton[@caption='as_button2']<br /><br />…//FlexApplication//FlexButton[@caption='as_button3']<br /><br />…//FlexApplication//FlexButton[@caption='no_id_as_button1']<br /><br />…//FlexApplication//FlexButton[@caption='no_id_as_button2']<br /><br />…//FlexApplication//FlexButton[@caption='no_id_as_button3'<br /><br />These various buttons allow us to check the following:<br /><br /><ul><li>Is automationName property only visible to Silk if defined in MXML?</li><li>Is automationName property hidden if the component added via ActionScript has an ID property set?</li></ul><br /><br />You should be able to see all these buttons in silk by accessing the automationName property via the Silk caption property.<br /><br />Refer to this web page for more info:<br /><br /><a href="http://community.microfocus.com/blogs/29_Silk/65_How_to_Improve_the_Testability_of_Your_Applications_Using_SilkTest"><font color="#0000FF">http://community.microfocus.com/blogs/29_Silk/65_How_to_Improve_the_Testability_of_Your_Applications_Using_SilkTest"</font></a>]]>
              </mx:htmlText>
          </mx:TextArea>
      </mx:Application>