Example #1
0
 public ActionBase(awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
 {
     this.DAL    = dal;
     this.IE     = ie;
     Repetitions = 1;
     this.Target = target;
 }
Example #2
0
 public TestSiteObject() : base("http://www.google.com", "pictures")
 {
     browser = new IE(this.Website);
     browser.WaitForComplete(20);
     dal = new awaDAL.DAL();
     dal.Init(@"Data Source=..\..\..\db\AutoWebAgentDB.sdf;Password=koby3274;Persist Security Info=True");
 }
Example #3
0
 public TestStepConditionAction()
 {
     //browser = new IE("http://www.google.com");
     browser = new IE(@"http://localhost/testPage.htm");
     //file:///C:\Documents and Settings\User-1\My Documents\לימודים\AutoWebAgentProject2009\AutoWebAgent\trunk\AutoWebAgent\TestAWA\testPage.htm
     browser.WaitForComplete(20);
     dal = new awaDAL.DAL();
     dal.Init(@"Data Source=..\..\..\db\AutoWebAgentDB.sdf;Password=koby3274;Persist Security Info=True");
     main    = new SiteObject("testpage", "text1");
     aux     = new SiteObject("testpage", "area1");
     button  = new SiteObject("testpage", "b1");
     steps   = new StepCollection();
     actions = new ActionCollection();
     conds   = new ConditionCollection();
 }
Example #4
0
 public Script(IE ie, awaDAL.DAL dal, int script_id)
 {
     Steps   = new StepCollection();
     this.ie = ie;
     if (script_id != -1)
     {
         var scriptRow = dal.DB.script.Single(row => row.id == script_id);
         this.Name             = scriptRow.name;
         this.Author           = dal.DB.users.Single(row => row.id == scriptRow.user_id).name;
         this.Activated        = false;
         this.Forced           = false;
         this.Count            = 1;
         this.Reccurance       = TimeSpan.Zero;
         this.LastModifiedTime = scriptRow.modified;
         var steps = dal.GetStepsByScriptID(script_id);
         foreach (var step in steps)
         {
             IStep newStep = new Step(ie, dal, step.id);
             Steps.Add(newStep);
         }
     }
 }
Example #5
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);
                }
            }
        }
Example #6
0
 public ValueCondition(string value, awaDAL.DAL dal, WatiN.Core.IE ie) : base(dal, ie)
 {
     this.value = value;
 }
Example #7
0
 public ConditionBase(awaDAL.DAL dal, WatiN.Core.IE ie)
 {
     this.DAL = dal;
     this.IE  = ie;
 }
Example #8
0
 public NotSelectedCondition(string si, awaDAL.DAL dal, WatiN.Core.IE ie)
     : base(dal, ie)
 {
     selectedItem = si;
 }
Example #9
0
 public CheckedCondition(awaDAL.DAL dal, WatiN.Core.IE ie)
     : base(dal, ie)
 {
 }
Example #10
0
 public NotEqualityCondition(ComparisonAttribute attr, awaDAL.DAL dal, WatiN.Core.IE ie)
     : base(dal, ie)
 {
     this.ca = attr;
 }
Example #11
0
 public UnCheckAction(awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
 }
Example #12
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;
 }
Example #13
0
 public NotifyAction(NotifyMethod method, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.notifyMethod = method;
 }
Example #14
0
 public SelectAction(string item, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.item = item;
 }