Exemple #1
0
        public Step(WatiN.Core.IE ie, awaDAL.DAL dal, int step_id)
        {
            if (step_id != -1)
            {
                Conditions = new ConditionCollection();
                ICondition newCondition = null;
                var        conditions   = dal.DB.condition.Where(row => row.step_id == step_id);
                foreach (var condition in conditions)
                {
                    if (condition.op.ToLower() == "none")
                    {
                        continue;
                    }

                    var condElm = dal.DB.element.SingleOrDefault(row => row.id == condition.lhs_element_id);
                    var auxElm  = dal.DB.element.SingleOrDefault(row => row.id == condition.rhs_element_id);
                    switch (ConditionBase.ConditionTypeEnum[condition.op])
                    {
                    case ConditionBase.ConditionType.CONTAINS:
                        newCondition = new ContainsCondition(condition.lhs_element_attr, dal, ie);
                        break;

                    case ConditionBase.ConditionType.EQUAL:
                        EqualityCondition.ComparisonAttribute cmpAttr = EqualityCondition.ComparisonAttribute.INNERTEXT;
                        if (condition.lhs_element_attr.ToLower() == "value")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.VALUE;
                        }
                        else
                        if (condition.lhs_element_attr.ToLower() == "class")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.CLASS;
                        }
                        else
                        if (condition.lhs_element_attr.ToLower() == "innerhtml")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.INNERHTML;
                        }
                        else
                        if (condition.lhs_element_attr.ToLower() == "name")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.NAME;
                        }
                        EqualityCondition eqCond = new EqualityCondition(cmpAttr, dal, ie);

                        eqCond.ConditionElement = new SiteObject(condElm.websiteRow.name, condElm.name);
                        newCondition            = eqCond;
                        break;

                    case ConditionBase.ConditionType.FALSE:
                        newCondition = new FalseCondition();
                        break;

                    case ConditionBase.ConditionType.NOT_EQUAL:
                        NotEqualityCondition.ComparisonAttribute ncmpAttr = NotEqualityCondition.ComparisonAttribute.INNERTEXT;
                        if (condition.lhs_element_attr.ToLower() == "value")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.VALUE;
                        }
                        else
                        if (condition.lhs_element_attr.ToLower() == "class")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.CLASS;
                        }
                        else
                        if (condition.lhs_element_attr.ToLower() == "innerhtml")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.INNERHTML;
                        }
                        else
                        if (condition.lhs_element_attr.ToLower() == "name")
                        {
                            cmpAttr = EqualityCondition.ComparisonAttribute.NAME;
                        }
                        var neqCond = new NotEqualityCondition(ncmpAttr, dal, ie);

                        neqCond.ConditionElement = new SiteObject(condElm.websiteRow.name, condElm.name);
                        newCondition             = neqCond;
                        break;

                    case ConditionBase.ConditionType.NOT_SELECETED:
                        newCondition = new NotSelectedCondition(condition.lhs_element_attr, dal, ie);
                        break;

                    case ConditionBase.ConditionType.NOT_VALUE:
                        newCondition = new NotValueCondition(condition.lhs_element_attr, dal, ie);
                        break;

                    case ConditionBase.ConditionType.SELECTED:
                        newCondition = new SelectedCondition(condition.lhs_element_attr, dal, ie);
                        break;

                    case ConditionBase.ConditionType.TRUE:
                        newCondition = new TrueCondition();
                        break;

                    case ConditionBase.ConditionType.VALUE:
                        newCondition = new ValueCondition(condition.lhs_element_attr, dal, ie);
                        break;
                    }
                }

                Conditions.Add(newCondition);

                Actions = new ActionCollection();
                var actions = dal.DB.action.Where(row => row.step_id == step_id);
                foreach (var action in actions)
                {
                    if (action.type.ToLower() == "none")
                    {
                        continue;
                    }
                    var        targetElm        = dal.DB.element.Single(row => row.id == action.target_id);
                    SiteObject targetSiteObject = new SiteObject(targetElm.websiteRow.name, targetElm.name);
                    IAction    newAction        = null;
                    if (action.type.ToLower() == "click")
                    {
                        newAction = new ClickAction(dal, ie, targetSiteObject);
                    }
                    else
                    if (action.type.ToLower() == "check")
                    {
                        newAction = new CheckAction(dal, ie, targetSiteObject);
                    }
                    else
                    if (action.type.ToLower() == "uncheck")
                    {
                        newAction = new UnCheckAction(dal, ie, targetSiteObject);
                    }
                    else
                    if (action.type.ToLower() == "type text")
                    {
                        newAction = new TypeAction(action.value, dal, ie, targetSiteObject);
                    }
                    else
                    if (action.type.ToLower() == "select")
                    {
                        newAction = new SelectAction(action.value, dal, ie, targetSiteObject);
                    }
                    if (action.type.ToLower() == "notify")
                    {
                        if (action.notifyMethod.ToLower() == "none")
                        {
                            continue;
                        }
                        NotifyAction.NotifyMethod method = NotifyAction.NotifyMethod.LOG;
                        if (action.notifyMethod.ToLower() == "email")
                        {
                            method = NotifyAction.NotifyMethod.EMAIL;
                        }
                        else
                        if (action.notifyMethod.ToLower() == "popup")
                        {
                            method = NotifyAction.NotifyMethod.POPUP;
                        }
                        newAction = new NotifyAction(method, dal, ie, targetSiteObject);
                    }
                    Actions.Add(newAction);
                }
            }
        }
Exemple #2
0
 public SiteObjectNotBoundException(SiteObject so)
 {
     this.Data["SiteObject"] = so;
 }
Exemple #3
0
 public UnCheckAction(awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
 }
Exemple #4
0
 /// <summary>
 /// This Class Represent a typing in a text input field action
 /// </summary>
 /// <param name="text">the text to fill in the field</param>
 /// <param name="dal">the DAL class instance</param>
 /// <param name="ie">the WatiN browser object</param>
 /// <param name="target">the Target Object upon which to act</param>
 public TypeAction(string text, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.text = text;
 }
Exemple #5
0
 public NotifyAction(NotifyMethod method, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.notifyMethod = method;
 }
Exemple #6
0
 public SelectAction(string item, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.item = item;
 }