0 Replies Latest reply on Jun 14, 2010 2:22 AM by pgpradeep

    Automation playback for tree

    pgpradeep Level 1

      Hi,

       

      I am writing a custom testing agent for recording and playback.

      When I run the code for tree open and select, firstly I am getting multiple matches for the itemRenderer, and secondly, I am forced to execute the code twice to open and select the tree. Can someone help me resolve this issue.

      For tree component, my  code is :

       

      switch

       

      (action)

      {

       

      case "select":

      eventClassName =

      "mx.automation.events.ListItemSelectEvent";

      eventType = ListItemSelectEvent.SELECT;

      //"select"

       

       

      break;

       

      case "open":

      eventClassName =

      "mx.events.TreeEvent";

      eventType = TreeEvent.ITEM_OPEN;

      //"itemOpen"

       

       

      break;

      }

       

      var eventClass:Class ;

      eventClass = Class(ApplicationDomain.currentDomain.getDefinition(eventClassName));

       

      var

       

      classEvent:Event;

      classEvent= new eventClass(eventType));

       

      switch

       

      (action)

      {

       

      case "select":

       

      var aObjectControl:IAutomationObject = autmObject;

       

      var part:AutomationIDPart = new AutomationIDPart();

       

      var text:String = args[0].toString();

      part.automationName = text;

       

       

      var aObjectArray:Array = automationManager.resolveIDPart(aObjectControl, part);//returning multiple selections for one renderer

       

      var delegate:IAutomationObject = (aObjectArray[0] as IAutomationObject);

       

      if (delegate)

      classEvent[

      "itemRenderer"] = delegate;

       

      else

      classEvent[

      "itemRenderer"] = aObjectArray[0];

       

       

      var value:int = 1;

       

      if(args[1] != null)

      {

      value = parseInt(args[1].toString());

      }

      classEvent[

      "triggerEvent"] = (value == 1 ? new MouseEvent(MouseEvent.CLICK) :

      value == 2 ?

      new KeyboardEvent(KeyboardEvent.KEY_UP) : null);

      value = 0;

       

      if(args[2] != null)

      {

      value = parseInt(args[2].toString());

      }

      classEvent[

      "ctrlKey"] = (uint(value) & (1 << 0)) != 0;

      classEvent[

      "shiftKey"] = (uint(value) & (1 << 1)) != 0;

      classEvent[

      "altKey"] = (uint(value) & (1 << 2)) != 0;

       

      break;

       

      case "open":

       

      var aObjectControl:IAutomationObject = autmObject;

       

       

      var part:AutomationIDPart = new AutomationIDPart();

       

      var text:String = args[0].toString();

      part.automationName = text;

       

       

      var aObjectArray:Array = automationManager.resolveIDPart(aObjectControl, part);

       

      var delegate:IAutomationObject = (aObjectArray[0] as IAutomationObject);

       

      if (delegate)

      classEvent[

      "itemRenderer"] = delegate;

       

      else

      classEvent[

      "itemRenderer"] = aObjectArray[0];

      classEvent[

      "triggerEvent"] = new MouseEvent(MouseEvent.CLICK);

       

      var value:int = 1;

       

      if(args[1] != null)

      {

      value = parseInt(args[1].toString());

      }

      classEvent[

      "triggerEvent"] = (value == 1 ? new MouseEvent(MouseEvent.CLICK) :

      value == 2 ?

      new KeyboardEvent(KeyboardEvent.KEY_UP) : null);

       

      break;

      }

       

      var

       

      aEvent:AutomationReplayEvent = new AutomationReplayEvent();

      aEvent.automationObject = automationObject;

      aEvent.replayableEvent = classEvent;

       

      return Automation.automationManager.replayAutomatableEvent(aEvent);

       

       

      Thanks,Oradeep.