示例#1
0
        void Check_Checkbox_visibility()
        {
            Report.Info("Inside Check_Checkbox_visibility ");
            Report.Info("Going to check the checkBox visibility");
            Total_Port_Fwding_Rules tpfr = new Total_Port_Fwding_Rules();
            int rulesCnt = tpfr.pfRules_Count();

            Report.Info(" rulesCnt -------->> " + rulesCnt);

            //if there are no rules (or) if the first check box is not visible then skip the next 2 test cases
            if (rulesCnt == -1)
            {
                // there are no rules
                TestSuite.Current.GetTestCase("Select_First_Port_Forwarding_Rule_to_Disable").Checked = false;
                TestSuite.Current.GetTestCase("Disable_First_Port_Forward_Rule").Checked = false;
            }
            else if (rulesCnt > 0)      // if rulesCnt is 'zero' skip it
            {
                TestSuite.Current.GetTestCase("Select_First_Port_Forwarding_Rule_to_Disable").Checked = false;
                TestSuite.Current.GetTestCase("Disable_First_Port_Forward_Rule").Checked = false;
            }
        }
        public void Choose_All_Port_Forward_Rules_to_Disable()
        {       //choose all port rules ( except UPnP) to delete - Added on 06/06/2017 , R3.11
            //Delay.Seconds(15);

            Total_Port_Fwding_Rules tpfr = new Total_Port_Fwding_Rules();
            int ruleCnt = tpfr.pfRules_Count();

            Report.Info(" ruleCnt " + ruleCnt);

            if (ruleCnt == -1)
            {
                Report.Failure("Port Forwarding ", "There are no active Port Forwarding rules to Disable !!");
                TestSuite.Current.GetTestCase("Apply_Port_Forward_Changes_Disable_All").Checked = false;
                return;
            }
            else if (TotalRows < 6)
            {
                Delay.Seconds(5);
            }
            else if (TotalRows < 10)
            {
                Delay.Seconds(10);
            }
            else if (TotalRows > 10 && TotalRows < 20)
            {
                Delay.Seconds(20);
            }
            else if (TotalRows > 20 && TotalRows < 30)
            {
                Delay.Seconds(30);
            }
            else if (TotalRows > 30)
            {
                Delay.Seconds(40);
            }
            WebDocument webDocument = "/dom[@domain='192.168.0.1']";
            TableTag    myTable     = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'PortForwardingTable']"); //R3.11
//            TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'portTriggeringTable']");  //As per R3.5 (9.1.116J)

            //Count the total no of port forwarding rules (rows)
            IList <TrTag> totalRules = myTable.Find <TrTag>("./tbody//tr");
            int           rulesCount = totalRules.Count;
            //Report.Info("Total Rules",rulesCount.ToString());
            string totalPortRules = "Total Rules : " + rulesCount.ToString();

            //Report.Info("Port Forwarding ",totalPortRules);

            if (rulesCount > 0)
            {
                Report.Info("Total Rules", totalPortRules);
                // is there are any active rules ??
                //walkthrough the column values
                IList <TdTag> cols      = myTable.Find <TdTag>("./tbody//td");
                int           colsCount = cols.Count;
                int           j         = 1;
                //Report.Info("Total colsCount",colsCount.ToString());

                foreach (TdTag col in cols)
                {
                    Report.Info("Column #", j.ToString());
                    Report.Info("Column Value", col.InnerText);
                    if (j == 5)
                    {
                        //enable or disable ?

                        //Report.Info("Enable or Disable ?");

                        IList <InputTag> inputVals = col.Find <InputTag>("./input");
                        int inputValsCount         = inputVals.Count;
                        //Report.Info("input count :  "+inputVals.Count);
                        Report.Info("input count :  " + inputValsCount);
                        if (ruleCnt == 1 && inputValsCount == 0)
                        {
                            Report.Info(" Skip - Apply_Port_Forward_Changes_Disable_All ");
                            TestSuite.Current.GetTestCase("Apply_Port_Forward_Changes_Disable_All").Checked = false;
                        }
                        foreach (InputTag inputVal in inputVals)
                        {
                            Ranorex.InputTag testTag = inputVal;
                            Report.Info(inputVal.GetPath().ToString());
                            if (testTag.Checked.ToString() == "True")
                            {
                                Report.Info(" portForwardingTableEnabledTag is currently enabled ");
                                inputVal.Checked = "False";
                                Delay.Seconds(5);
                                Report.Log(ReportLevel.Success, "This port forwarding rule is disabled now...");
                                Report.Screenshot("PortForwardingRule", col.Element, true);
                            }
                            else
                            {
                                //Report.Info(" portForwardingTableEnabledTag is currently disabled ");
                                //inputVal.PerformClick();
                                //Delay.Seconds(5);
                                Report.Log(ReportLevel.Success, "This port forwarding rule is already disabled !!!");
                                Report.Screenshot("PortForwardingRule", col.Element, true);
                            }
                        }                //end of for-loop : InputTag
                        j++;             //increment the column
                    }
                    else if (j == 6)
                    {
                        //delete box
                        //Report.Info("delete ?");
                        j = 1;
                    }
                    else
                    {
                        j++;
                    }
                }                // end of FOR-LOOP :TdTag
                Report.Log(ReportLevel.Success, "The following port forwarding rule(s) are Disabled");
                Delay.Seconds(1);
                //Report.Screenshot();
                Report.Screenshot("PortForwardingRule", myTable.Element, true);
            }
            else
            {
                Report.Failure("Port Forwarding ", "There are no active Port Forwarding rules to Disable !!");
                TestSuite.Current.GetTestCase("Apply_Port_Forward_Changes_Disable_All").Checked = false;
                return;
            }    // end of if-else
        }