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
public void Choose_Attached_DHCP_Device_To_Reserved_List(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7) { ////choose device from the attached list /// //This method is to select any MAC filter rules to delete //argument1 - MAC Address0, argument2- MAC Address1 //argument3 - MAC Address2, argument4 - MAC Address3 //argument5 - MAC Address4, argument6 - MAC Address5 //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; string macAddress = "", macAddress1 = "", IPAddress = "", devName = "", Wifi_Freq = ""; 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 = ""; 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); //Report.Info(MacCol.GetInnerHtml().ToString()); if (colNum == 1) { //radio button radiobuttonPath = MacCol.GetPath().ToString(); //Report.Info(MacCol.GetInnerHtml().ToString()); //Report.Info(radiobuttonPath); Report.Info("Radio button Path:", radiobuttonPath); } else if (colNum == 2) { //device name /* * IList<SpanTag> spanVals = MacCol.Find<SpanTag>("./span"); * foreach(SpanTag spanVal in spanVals){ * devName = spanVal.InnerText; * } */ devName = MacCol.InnerText; } else if (colNum == 3) { //MAC Address //Report.Info(MacCol.InnerText); //Report.Info(MacCol.GetInnerHtml().ToString()); //macAddress1 = MacCol.InnerText; IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); //Report.Info("span count : "+spanVals.Count); foreach (SpanTag spanVal in spanVals) { macAddress1 = spanVal.InnerText; //Report.Info("devName : ", devName); //Report.Info("MAC Address to Add : " + macAddress); //Report.Info("MAC Address1 : " + macAddress1); if (macAddress == macAddress1) { Report.Info("//--------------- MAC address exist in attached device list------//"); Report.Info("//--------------- Wifi_Freq -----", Wifi_Freq); macAddress1 = spanVal.InnerText; Report.Info("Device Name ", devName); Report.Info("MAC Address to Add ", macAddress); //Report.Info("MAC Address1 : " + macAddress1); isMatch = true; String newPath = ""; Report.Info("radiobuttonPath : ", radiobuttonPath.ToString()); //newPath = radiobuttonPath + "/input[#'attachedDevicesGroup']"; //newPath = "/dom[@domain='192.168.0.1']//tbody[#'AttachedDevicesTable_body']//input[@name='attachedDevicesGroup']"; //newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='2' ]"; int radVal = rowNum - 1; newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='" + radVal + "']"; // newPath ="/dom[@domain='192.168.0.1']//input[#'ipv4FilterTable-Enabled-"+delCheck+"']"; Ranorex.InputTag MACFilterAttachedDeviceTag = newPath; Delay.Seconds(1); //MACFilterAttachedDeviceTag.Checked = "True"; MACFilterAttachedDeviceTag.PerformClick(); //MACFilterAttachedDeviceTag.TagValue ="2"; Delay.Seconds(1); /* * if (MACFilterTableDeleteTag.Checked.ToString() == "False"){ * Delay.Seconds(1); * MACFilterTableDeleteTag.PerformClick(); * }else{ * Report.Info(" MACFilterTableDeleteTag is already Enabled "); * } */ string rst = "The following DHCP Client is added to the reserved list !!!"; Report.Success(rst); //Report.Screenshot("MACFilter_Filtering",MacCol.Element,true); Report.Screenshot("DHCP_Reserved_List", row.Element, true); break; } } //end of SpanTag for-loop } else if (colNum == 4) { //Ip Address IPAddress = MacCol.InnerText; } else if (colNum == 6) { // frequency connected to IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { Wifi_Freq = spanVal.InnerText; } } colNum++; } //TdTag for-end loop if (isMatch) { Report.Info("Wifi_Freq", Wifi_Freq); if (Wifi_Freq.Trim() == " WI-FI 2.4G") { Report.Info("This device is connected to WI-FI 2.4G"); //choose the device and click radio button break; } else { Report.Info("This device is NOT connected to WI-FI 2.4G"); break; } //break; } rowNum++; //addCheck++; //counter to select add checkbox } //ROW for-end loop //Report.Info("rowNum :: ",rowNum.ToString()); if (!isMatch) { //Report.Info(" Device does not exist in the attached list "); //Report.Info("devName : ", devName); //Report.Info("MAC Address to Add : " + macAddress); string rst = "The device : " + devName + "(" + macAddress + ")" + " does not exist in the attached list "; //Report.Failure("DHCP_Reserved_List"," This device does not exist in the attached list "); Report.Failure("DHCP_Reserved_List", rst); TestSuite.Current.GetTestCase("Add_Device_To_DHCP_Reserved_List").Checked = false; //Add_Device_To_DHCP_Reserved_List } else { TestSuite.Current.GetTestCase("Add_Device_To_DHCP_Reserved_List").Checked = true; //Add_Device_To_DHCP_Reserved_List } } //end of if-else }
public void Choose_Wireless_Device_To_Rename(string argument1, string argument2) { Report.Info(" ===== Wireless_Device_To_Rename === " + argument1); // /dom[@domain='192.168.0.1']//table[#'wireless_Device'] WebDocument webDocument = "/dom[@domain='192.168.0.1']"; TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'wireless_Device']"); //count the rows IList <TrTag> rows = myTable.Find <TrTag>("./tbody//tr"); int rowsCnt = rows.Count; //Report.Info("Total rowsCnt",rowsCnt.ToString()); Report.Info("Total Rows", rowsCnt.ToString()); if (rowsCnt == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Rename ", "There are no connected wireless devices to rename !!"); TestSuite.Current.GetTestCase("Verify_Renamed_Wireless_Device_Name_In_Home_Screen").Checked = false; return; } else { //Choose_Wireless_Device_For_Rename int rowNum = 1; Boolean isMatch = false; foreach (var row in rows) { Report.Info("Row: " + rowNum); // Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); int colCnt = cols.Count; //Report.Info(" Total Columns(Devices) : ",colCnt.ToString()); if (colCnt > 0) { Report.Info(" There are " + colCnt.ToString() + " devices attached to this router !!! "); } int colNum = 1; String devicePath = ""; foreach (TdTag MacCol in cols) { Report.Info(" MacCol: " + colNum); //Report.Info("MacCol Info: "+MacCol.InnerText); // Report.Info(MacCol.GetInnerHtml().ToString()); IList <PTag> pVals = MacCol.Find <PTag>("./p"); Report.Info(" pVals count : ", pVals.Count.ToString()); foreach (PTag pVal in pVals) { string deviceName = pVal.InnerText.Trim(); Report.Info(" Device Name " + deviceName); if (argument1.Trim() == deviceName.Trim()) { Report.Info("This device name needs to be changed"); //devicePath = MacCol.GetPath().ToString(); //Report.Info("devicePath",devicePath); devicePath = MacCol.GetPath() + "/p[@innertext='" + deviceName + "']"; // /dom[@domain='192.168.0.1']//table[#'wireless_Device']/?/?/tr/td[2]/p[@innertext='android-fc4d149c99a46022'] // newPath = col.GetPath() + "/input[#'ipv4FilterTable-Delete-"+delCheck+"']"; // newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='"+radVal+"']"; Report.Info("devicePath", devicePath); Ranorex.PTag DeviceRenameTag = devicePath; Delay.Seconds(5); DeviceRenameTag.DoubleClick(); DeviceRenameTag.PerformClick(); //input the new friendly ( argument2) and press "Apply" button repo.WebDocumentIE.FriendlyName.Value = argument2; // /dom[@browsername='IE']//table[#'wireless_Device']//td/input[@type='button'] String wireless_Device_applyButton_Path = "/dom[@browsername='IE']//table[#'wireless_Device']//td/input[@type='button']"; Ranorex.InputTag wireless_Device = wireless_Device_applyButton_Path; wireless_Device.DoubleClick(); wireless_Device.PerformClick(); Delay.Seconds(5); Report.Info("---------------before click -------------"); repo.WebDocument19216801.WarningWizardFrame0.Button29.Click(); //added on 09/05/18 to click YES button in the popup window 9.1.1802.600 Report.Info("----------------after click -----------------"); isMatch = true; break; } } colNum++; } rowNum++; } if ((rowNum - 1) == rowsCnt && !isMatch) //if device does not exist { Report.Info(" ===== This device does not exist ====="); //Delay.Seconds(1); //Report.Screenshot("Device Rename",myTable.Element,true); //Report.Screenshot(); } } }
public void Choose_All_DHCP_Reserved_Rules_To_Delete() { //This method is to select all the filter rules to delete Delay.Seconds(40); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; webDocument.WaitForDocumentLoaded(); //Report.Info(webDocument.GetHtml()); TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'dhcpClientsTable']"); //Count the total no of DHCP Reserved rules (rows) IList <TrTag> totalDHCPList = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalDHCPList.Count; string totalDHCPReservedList = "Total Rules : " + rulesCount.ToString(); Report.Info("Active MAC Filter Rules ", totalDHCPReservedList); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("DHCP Reserved List ", "There are no active reservation list(s) to delete !!"); TestSuite.Current.GetTestCase("Confirm_To_Delete_All_From_DHCP_Reservation").Checked = false; return; } else { Report.Info(" There are " + rulesCount.ToString() + " DHCP Reservation list(s) to delete !!! "); //walkthrough the column values IList <TdTag> cols = myTable.Find <TdTag>("./tbody//td"); int colsCount = cols.Count; Report.Info("Total colsCount", colsCount.ToString()); int j = 1, delCount = 0, delCheck = 0; foreach (TdTag MacCol in cols) { //Report.Info("Column",j.ToString()); //Report.Info(MacCol.InnerText); string macAddress = "", ipAddress = ""; if (j == 1 && (MacCol.InnerText.ToString().StartsWith("No reserved rule"))) //No reserved rule! --R3.7 //Report.Info("No MAC filtering rule exists !!!"); { Report.Failure("MAC Filter ", "There are No DHCP Reservation list to delete !!"); TestSuite.Current.GetTestCase("Confirm_To_Delete_All_From_DHCP_Reservation").Checked = false; Delay.Seconds(1); Report.Screenshot("DHCP Reserved List", myTable.Element, true); return; } else if (j == 1 && !(MacCol.InnerText.ToString().StartsWith("No reserved rule"))) { //macAddress macAddress = MacCol.InnerText.ToString(); //Report.Info("macAddress",macAddress); } else if (j == 2) { //Report.Info(MacCol.InnerText); //macAddress = MacCol; ipAddress = MacCol.InnerText.ToString(); //Report.Info("ipAddress",ipAddress.ToString()); } else if (j == 3) { //Report.Info("---Checked delete box ---"); /* * WebElement webElement = MacCol.Element; * Delay.Seconds(2); * webElement.Click(); * Report.Screenshot("Delete MACFilter",webElement,true); */ //Report.Info(MacCol.GetInnerHtml().ToString()); //Report.Info("MacCol path: "+MacCol.GetPath().ToString()); String newPath = ""; newPath = MacCol.GetPath() + "/input[#'dhcpClientsTable-Delete-" + delCheck + "']"; //Report.Info("newPath : "+ newPath); Ranorex.InputTag DHCPClientsTableDeleteTag = newPath; // Report.Info("DHCPClientsTableDeleteTag(Default) : " + DHCPClientsTableDeleteTag.Checked.ToString()); if (DHCPClientsTableDeleteTag.Checked.ToString() == "False") { //Report.Info("----------------- DHCPClientsTableDeleteTag was False ---"); Delay.Seconds(1); DHCPClientsTableDeleteTag.PerformClick(); } else { //Report.Info("----------------- DHCPClientsTableDeleteTag was True ---"); Report.Info(" DHCPClientsTableDeleteTag is already Enabled "); } string rst = "The following DHCP Reserved List is selected to delete permanently !!!"; Report.Success(rst); Delay.Seconds(2); Report.Screenshot("DHCP Reserved List", MacCol.Element, true); //Report.Screenshot("DHCP Reserved List",myTable.Element,true); Delay.Seconds(2); j = 0; delCount++; delCheck++; } j++; } //end of TdTag for-loop if (delCount == rulesCount) { // to check whether it selected all rows for deletion string rst = "All the " + rulesCount.ToString() + " DHCP Reserved List(s) are deleted permanently !!!"; Report.Success(rst); Delay.Seconds(2); Report.Screenshot("DHCP Reserved List", myTable.Element, true); } else { Report.Info(" All rows are not deleted !!! "); } } } //end of method Choose_All_DHCP_Reserved_Rules_To_Delete()
public void Choose_Attached_Devices_To_Deny_Add_5GHz_Primary(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7) { ////choose device from the attached list //This method is to select any MAC filter rules to delete //argument1 - MAC Address0, argument2- MAC Address1 //argument3 - MAC Address2, argument4 - MAC Address3 //argument5 - MAC Address4, argument6 - MAC Address5 //argument7 - Access Mode Delay.Seconds(30); // to load the pages WebDocument webDocument = "/dom[@domain='192.168.0.1']"; //Report.Info(webDocument.GetHtml()); // choose the Access Mode //BssAccessModeGrp //Radio Button Options --> 1-DisableWMACFilter, 2-AllowAllDevices,3-DenyAllDevices String AccessModeGrpPath = ""; if (argument7 == "Disable") { Report.Info("It is DISABLE"); AccessModeGrpPath = "/dom[@domain='192.168.0.1']//input[@name='BssAccessModeGrp' and @type='radio' and @value='1']"; // Disable Ranorex.InputTag BssAccessModeGrpTag = AccessModeGrpPath; Delay.Seconds(1); BssAccessModeGrpTag.PerformClick(); Delay.Seconds(1); } else if (argument7 == "Allow") { Report.Info("It is ALLOW"); AccessModeGrpPath = "/dom[@domain='192.168.0.1']//input[@name='BssAccessModeGrp' and @type='radio' and @value='2']"; // Allow Ranorex.InputTag BssAccessModeGrpTag = AccessModeGrpPath; Delay.Seconds(1); BssAccessModeGrpTag.PerformClick(); Delay.Seconds(1); } else if (argument7 == "Deny") { Report.Info("It is DENY"); AccessModeGrpPath = "/dom[@domain='192.168.0.1']//input[@name='BssAccessModeGrp' and @type='radio' and @value='3']"; // Deny Ranorex.InputTag BssAccessModeGrpTag = AccessModeGrpPath; Delay.Seconds(1); BssAccessModeGrpTag.PerformClick(); Delay.Seconds(1); } // TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'AttachedDevicesTable']"); //Count the total no of IPv4 port Filter rules (rows) IList <TrTag> totalMACRules = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalMACRules.Count; string totalMACFilterRules = "Total Rules : " + rulesCount.ToString(); Report.Info("Active Attached Devices ", totalMACFilterRules); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("MAC Filter ", "There are no devices to add !!"); //TestSuite.Current.GetTestCase("Delete_Any_MAC_Filtering_Rules").Checked = false; 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; string macAddress = "", macAddress1 = "", devName = "", Wifi_Freq = ""; macAddress = argument1 + ":" + argument2 + ":" + argument3 + ":" + argument4 + ":" + argument5 + ":" + argument6; Report.Info("Inpute MAC ADDRESS : ", macAddress); foreach (var row in totalMACRules) { //Report.Info("Row: " + rowNum); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Columns in the Row : ",cols.Count.ToString()); int colNum = 1; String radiobuttonPath = ""; foreach (TdTag MacCol in cols) { Report.Info("MacCol: " + colNum); //Report.Info("MacCol Info: "+MacCol.InnerText); //Report.Info(MacCol.GetInnerHtml().ToString()); if (colNum == 1) { //radio button radiobuttonPath = MacCol.GetPath().ToString(); //Report.Info(MacCol.GetInnerHtml().ToString()); //Report.Info(radiobuttonPath); //Report.Info("Radio button Path:",radiobuttonPath); } else if (colNum == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { devName = spanVal.InnerText; } Report.Info("devName", devName); } else if (colNum == 3) { //Report.Info(MacCol.InnerText); //Report.Info(MacCol.GetInnerHtml().ToString()); //macAddress1 = MacCol.InnerText; IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); //Report.Info("span count : "+spanVals.Count); foreach (SpanTag spanVal in spanVals) { macAddress1 = spanVal.InnerText; //Report.Info("devName : ", devName); //Report.Info("MAC Address to Add : " + macAddress); //Report.Info("MAC Address1 : " + macAddress1); if (macAddress == macAddress1) { Report.Info("//--------------- MAC address exist in attached device list------//"); Report.Info("//--------------- Wifi_Freq---------------", Wifi_Freq); macAddress1 = spanVal.InnerText; Report.Info("Device Name ", devName); Report.Info("MAC Address to Add ", macAddress); Report.Info("Wifi_Freq " + Wifi_Freq); isMatch = true; String newPath = ""; //Report.Info("radiobuttonPath : ",radiobuttonPath.ToString()); //newPath = radiobuttonPath + "/input[#'attachedDevicesGroup']"; //newPath = "/dom[@domain='192.168.0.1']//tbody[#'AttachedDevicesTable_body']//input[@name='attachedDevicesGroup']"; //newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='2' ]"; int radVal = rowNum - 1; newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='" + radVal + "']"; // newPath ="/dom[@domain='192.168.0.1']//input[#'ipv4FilterTable-Enabled-"+delCheck+"']"; Ranorex.InputTag MACFilterAttachedDeviceTag = newPath; Delay.Seconds(1); //MACFilterAttachedDeviceTag.Checked = "True"; MACFilterAttachedDeviceTag.PerformClick(); //MACFilterAttachedDeviceTag.TagValue ="2"; Delay.Seconds(1); /* * if (MACFilterTableDeleteTag.Checked.ToString() == "False"){ * Delay.Seconds(1); * MACFilterTableDeleteTag.PerformClick(); * }else{ * Report.Info(" MACFilterTableDeleteTag is already Enabled "); * } */ string rst = "The following device is currently attached to this router !!!"; Report.Success(rst); //Report.Screenshot("MACFilter_Filtering",MacCol.Element,true); Report.Screenshot("MAC Filter_List", row.Element, true); break; } } //end of SpanTag for-loop } else if (colNum == 4) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { Wifi_Freq = spanVal.InnerText; } Report.Info("Wifi_Freq", Wifi_Freq); } colNum++; } //TdTag for-end loop if (isMatch) { break; } rowNum++; //addCheck++; //counter to select add checkbox } //ROW for-end loop //Report.Info("rowNum :: ",rowNum.ToString()); if (!isMatch) { //Report.Info(" Device does not exist in the attached list "); //Report.Info("devName : ", devName); //Report.Info("MAC Address to Add : " + macAddress); string rst = "The device : " + devName + "(" + macAddress + ")" + " does not exist in the attached list "; //Report.Failure("MAC Filter List"," This device does not exist in the attached list "); Report.Failure("MAC Filter List", rst); TestSuite.Current.GetTestCase("Add_Deny_Device_To_MAC_Address_List1").Checked = false; //Add_Deny_Device_To_MAC_Address_List1 } else { TestSuite.Current.GetTestCase("Add_Deny_Device_To_MAC_Address_List1").Checked = true; //Add_Deny_Device_To_MAC_Address_List1 } } //end of if-else }
public void Choose_All_MAC_Filter_Rules_To_Delete() { //This method is to select all the filter rules to delete Delay.Seconds(40); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; //Report.Info(webDocument.GetHtml()); TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'macFilterTable']"); //Count the total no of IPv4 port Filter rules (rows) IList <TrTag> totalMACRules = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalMACRules.Count; string totalMACFilterRules = "Total Rules : " + rulesCount.ToString(); Report.Info("Active MAC Filter Rules ", totalMACFilterRules); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("MAC Filter ", "There are no active rules to delete !!"); TestSuite.Current.GetTestCase("Delete_All_MAC_Filtering_Rules").Checked = false; TestSuite.Current.GetTestCase("Activate_MAC_Filtering_Rule_Always1").Checked = true; return; } else { //Report.Info(" There is/are " + rulesCount.ToString() + " row exists in MAC Filter table !!! "); Report.Info(" No. of rows exists in MAC Filter table : " + rulesCount.ToString()); //walkthrough the column values IList <TdTag> cols = myTable.Find <TdTag>("./tbody//td"); int colsCount = cols.Count; Report.Info("Total colsCount", colsCount.ToString()); int j = 1; int delCount = 0; int delCheck = 0; foreach (TdTag MacCol in cols) { Report.Info(j.ToString()); Report.Info(MacCol.InnerText); TdTag macAddress = null; //if(j==1 && (MacCol.InnerText.ToString().StartsWith("No MAC filtering"))){ if (j == 1 && (MacCol.InnerText.ToString().StartsWith("No MAC filtering rule!"))) //No MAC filtering rule! //Report.Info("No MAC filtering rule exists !!!"); { Report.Failure("MAC Filter ", "There are No MAC filtering rules to delete !!"); TestSuite.Current.GetTestCase("Delete_All_MAC_Filtering_Rules").Checked = false; TestSuite.Current.GetTestCase("Activate_MAC_Filtering_Rule_Always1").Checked = false; Delay.Seconds(1); Report.Screenshot("MAC_Filtering", myTable.Element, true); return; } else if (j == 2) { //Report.Info(MacCol.InnerText); macAddress = MacCol; } else if (j == 4) { //Report.Info("---Checked delete box ---"); /* * WebElement webElement = MacCol.Element; * Delay.Seconds(2); * webElement.Click(); * Report.Screenshot("Delete MACFilter",webElement,true); */ //Report.Info(MacCol.GetInnerHtml().ToString()); Report.Info("MacCol path: " + MacCol.GetPath().ToString()); String newPath = ""; //newPath = col.GetPath() + "/input[#'ipv4FilterTable-Delete-"+delCheck+"']"; // newPath = MacCol.GetPath() + "/input[#'fmChbx-macFilterTable-Delete-"+delCheck+"']"; newPath = MacCol.GetPath() + "/input[#'macFilterTable-Delete-" + delCheck + "']"; /* * /dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?macfilter&mid=MACFiltering']//tbody[#'macFilterTable_body']/tr[1]/td[3] * /dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?macfilter&mid=MACFiltering']//input[#'macFilterTable-Delete-0'] * /dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?macfilter&mid=MACFiltering']//b[#'fmChbx-macFilterTable-Delete-0'] */ Report.Info("macFilterTable-Delete checkbox "); Report.Info("newPath : " + newPath); Ranorex.InputTag MACFilterTableDeleteTag = newPath; // Report.Info("MACFilterTableDeleteTag(Default) : " + MACFilterTableDeleteTag.Checked.ToString()); if (MACFilterTableDeleteTag.Checked.ToString() == "False") { //Report.Info("----------------- MACFilterTableDeleteTag was False ---"); Delay.Seconds(1); MACFilterTableDeleteTag.PerformClick(); } else { Report.Info(" MACFilterTableDeleteTag is already Enabled "); } string rst = "The following MACFilter_Filtering rule is deleted permanently !!!"; Report.Success(rst); Delay.Seconds(1); //Report.Screenshot("MACFilter_Filtering",macAddress.Element,true); Report.Screenshot("MACFilter_Filtering", myTable.Element, true); Delay.Seconds(1); j = 0; delCount++; delCheck++; } j++; } //end of for-loop if (delCount == rulesCount) { // to check whether it selected all rows for deletion string rst = "The following " + rulesCount.ToString() + " MAC Filtering rules are deleted permanently !!!"; Report.Success(rst); Report.Screenshot("MAC_Filtering", myTable.Element, true); Delay.Seconds(1); TestSuite.Current.GetTestCase("Activate_MAC_Filtering_Rule_Always1").Checked = true; } else { Report.Info(" All rows are not deleted !!! "); TestSuite.Current.GetTestCase("Activate_MAC_Filtering_Rule_Always1").Checked = false; } } }
public void Choose_Connected_Device_To_Add_Duplicate_IPAddress(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6) { ////choose device from the attached list //This method is to select any MAC filter rules to delete //argument1 - MAC Address0, argument2- MAC Address1 //argument3 - MAC Address2, argument4 - MAC Address3 //argument5 - MAC Address4, argument6 - MAC Address5 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; bool isMatch = false; string macAddress = "", macAddress1 = "", IPAddress = "", devName = "", Wifi_Freq = ""; macAddress = argument1 + ":" + argument2 + ":" + argument3 + ":" + argument4 + ":" + argument5 + ":" + argument6; //Report.Info("macAddress",macAddress); 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 = ""; 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); //Report.Info(MacCol.GetInnerHtml().ToString()); if (colNum == 1) { //radio button radiobuttonPath = MacCol.GetPath().ToString(); //Report.Info(MacCol.GetInnerHtml().ToString()); //Report.Info(radiobuttonPath); //Report.Info("Radio button Path:",radiobuttonPath); } else if (colNum == 2) { //device name devName = MacCol.InnerText; } 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("//--------------- MAC address exist in attached device list------//"); //Report.Info("//--------------- Wifi_Freq -----",Wifi_Freq); macAddress1 = spanVal.InnerText; Report.Info("Device Name ", devName); Report.Info("MAC Address to Add ", macAddress); isMatch = true; String newPath = ""; int radVal = rowNum - 1; Report.Info("// rowNum //", rowNum.ToString()); Report.Info("// radVal //", radVal.ToString()); Report.Info("radiobuttonPath : ", radiobuttonPath); newPath = radiobuttonPath + "/input[@name='attachedDevicesGroup' and @type='radio' and @value='" + radVal + "']"; //below 2 lines added on 18/10/17 for code - 116.400 // /dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?dhcp_setting&mid=DHCP']//tbody[#'AttachedDevicesTable_body']/tr[3]/td[1]/input[@name='attachedDevicesGroup'] // newPath ="/dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?dhcp_setting&mid=DHCP']//tbody[#'AttachedDevicesTable_body']//input[@type='radio' and @value='"+radVal+"']"; Report.Info("newPath : ", newPath); Ranorex.InputTag MACFilterAttachedDeviceTag = newPath; Delay.Seconds(1); MACFilterAttachedDeviceTag.PerformClick(); Delay.Seconds(1); string rst = "The following DHCP Client is going to be added to the reserved list !!!"; Report.Info(rst); Report.Screenshot("DHCP_Reserved_List", row.Element, true); break; } } //end of SpanTag for-loop } else if (colNum == 4) { //Ip Address IPAddress = MacCol.InnerText; } else if (colNum == 6) { // frequency connected to IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { Wifi_Freq = spanVal.InnerText; } } colNum++; } //TdTag for-end loop //Report.Info("TdTag for-end loop"); if (isMatch) { //TestSuite.Current.GetTestCase("Collect_MAC_Address").Checked = true;//to receive MAC Address TestSuite.Current.GetTestCase("Collect_Last_Octate_MAC_Address").Checked = true; //to receive MAC Address TestSuite.Current.GetTestCase("Add_Duplicate_IPAddress_To_DHCP_Reservation").Checked = true; //Add_Duplicate_IPAddress_To_DHCP_Reservation Report.Info("Wifi_Freq", Wifi_Freq); if (Wifi_Freq.Trim() == " WI-FI 2.4G") { Report.Info("This device is connected to WI-FI 2.4G"); //choose the device and click radio button break; } else { Report.Info("This device is NOT connected to WI-FI 2.4G"); break; } //break; } rowNum++; } //ROW for-end loop //Report.Info("ROW for-end loop"); if (!isMatch) { string rst = "The device with MAC Address : " + "(" + macAddress + ")" + " : is not attached to this router at this moment "; //Report.Failure("DHCP_Reserved_List"," This device does not exist in the attached list "); Report.Failure("DHCP_Reserv", rst); //TestSuite.Current.GetTestCase("Collect_MAC_Address").Checked = false; TestSuite.Current.GetTestCase("Collect_Last_Octate_MAC_Address").Checked = true; //to receive MAC Address TestSuite.Current.GetTestCase("Add_Duplicate_IPAddress_To_DHCP_Reservation").Checked = false; //Add_Duplicate_IPAddress_To_DHCP_Reservation } //end of if } }
public void Choose_Any_5GHz_Wireless_MAC_Filtering_Device_To_Delete(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6, string argument7) { //choose any device to delete based on Device name and MAC addresses //argument7 - device name, argument1- MAC 0 ....and argument6-MAC5 // Delay.Seconds(30); 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 } Report.Info("DeviceName: " + argument7 + " - " + " MAC: " + argument1 + " : " + argument2 + " : " + argument3 + " : " + argument4 + " : " + argument5 + " : " + argument6); 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> totalMACRules = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalMACRules.Count; string totalMACFilterRules = "Total Rules : " + rulesCount.ToString(); Report.Info("Active MAC Filter Rules ", totalMACFilterRules); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("MAC Filter ", "There are no active rules to delete !!"); TestSuite.Current.GetTestCase("Delete_Any_MAC_Filtering_Rules").Checked = false; return; } else if (rulesCount == 1) // if there is only one row //walkthrough the column values { IList <TdTag> cols = myTable.Find <TdTag>("./tbody//td"); int colsCount = cols.Count; if (colsCount > 1) // if there is only one row, many columns { Report.Info(" Total column : " + colsCount.ToString()); Report.Info(" There is " + totalMACFilterRules + " Wireless Filter Rule to delete !!! "); int colNum = 1; int delCheck = 0; Boolean isMatch = false; string macAddress = "", macAddress1 = ""; macAddress = argument1 + ":" + argument2 + ":" + argument3 + ":" + argument4 + ":" + argument5 + ":" + argument6; Report.Info("MAC Address : " + macAddress); foreach (TdTag col in cols) { Report.Info("col: " + colNum); if (colNum == 2) { //Report.Info(MacCol.InnerText); macAddress1 = col.InnerText; Report.Info("MAC Address1 : " + macAddress1); } else if (colNum == 3) { if (macAddress == macAddress1) { isMatch = true; Report.Info("----------------- Rules Matches !!! ------"); String newPath = ""; newPath = col.GetPath() + "/input[#'macAddressFilterTable-Delete-" + delCheck + "']"; //fmChbx-macAddressFilterTable-Delete-0, macAddressFilterTable-Delete-0 Ranorex.InputTag MACFilterTableDeleteTag = newPath; if (MACFilterTableDeleteTag.Checked.ToString() == "False") { Report.Info("----------------- MACFilterTableDeleteTag was False ---"); Delay.Seconds(5); MACFilterTableDeleteTag.PerformClick(); } else { Report.Info(" MACFilterTableDeleteTag is already Enabled "); } string rst = "The following MACFilter_Filtering rule is deleted permanently !!!"; Report.Success(rst); Report.Screenshot("MACFilter_Filtering", myTable.Element, true); } } colNum++; } //end of for loop-col } else // if there is only one row, one column { Report.Info(" Total column : " + colsCount.ToString()); foreach (TdTag col in cols) { string noFilterStr = col.InnerText.ToString(); Report.Info(noFilterStr); // if(noFilterStr.StartsWith("No filtering")){ //No filtering device! if (noFilterStr.StartsWith("You have not selected a device to filter")) //You have not selected a device to filter { Report.Failure("MAC Filter Devices ", "There are no devie to delete !!"); TestSuite.Current.GetTestCase("Delete_Any_5GHz_Wireless_MAC_Filter_Device").Checked = false; return; } else { Report.Info(" There are " + rulesCount.ToString() + " MAC Filter Rule to delete !!! "); //check if the rule is matching the condition } } } } else // if there are many rows //Report.Info(" There are " + totalMACFilterRules + " MAC Filter Rules to delete !!! "); { Report.Info(" There are " + rulesCount.ToString() + " MAC Filter Rule(s) to delete !!! "); int rowNum = 1; int delCheck = 0; Boolean isMatch = false; string macAddress = "", macAddress1 = ""; macAddress = argument1 + ":" + argument2 + ":" + argument3 + ":" + argument4 + ":" + argument5 + ":" + argument6; Report.Info("MAC Address : " + macAddress); foreach (var row in totalMACRules) { // Report.Info("Row: " + rowNum); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); int colNum = 1; foreach (TdTag MacCol in cols) { //Report.Info("MacCol: " + colNum); //Report.Info("MacCol Info: "+MacCol.InnerText); if (colNum == 2) { //Report.Info(MacCol.InnerText); macAddress1 = MacCol.InnerText; Report.Info("MAC Address1 : " + macAddress1); } else if (colNum == 3) { // check if Mac address is matching //Report.Info("----------------- click delete checkbox ------"); if (macAddress == macAddress1) { isMatch = true; Report.Info("----------------- Rule Exist !!! ------"); String newPath = ""; newPath = MacCol.GetPath() + "/input[#'macAddressFilterTable-Delete-" + delCheck + "']"; //fmChbx-macAddressFilterTable-Delete-0, macAddressFilterTable-Delete-0 //dom[@domain='192.168.0.1']//b[#'fmChbx-macAddressFilterTable-Delete-1'] // Report.Info("newPath :" + newPath); Report.Info("--------- newPath orginal ---->> " + newPath); // newPath = "/dom[@page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.100.1/?wifi_settings&mid=WirelessPrimary']//tbody[#'macAddressFilterTable_body']/tr[1]/td[3]/" + "/input[#'macAddressFilterTable-Delete-"+delCheck+"']"; // newPath = "/dom[@page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?wifi_settings&mid=WirelessPrimary']/"+ "/input[#'macAddressFilterTable-Delete-"+delCheck+"']"; //original working statement // newPath = "/dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?wifi_settings&mid=WirelessSecurity']//input[#'macAddressFilterTable-Delete-31']"; //added on 17/10/17 for code -116.400 newPath = "/dom[@caption='Hub 3.0' and @page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?wifi_settings&mid=WirelessSecurity']//input[#'macAddressFilterTable-Delete-" + delCheck + "']"; //added on 17/10/17 for code -116.400 Report.Info("--------- newPath modified ---->> " + newPath); // The above code is added to test on Windows10 platform - 23Feb2017 Ranorex.InputTag MACFilterTableDeleteTag = newPath; if (MACFilterTableDeleteTag.Checked.ToString() == "False") { Report.Info("----------------- MACFilterTableDeleteTag was False ---"); Delay.Seconds(5); MACFilterTableDeleteTag.PerformClick(); Delay.Seconds(3); } else { Report.Info(" MACFilterTableDeleteTag is already Enabled "); } string rst = "The following MACFilter_Filtering rule is deleted permanently !!!"; Report.Success(rst); Report.Screenshot("MACFilter_Filtering", row.Element, true); } } colNum++; } // end of for-loop (column) if (isMatch) { break; } rowNum++; delCheck++; //counter to select delete checkbox } //end of for-loop (row) if ((rowNum - 1) == rulesCount && !isMatch) //if rule does not exist { TestSuite.Current.GetTestCase("Delete_Any_5GHz_Wireless_MAC_Filter_Device").Checked = false; Report.Info(" ===== This Rule does not exist ====="); Delay.Seconds(1); Report.Screenshot("MAC_Filtering_Devices", myTable.Element, true); } } }
public void Choose_Any_DHCP_Reserv_Rule_To_Delete(string argument1, string argument2) { //argument1 - MAC Address, argument2- IP Address //Choose_the _DHCP_Reserv_Rule_To_Delete 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[#'dhcpClientsTable']"); IList <TrTag> totalDHCPReservList = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalDHCPReservList.Count; Report.Info("Total Rows in the table :" + rulesCount.ToString()); // string totalDHCPReservListStr = "Total Reserv list : "+rulesCount.ToString(); // Report.Info("Active DHCP Reserv list ",totalDHCPReservListStr); if (rulesCount == 0) { Report.Failure("DHCP Reserv list ", "There are no active rules to delete !!"); TestSuite.Current.GetTestCase("Delete_Any_DHCP_Rule").Checked = false; return; } else { int rowNum = 1; int delCheck = 0; Boolean isMatch = false; string macAddress = "", macAddress1 = "", ipAddress = "", ipAddress1 = ""; macAddress = argument1; ipAddress = argument2; Report.Info("MAC Address to Delete : " + macAddress); Report.Info("IP Address tp delete: " + ipAddress); foreach (var row in totalDHCPReservList) { Report.Info("Row: " + rowNum); Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); if (cols.Count == 1) { Report.Info("There are no active rules to delete "); TestSuite.Current.GetTestCase("Delete_Any_DHCP_Rule").Checked = false; return; } Report.Info(" There are " + rulesCount.ToString() + " DHCP Rules in the Reserv list !!! "); int colNum = 1; foreach (TdTag MacCol in cols) { // Report.Info("MacCol: " + colNum); // Report.Info("MacCol Info: "+MacCol.InnerText); if (colNum == 1) { //Report.Info(MacCol.InnerText); macAddress1 = MacCol.InnerText; Report.Info("MAC Address in the Reserv list : " + macAddress1); } else if (colNum == 2) { ipAddress1 = MacCol.InnerText; Report.Info("IP Address in the Reserv list : " + ipAddress1); } else if (colNum == 3) { // check if Mac address is matching // Report.Info("----------------- click delete checkbox ------"); if (macAddress.Trim() == macAddress1.Trim()) { isMatch = true; Report.Info("----------------- Rules Matches !!! ------"); String newPath = ""; // Report.Info("delCheck ", delCheck.ToString()); newPath = MacCol.GetPath() + "/input[#'dhcpClientsTable-Delete-" + delCheck + "']"; Ranorex.InputTag DHCPReservTableDeleteTag = newPath; if (DHCPReservTableDeleteTag.Checked.ToString() == "False") { Report.Info("----------------- DHCPReservTableDeleteTag will be enabled now ---"); Delay.Seconds(1); DHCPReservTableDeleteTag.PerformClick(); Report.Screenshot("DHCPReserv_List", row.Element, true); Delay.Seconds(2); } else { Report.Info(" DHCPReservTableDeleteTag is already Enabled "); } Report.Success("The following DHCP Reserv rule is deleted permanently !!!"); Report.Screenshot("DHCPReserv_List", myTable.Element, false); } } colNum++; } // end of for-loop (column) if (isMatch) { break; } rowNum++; delCheck++; //counter to select delete checkbox } //end of for-loop (row) if ((rowNum - 1) == rulesCount && !isMatch) //if rule does not exist { Report.Info(" ===== This DHCP Rule does not exist ====="); Delay.Seconds(1); Report.Screenshot("DHCPReserv_List", myTable.Element, true); } } }
public void Choose_Any_MAC_Filtering_To_Delete(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6) { //This method is to select any MAC filter rules to delete //argument1 - MAC Address0, argument2- MAC Address1 //argument3 - MAC Address3, argument4 - MAC Address4 //argument5 - MAC Address5 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[#'macFilterTable']"); //Count the total no of IPv4 port Filter rules (rows) IList <TrTag> totalMACRules = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalMACRules.Count; string totalMACFilterRules = "Total Rules : " + rulesCount.ToString(); Report.Info("Active MAC Filter Rules ", totalMACFilterRules); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("MAC Filter ", "There are no active rules to delete !!"); TestSuite.Current.GetTestCase("Delete_Any_MAC_Filtering_Rules").Checked = false; return; } else { Report.Info(" There are " + totalMACFilterRules + " MAC Filter Rules to delete !!! "); int rowNum = 1; int delCheck = 0; Boolean isMatch = false; string macAddress = "", macAddress1 = ""; macAddress = argument1 + ":" + argument2 + ":" + argument3 + ":" + argument4 + ":" + argument5 + ":" + argument6; Report.Info("MAC Address : " + macAddress); foreach (var row in totalMACRules) { Report.Info("Row: " + rowNum); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); int colNum = 1; foreach (TdTag MacCol in cols) { //Report.Info("MacCol: " + colNum); //Report.Info("MacCol Info: "+MacCol.InnerText); if (colNum == 2) { //Report.Info(MacCol.InnerText); macAddress1 = MacCol.InnerText; Report.Info("MAC Address1 : " + macAddress1); } else if (colNum == 4) { // check if Mac address is matching //Report.Info("----------------- click delete checkbox ------"); if (macAddress == macAddress1) { isMatch = true; //Report.Info("----------------- Rules Matches !!! ------"); String newPath = ""; newPath = MacCol.GetPath() + "/input[#'macFilterTable-Delete-" + delCheck + "']"; Ranorex.InputTag MACFilterTableDeleteTag = newPath; if (MACFilterTableDeleteTag.Checked.ToString() == "False") { //Report.Info("----------------- MACFilterTableDeleteTag was False ---"); Delay.Seconds(1); MACFilterTableDeleteTag.PerformClick(); } else { Report.Info(" MACFilterTableDeleteTag is already Enabled "); } string rst = "The following MACFilter_Filtering rule is deleted permanently !!!"; Report.Success(rst); Report.Screenshot("MACFilter_Filtering", row.Element, true); } } colNum++; } // end of for-loop (column) if (isMatch) { break; } rowNum++; delCheck++; //counter to select delete checkbox } //end of for-loop (row) if ((rowNum - 1) == rulesCount && !isMatch) //if rule does not exist { Report.Info(" ===== This Rule does not exist ====="); Delay.Seconds(1); Report.Screenshot("MAC_Filtering", myTable.Element, true); } } //end of IF-ELSE }