public void setNode(Steps curStep)
        {
            selectedNode = curStep;

            presetStepObjectiveText.Text = curStep.Desc;
            presetStepKeywordBox.SelectedIndex = presetStepKeywordBox.FindStringExact(curStep.Keyword);
            presetStepElementText.Text = curStep.Element;
            presetStepValueText.Text = curStep.Value;

        }
        public RunLog ParseAction(Steps step)
        {
            //Wait(1000);
            RunLog log = new RunLog();
            switch(step.Keyword)
            {
                case "group":
                    log.Pass = true;
                    break;

                case "url":
                    log = Url(step.Value);
                    break;

                case "click":
                    log = ClickAndWait(step.Element);
                    break;

                case "doubleclick":
                    log = DoubleClick(step.Element);
                    break;

                case "type":
                    log = Type(step.Element, step.Value);
                    break;

                case "select":
                    log = Select(step.Element, step.Value);
                    break;

                case "wait":
                    log = Wait(Convert.ToInt32(step.Value));

                    break;

                case "switchtopopup":
                    log = Popup(step.Element);
                
                    break;

                case "switchtomainwindow":
                    log = MainWindow();
                    break;
                case "submit":
                    log = Submit(step.Element);
                    break;
                default:
                    break;

            }
            return log;
        }
        // These methods fill data into the treeview

        private Steps FindNextStep(Steps curStep, List<Steps> stepList)
        {
            foreach (Steps thisStep in stepList)
            {
                if(thisStep.Id == curStep.Next)
                {
                    return thisStep;
                }
            }

            return null;
        }
        private void recursiveRunTest(TreeNode treeNode, SeleniumActions seleniumHandle)
        {
            runStepNum++;

            if (treeNode.Equals(startNode))
            {
                runsteps = true;
            }

            if (runsteps)
            {
                //stepBrowser.SelectedNode = treeNode;
                Steps curStep = (Steps)treeNode.Tag;

                Steps tempStep = new Steps();

                tempStep.Keyword = curStep.Keyword;
                tempStep.Value = curStep.Value;
                tempStep.Element = curStep.Element;
                foreach (Variables curVar in runStepVars)
                {
                    tempStep.Value = tempStep.Value.Replace(curVar.Searchstr, curVar.Calculatedvalue);
                    tempStep.Element = tempStep.Element.Replace(curVar.Searchstr, curVar.Calculatedvalue);
                }

                RunLog log = seleniumHandle.ParseAction(tempStep);

                log.Stepnum = runStepNum;
                log.Step = curStep;

                if (!log.Pass)
                {
                    runsteps = false;
                    log.Message = "Step Failed, Aborting Run\n\n" + log.Message;
                }
                    

                

                testCaseWorker.ReportProgress(2, log);
            }

            foreach (TreeNode tn in treeNode.Nodes)
            {
                recursiveRunTest(tn, seleniumHandle);
            }
        }
 public void UpdateStepOrder(Steps curStep)
 {
     stepsTableAdapter.UpdateOrder(curStep.Id, curStep.Order);
 }
        public void DeleteStep(Steps curStep)
        {
            automationDataSet.stepsRow curRow = automationDataSet.steps.FindByid(curStep.Id);
            if (curRow != null)
                curRow.Delete();

            stepsTableAdapter.Update(curRow);
        }
        public int CommitStep(Steps curStep)
        {
            int id = 0;

            automationDataSet.stepsRow curRow = automationDataSet.steps.FindByid(curStep.Id);
            
            if (curRow == null)
            {
                id = Convert.ToInt32(stepsTableAdapter.InsertGetId(curStep.Testcase_id, curStep.Parentstep_id, curStep.Order, curStep.Desc, curStep.Keyword, curStep.Value, curStep.Linked_id, curStep.Element));
                stepsTableAdapter.Fill(automationDataSet.steps);
            }
            else
            {
                curRow.testcase_id = curStep.Testcase_id;
                curRow.parentstep_id = curStep.Parentstep_id;
                curRow.order = curStep.Order;
                curRow.desc = curStep.Desc;
                curRow.keyword = curStep.Keyword;
                curRow.value = curStep.Value;
                curRow.linked_id = curStep.Linked_id;
                curRow.element = curStep.Element;
                curRow.prev = curStep.Prev;
                curRow.next = curStep.Next;

                stepsTableAdapter.Update(curRow);
                

                id = curRow.id;
            }

            return id;
        }
        public List<Steps> GetStepsFromPreset(TestCases curTc)
        {
            automationDataSet.presetsRow thisrow = automationDataSet.presets.FindByid(curTc.Id);

            automationDataSet.stepsRow[] rows = (automationDataSet.stepsRow[])thisrow.GetChildRows("presets_steps");

            List<Steps> stepList = new List<Steps>();

            foreach (automationDataSet.stepsRow row in rows)
            {

                Steps curStep = new Steps();

                curStep.Id = row.id;
                curStep.Testcase_id = row.testcase_id;
                curStep.Parentstep_id = row.parentstep_id;
                curStep.Order = row.order;
                curStep.Desc = row.desc;
                curStep.Keyword = row.keyword;
                curStep.Value = row.value;
                curStep.Linked_id = row.linked_id;
                curStep.Element = row.element;
                curStep.Prev = row.prev;
                curStep.Next = row.next;

                stepList.Add(curStep);
            }

            return stepList;
        }