示例#1
0
 public static void selectRadiobutton(Ranorex.InputTag element, string strValue, string ControlName)
 {
     try
     {
         element.EnsureVisible();
         element.Focus();
         Mouse.MoveTo(element);
         Delay.Seconds(1);
         element.Click();
         Report.Info(strValue + " is selected in " + ControlName);
         Delay.Milliseconds(300);
     }
     catch (Exception ex)
     {
         Report.Screenshot();
         Report.Failure(strValue + " is not selected due to " + ex.Message);
     }
 }
        public void Choose_Attached_DHCPv6_Device_To_Reserved_List(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7)
        {
            //choose IPv6 devices to reserve
            ////choose device from the attached list
            //This method is to select any MAC filter rules to delete
            //argument1 - MAC Address1, argument2- MAC Address2
            //argument3 - MAC Address3, argument4 - MAC Address4
            //argument5 - MAC Address5, argument6 - MAC Address6
            //argument7 - Device Name

            Delay.Seconds(30);                  // to load the pages
            WebDocument webDocument = "/dom[@domain='192.168.0.1']";

            webDocument.WaitForDocumentLoaded();
            //Report.Info(webDocument.GetHtml());

            //DHCP lease table

            TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'AttachedDevicesTable']");
            //Count the total no of IPv4 port Filter rules (rows)
            IList <TrTag> totalDHCPClients  = myTable.Find <TrTag>("./tbody//tr");              //Row
            int           rulesCount        = totalDHCPClients.Count;
            string        totalDHCPAttached = "Total Rules : " + rulesCount.ToString();

            Report.Info("Active Attached Devices ", totalDHCPAttached);

            if (rulesCount == 0)
            {
                //Mouse.ScrollWheel(150);
                Report.Failure("DHCP List", "There are no devices to add !!");
                return;
            }
            else
            {
                //if there any rules? then choose appropriate radio button
                Report.Info(" There are " + rulesCount.ToString() + " devices attached to this router  !!! ");
                int rowNum = 1;
                //int addCheck = 1;
                Boolean isMatch = false, isMacAddressMatch = false;
                string  macAddress = "", macAddress1 = "", IPAddress = "", devName = "", Wifi_Freq = "";
                string  IPAddressSubStr = "";
                macAddress = argument1 + ":" + argument2 + ":" + argument3 + ":" + argument4 + ":" + argument5 + ":" + argument6;

                foreach (var row in totalDHCPClients)
                {
                    Report.Info("Row : " + rowNum);
//					Report.Info(row.GetInnerHtml().ToString());
                    IList <TdTag> cols = row.Find <TdTag>("./td");                      //column
                    Report.Info(" Total Columns in the Row : ", cols.Count.ToString());

                    int    colNum          = 1;
                    String radiobuttonPath = "";
//					Ranorex.InputTag MACFilterAttachedDeviceTag = null;
//					String newPath = "";
                    foreach (TdTag MacCol in cols)
                    {
                        //1- Radiobutton, 2-Device name,3-MAC address,4-IP Address,5-Lease time,6-Connected to
                        Report.Info("MacCol: " + colNum);
//						Report.Info("MacCol Info: "+MacCol.InnerText);

                        if (colNum == 1)
                        {
                            radiobuttonPath = MacCol.GetPath().ToString();
                        }
                        else if (colNum == 2)
                        {
                            devName = MacCol.InnerText;
                            Report.Info("devName : " + devName);
                        }
                        else if (colNum == 3)                           //MAC Address

                        {
                            IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span");
                            //Report.Info("span count :  "+spanVals.Count);
                            foreach (SpanTag spanVal in spanVals)
                            {
                                macAddress1 = spanVal.InnerText;
                                if (macAddress == macAddress1)
                                {
                                    Report.Info(" The device with MAC Address -  " + macAddress1 + "  - is attached to the Hub");
//									Report.Info(" Wifi_Freq  : ",Wifi_Freq);
//									Report.Info("Device Name : ", devName);
//									Report.Info("MAC Address to Add :", macAddress1);
                                    isMacAddressMatch = true;

                                    /*
                                     * //									isMatch = true;
                                     * String newPath = "";
                                     * int radVal = rowNum -1;
                                     * newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='"+radVal+"']";
                                     * Ranorex.InputTag MACFilterAttachedDeviceTag = newPath;
                                     * //									MACFilterAttachedDeviceTag = newPath;
                                     * Report.Info("MACFilterAttachedDeviceTag PATH :  ", newPath);
                                     *
                                     * //									Delay.Seconds(1);
                                     * MACFilterAttachedDeviceTag.PerformClick();	//MACFilterAttachedDeviceTag.Checked = "True";
                                     * //MACFilterAttachedDeviceTag.TagValue ="2";
                                     * Delay.Seconds(1);
                                     * //									string rst = "The following DHCP Client is added to the reserved list !!!";Report.Success(rst);
                                     * Report.Success("The following DHCP Client is added to the reserved list !!!");
                                     * Report.Screenshot("DHCP_Reserved_List",MacCol.Element,true);
                                     * //Report.Screenshot("DHCP_Reserved_List",row.Element,true);
                                     * //break;
                                     */
                                }
                            }
                        }
                        else if (colNum == 4)                           //Ip Address
                        {
                            IPAddress = MacCol.InnerText;
                            //check if the IP Address is IPv6 type,if yes then click the radio button
                            Report.Info(" IPAddress : " + IPAddress);
//							Report.Info(" IPAddress length : " + IPAddress.Length);
                            if (IPAddress.Length <= 0)
                            {
                                Report.Failure("InValid IPv4/v6 Address");
                            }
                            else if (IPAddress.Length > 0)
                            {
                                Report.Info(" IPAddressLength : " + IPAddress.Length);
                                IPAddressSubStr = IPAddress.Substring(0, IPAddress.Length - 3);
                                Report.Info("IPAddressSubStr : " + IPAddressSubStr);
                            }
                            //parse the IPv4 address
                            Boolean CheckIPAddress = this.CheckIPv4AddressValid(IPAddressSubStr.Trim());

                            if (CheckIPAddress)
                            {
                                Report.Success("Valid IP v4/v6 Address");
                                int isIPv4 = IPAddressSubStr.IndexOf('.');
//								Report.Info(isIPv4.ToString());

                                if (isIPv4 == -1)                                // it is IPv6
                                {
                                    if (isMacAddressMatch)
                                    {
                                        isMatch = true;
                                        Report.Info("It is IPv6 ");
                                        //choose the device and add to the reserve list
                                        String newPath = "";
                                        int    radVal  = rowNum - 1;
                                        newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='" + radVal + "']";
                                        Ranorex.InputTag MACFilterAttachedDeviceTag = newPath;
                                        Report.Info("MACFilterAttachedDeviceTag PATH :  ", newPath);
                                        Delay.Seconds(1);
                                        MACFilterAttachedDeviceTag.Click();
                                        MACFilterAttachedDeviceTag.PerformClick();
                                        Delay.Seconds(2);
                                        Report.Screenshot("DHCPv6_Reserved_List", MacCol.Element, true);
                                        Report.Success("The DHCPv6 Client is added to the reserved list !!!");
                                    }
                                }
                                else
                                {
                                    Report.Info("It is IPv4 ");
                                }
                            }
                            else
                            {
                                //IPAddress is v6
                                Report.Failure("InValid IPv4/v6 Address");
                            }
                        }
                        else if (colNum == 6)                           // frequency connected to
                        //IList<SpanTag> spanVals = MacCol.Find<SpanTag>("./span");
                        //foreach(SpanTag spanVal in spanVals){
                        //Wifi_Freq = spanVal.InnerText;
                        //}
                        {
                            Wifi_Freq = MacCol.InnerText;
//							Report.Info("Wifi_Freq : " + Wifi_Freq);

                            /*
                             * if(isMatch){
                             *      break;
                             * } */
                        }

                        colNum++;
                    }                           //end of forloop - cols
                    if (isMatch)                //is device attached and radio button clicked ??
                    {
                        Report.Info("Wifi_Frequency : ", Wifi_Freq);
                        if (Wifi_Freq.Trim().StartsWith("Wi-Fi 2.4G"))
                        {
                            Report.Info("This device is connected to  WI-FI 2.4G");
                            //choose the device  and click radio button
                            break;
                        }
                        else if (Wifi_Freq.Trim().StartsWith("Wi-Fi 5G"))
                        {
                            Report.Info("This device is connected to  WI-FI 5G");
                            break;
                        }
                        else if (Wifi_Freq.Trim().StartsWith("Ethernet"))
                        {
                            Report.Info("This device is connected to  Ethernet");
                            break;
                        }
                        else
                        {
                            Report.Info("This device is NOT connected to  WI-FI 2.4G /WI-FI 5G");
                            break;
                        }
                        //break;
                    }

                    rowNum++;
                }                       //end of forloop - totalDHCPClients

                if (!isMatch)
                {
                    string rst = "The device : " + devName + "(" + macAddress + ")" + " does not  exist in the attached list ";
                    Report.Failure("DHCPv6_Reserved_List", rst);
                    TestSuite.Current.GetTestCase("Add_Device_To_DHCPv6_Reserved_List").Checked = false;                        //Add_Device_To_DHCP_Reserved_List
                }
                else
                {
                    TestSuite.Current.GetTestCase("Add_Device_To_DHCPv6_Reserved_List").Checked = true; //Add_Device_To_DHCP_Reserved_List
                }
            }                                                                                           //end of if-else
        }                                                                                               //end of method
示例#3
0
        public void Choose_All_Devices_From_MAC_List_To_Delete_2_4GHz_Primary()
        {
            //delete all devices that belongs to 2_4GHz_Primary
            if (TotalRows1 <= 5 || TotalRows2 <= 5)
            {
                Delay.Seconds(5);               // to load the pages
            }
            else if ((TotalRows1 > 5 && TotalRows1 <= 10) || (TotalRows2 > 5 && TotalRows2 <= 10))
            {
                Delay.Seconds(10);              // to load the pages
            }
            else if ((TotalRows1 > 10 && TotalRows1 <= 20) || (TotalRows2 > 10 && TotalRows2 <= 20))
            {
                Delay.Seconds(20);              // to load the pages
            }
            else
            {
                Delay.Seconds(30);              // to load the pages
            }
            //Delay.Seconds(30);
            WebDocument webDocument = "/dom[@domain='192.168.0.1']";
            //Report.Info(webDocument.GetHtml());
            TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'macAddressFilterTable']");
            //Count the total no of IPv4 port Filter rules (rows)
            IList <TrTag> totalMACListDevices   = myTable.Find <TrTag>("./tbody//tr");
            int           rulesCount            = totalMACListDevices.Count;
            string        totalMACFilterDevices = "Total Rules : " + rulesCount.ToString();

            Report.Info("Active Devices ", totalMACFilterDevices);

            if (rulesCount == 0)
            {
                //Mouse.ScrollWheel(150);
                Report.Failure("MAC Filter Devices ", "There are no devie to delete !!");
                TestSuite.Current.GetTestCase("Delete_All_Devices_From_MAC_Filter_List_2_4GHz_Pmry_Wireless").Checked = false;
                return;
            }
            else if (rulesCount == 1)
            {
                //walkthrough the column values
                IList <TdTag> cols = myTable.Find <TdTag>("./tbody//td");
                int           colsCount = cols.Count, colCnt = 1, delCheck = 0;;
                string        noFilterStr = null;
                //Report.Info("colsCount",colsCount.ToString());
                string Wireless_radio = "";
                foreach (TdTag col in cols)
                {
                    if (colsCount == 1)                         ////No filtering device!
                    {
                        noFilterStr = col.InnerText.ToString();
                        //Report.Info(noFilterStr.ToString());
                        //if(noFilterStr.StartsWith("No filtering")){
                        if (noFilterStr.StartsWith("You have not selected a device to filter. Please select a device from the attached devices list."))
                        {
                            Report.Failure("MAC Filter Devices ", "There are no devie to delete !!");
                            TestSuite.Current.GetTestCase("Delete_All_Devices_From_MAC_Filter_List_2_4GHz_Pmry_Wireless").Checked = false;
                            return;
                        }
                    }
                    else                        //only one rule exist
                    //Report.Info("Only one MAC Filter rule exist,now !!!");
                    {
                        if (colCnt == 3)
                        {
                            IList <SpanTag> spanVals = col.Find <SpanTag>("./span");
                            //Report.Info("span count :  "+spanVals.Count);

                            foreach (SpanTag spanVal in spanVals)
                            {
                                Wireless_radio = spanVal.InnerText;
                                Report.Info("Wireless_radio  : " + Wireless_radio);
                            }
                            //Report.Info("Wireless_radio",Wireless_radio);
                            Report.LogHtml(ReportLevel.Info, Wireless_radio, "<b>Wireless_radio frequency</b>");
                        }
                        else if (colCnt == 4)
                        {
                            if (Wireless_radio == "2.4GHz")
                            {
                                //Report.Info("----------------- click delete checkbox ------");
                                String newPath = "", colPath = "";
                                colPath = col.GetPath().ToString();
                                Report.Info("colpath -->" + colPath);
                                newPath = colPath + "/input[#'macAddressFilterTable-Delete-" + delCheck + "']";
                                Ranorex.InputTag MACFilterTableDeleteTag = newPath;
                                if (MACFilterTableDeleteTag.Checked.ToString() == "False")
                                {
                                    //Report.Info("----------------- MACFilterTableDeleteTag was False ---");
                                    Delay.Seconds(1);
                                    MACFilterTableDeleteTag.Click();
                                    MACFilterTableDeleteTag.PerformClick();
                                    MACFilterTableDeleteTag.Checked = "Checked";
                                    Delay.Seconds(1);
                                }
                                else
                                {
                                    Report.Info(" MACFilterTableDeleteTag is already checked  ");
                                }
                                string rst = "The following MACFilter_Filtering rule is deleted permanently !!!";
                                Report.Success(rst);
                                Report.Screenshot("MACFilter_Filtering", col.Element, true);
                            }
                            else
                            {
                                Report.Info(" Different wireless radio frequency(5GHz) devices are added in the list ! ");
                            }
                        }
                        colCnt++;
                    }                   //end of if-else
                }                       //end of forloop:TdTag
            }
            else
            {
                Report.Info(" There are " + rulesCount.ToString() + " MAC filter list !!! ");

                int rowNum   = 1;
                int delCheck = 0;

                foreach (var row in totalMACListDevices)
                {
                    Report.Info("Row: " + rowNum);
                    //walkthrough the column values
                    //IList<TdTag> cols = myTable.Find<TdTag>("./tbody//td");
                    IList <TdTag> cols      = row.Find <TdTag>("./td");
                    int           colsCount = cols.Count;
//					Report.Info("Total colsCount",colsCount.ToString());
                    int    j = 1;                       //column number
                    string Wireless_radio = "";
                    foreach (TdTag col in cols)
                    {
//						Report.Info("col number: " + j);
                        //Report.Info("col.InnerText",col.InnerText);

                        /*
                         * if(j==3){
                         *      //Wireless radio
                         *      //Wireless_radio = col.InnerText;
                         *      String wirelessRadioPath = "";
                         *      wirelessRadioPath = col.GetPath().ToString();
                         *      Report.Info("wirelessRadioPath",wirelessRadioPath);
                         *      //find span tag
                         * }else **/
                        if (j == 3)
                        {
                            //Wireless_radio = col.InnerText;
                            IList <SpanTag> spanVals = col.Find <SpanTag>("./span");
                            //Report.Info("span count :  "+spanVals.Count);

                            foreach (SpanTag spanVal in spanVals)
                            {
                                Wireless_radio = spanVal.InnerText;
                                Report.Info("Wireless_radio  : " + Wireless_radio);
                            }
                            //Report.Info("Wireless_radio",Wireless_radio);
//							 Report.LogHtml(ReportLevel.Info,Wireless_radio,"<b>Wireless_radio frequency</b>");
                        }
                        else if (j == 4)
                        {
                            if ((Wireless_radio == "2.4GHz") || (Wireless_radio == "2.4 GHz"))                                  //updated on 17/10/17  based on SON code - 116.400

                            /*
                             * WebElement webElement = col.Element;
                             * Delay.Seconds(2);
                             * webElement.Click();
                             * Report.Screenshot("Delete MACFilterDevices",webElement,true);
                             * Report.Info("Delete Checkbox Clicked");
                             * j=0;
                             */
                            //Delay.Seconds(5);
                            //Report.Info("----------------- click delete checkbox ------");
                            //Report.Info("Wireless_radio",Wireless_radio);
                            //if(macAddress == macAddress1){
                            //isMatch = true;
                            //Report.Info("----------------- Rules Matches !!! ------");
                            {
                                String newPath = "", colPath = "";
                                colPath = col.GetPath().ToString();
                                //Report.Info("col Path ", colPath);
                                //newPath = col.GetPath() + "/input[#'macAddressFilterTable-Delete-"+delCheck+"']";	//fmChbx-macAddressFilterTable-Delete-0
                                //macAddressFilterTable-Delete-0
                                newPath = colPath + "/input[#'macAddressFilterTable-Delete-" + delCheck + "']";

                                //newPath = "/dom[@domain='192.168.0.1']//input[#'macAddressFilterTable-"+delCheck+"']";
                                //dom[@domain='192.168.0.1']//input[#'macAddressFilterTable-Delete-0']
                                //Report.Info("newPath ", newPath);
                                Ranorex.InputTag MACFilterTableDeleteTag = newPath;
                                if (MACFilterTableDeleteTag.Checked.ToString() == "False")
                                {
                                    Report.Info("----------------- MACFilterTableDeleteTag was False ---");
                                    Delay.Seconds(1);
                                    MACFilterTableDeleteTag.Click();
                                    MACFilterTableDeleteTag.PerformClick();
                                    MACFilterTableDeleteTag.Checked = "Checked";
                                    Delay.Seconds(1);
                                }
                                else
                                {
                                    Report.Info(" MACFilterTableDeleteTag is already marked for deletion ");
                                }
                                string rst = "The following MACFilter_Filtering rule is deleted permanently !!!";
                                Report.Success(rst);
                                Report.Screenshot("MACFilter_Filtering", col.Element, true);


                                //	}
                            }
                            else
                            {
                                Report.Info(" Different wireless radio frequency ");
                            }   //end of IF-ELSE : Wireless_radio frequency
                        }
                        j++;    //column number
                    }           //end of foreach - column
                    rowNum++;
                    delCheck++; //counter to select delete checkbox
                }               //end of foreach - row
                TestSuite.Current.GetTestCase("Delete_All_Devices_From_MAC_Filter_List_2_4GHz_Pmry_Wireless").Checked = true;
            }                   //end of if-else
        }                       //end of function