private void Validate_Admin_Password__Change_Screen() { Delay.Seconds(30); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; webDocument.WaitForDocumentLoaded(); //Report.Info(webDocument.GetHtml()); TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'LoginSettings']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalDeviceRows.Count; Report.Info(" LoginSettings Password Table Rows : " + rulesCount); // bool isSuccess=true; if (rulesCount == 3) { int rowNum = 1; foreach (var row in totalDeviceRows) { IList <TdTag> cols = row.Find <TdTag>("./td"); int colNum = 1; foreach (TdTag MacCol in cols) { if (colNum == 1) { Report.Info("Col Info: " + MacCol.InnerText); //validate lable values } if (colNum == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); if (spanVals.Count == 1) { Report.Success("Password field validation is Success"); } /* * foreach(SpanTag spanVal in spanVals){ * devInfo = spanVal.InnerText; * if(devInfo.Length > 0){ * devInfoSubstr = devInfo.Substring(1,devInfo.Length-1); // for validation purpose * }else{ * //blank * devInfoSubstr = ""; * } * } */ } colNum++; } //end of Column rowNum++; } //end of ROW } else { Report.Failure("Issue with page display !!"); } }
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 Count_Wireless_Filtering() { //count total number of Wireless MAC filtering rules int TotalRows = 0; WebDocument webDocument1 = "/dom[@domain='192.168.0.1']"; webDocument1.WaitForDocumentLoaded(); Delay.Seconds(40); //TableTag myTable1 = webDocument1.FindSingle("/dom[@domain='192.168.0.1']//table[#'portTriggeringTable']"); TableTag myTable1 = webDocument1.FindSingle("/dom[@domain='192.168.0.1']//table[#'macAddressFilterTable']"); IList <TrTag> rows1 = myTable1.Find <TrTag>("./tbody//tr"); TotalRows = rows1.Count; int Wireless_5GHz_MAC = 0, Wireless_2GHz_MAC = 0; // if it is just 1 row need to check if it is an invalid filter if (TotalRows == 1) { IList <TdTag> cols = myTable1.Find <TdTag>("./tbody//td"); foreach (TdTag MacCol in cols) { //Report.Info("Column",j.ToString()); Report.Info(MacCol.InnerText); if (MacCol.InnerText.ToString().StartsWith("You have not selected")) //No reserved rule! --R3.8 // You have not selected a device to filter. Please select a device from the attached devices list. //Report.Info("No DHCP filtering rule exists !!!"); //return Wireless_5GHz_MAC; // Report.Failure("Wireless_Filter ","There are no Wireless_Filters !!"); { Report.Success("Wireless_Filter ", "There are no Wireless_Filters !!"); return; } else { Report.Info("Wireless_Filter", TotalRows.ToString()); break; } } } else { // int Wireless_5GHz_MAC=0, Wireless_2GHz_MAC=0; // Report.Info("DHCP_Resv Rule(s) ",rowsCnt.ToString()); Report.Info("Total Wireless_MAC_Filter: " + TotalRows.ToString()); //count 5GHz,2GHz filters separetly int rowNum = 1; string WirelessRadioType = ""; bool isSuccess = true; foreach (var row in rows1) { IList <TdTag> cols = row.Find <TdTag>("./td"); int colNum = 1; // Report.Info("rowNum: " + rowNum); foreach (TdTag MacCol in cols) { // Report.Info("colNum: " + colNum); // Report.Info("Col1 Info: "+MacCol.InnerText); if (colNum == 3) { // Report.Info(MacCol.GetInnerHtml().ToString()); IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); // Report.Info("span count : "+spanVals.Count); foreach (SpanTag spanVal in spanVals) { WirelessRadioType = spanVal.InnerText; // Report.Info("WirelessRadioType : " + WirelessRadioType); } //WirelessRadioType = MacCol.InnerText.Trim(); if ((WirelessRadioType.StartsWith("5GHz")) || (WirelessRadioType.StartsWith("5 GHz"))) { Wireless_5GHz_MAC++; } else if (WirelessRadioType.StartsWith("2.4GHz") || (WirelessRadioType.StartsWith("2.4 GHz"))) { Wireless_2GHz_MAC++; } else { isSuccess = false; Report.Info("Wireless_5GHz_MAC : " + Wireless_5GHz_MAC + " Wireless_2GHz_MAC : " + Wireless_2GHz_MAC); Report.Failure("WirelessRadioType is neither 5GHz nor 2.4GHz "); } } colNum++; } // end of COLUMN for-loop rowNum++; } //end of ROW for-loop if (isSuccess) { Report.Success("Wireless_5GHz_MAC Filter : " + Wireless_5GHz_MAC + "<====> " + "Wireless_2.4GHz_MAC Filter : " + Wireless_2GHz_MAC); } else { Report.Failure("WirelessRadioType is neither 5GHz nor 2.4GHz "); } } //end of IF_ELSE }
public int Count_Wireless_Filtering_Lists(string wirelessRadioType) { //count total number of Wireless MAC filtering rules Report.Info("---- inside Count_Wireless_Filtering_Lists --- "); int TotalRows = 0; WebDocument webDocument1 = "/dom[@domain='192.168.0.1']"; webDocument1.WaitForDocumentLoaded(); Delay.Seconds(40); //TableTag myTable1 = webDocument1.FindSingle("/dom[@domain='192.168.0.1']//table[#'portTriggeringTable']"); TableTag myTable1 = webDocument1.FindSingle("/dom[@domain='192.168.0.1']//table[#'macAddressFilterTable']"); // /dom[@domain='192.168.0.1']//table[#'macAddressFilterTable'] IList <TrTag> rows1 = myTable1.Find <TrTag>("./tbody//tr"); TotalRows = rows1.Count; int Wireless_5GHz_MAC = 0, Wireless_2GHz_MAC = 0; bool isSuccess = true; Report.Info("Total Wireless_MAC_Filter: " + TotalRows.ToString()); if (TotalRows == 1) { IList <TdTag> cols = myTable1.Find <TdTag>("./tbody//td"); foreach (TdTag MacCol in cols) { Report.Info(MacCol.InnerText); if (MacCol.InnerText.ToString().StartsWith("You have not selected")) { return(0); } else { return(1); } } return(0); } else { Report.Info("Total Wireless_MAC_Filter: " + TotalRows.ToString()); int rowNum = 1; string WirelessRadioType = ""; foreach (var row in rows1) { IList <TdTag> cols = row.Find <TdTag>("./td"); int colNum = 1; // Report.Info("rowNum: " + rowNum); foreach (TdTag MacCol in cols) { // Report.Info("colNum: " + colNum); // Report.Info("Col1 Info: "+MacCol.InnerText); if (colNum == 3) { // Report.Info(MacCol.GetInnerHtml().ToString()); IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); // Report.Info("span count : "+spanVals.Count); foreach (SpanTag spanVal in spanVals) { WirelessRadioType = spanVal.InnerText; // Report.Info("WirelessRadioType : " + WirelessRadioType); } //WirelessRadioType = MacCol.InnerText.Trim(); if ((WirelessRadioType.StartsWith("5GHz")) || (WirelessRadioType.StartsWith("5 GHz"))) { Wireless_5GHz_MAC++; isSuccess = true; } else if ((WirelessRadioType.StartsWith("2.4GHz")) || (WirelessRadioType.StartsWith("2.4 GHz"))) { Wireless_2GHz_MAC++; isSuccess = true; } else { isSuccess = false; //Report.Failure("WirelessRadioType is neither 5GHz nor 2.4GHz "); Wireless_5GHz_MAC = 0; Wireless_2GHz_MAC = 0; break; } } colNum++; } // end of COLUMN for-loop rowNum++; } //end of ROW for-loop //return 0; if (isSuccess) { Report.Info("Wireless_5GHz_MAC Filter : " + Wireless_5GHz_MAC + "<====> " + "Wireless_2.4GHz_MAC Filter : " + Wireless_2GHz_MAC); if ((wirelessRadioType.StartsWith("5GHz")) || (wirelessRadioType.StartsWith("5 GHz"))) { return(Wireless_5GHz_MAC); } else if ((wirelessRadioType.StartsWith("2.4GHz")) || (wirelessRadioType.StartsWith("2.4 GHz"))) { return(Wireless_2GHz_MAC); } else { return(0); } } else { Report.Info("WirelessRadioType is neither 5GHz nor 2.4GHz "); if ((wirelessRadioType.StartsWith("5GHz")) || (wirelessRadioType.StartsWith("5 GHz"))) { return(Wireless_5GHz_MAC); } else if ((wirelessRadioType.StartsWith("2.4GHz")) || (wirelessRadioType.StartsWith("2.4 GHz"))) { return(Wireless_2GHz_MAC); } else { return(0); } } } //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_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_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_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 Verify_Device_Info_IPv6(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6) { //Standard specification compliant : argument1 //Hardware version : argument2 //Software version : argument3 //Cable modem serial number : argument4 //Network access : argument5 //Cable MAC address : argument6 Report.Info(" INSIDE Verify_Device_Info_IPv6 "); Duration newDuration = new Duration(240000); repo.WebDocument19216801.DivButtonsInfo.WaitForExists(newDuration); //----- Hub3.0 device info ----// //Hardware version, software ver,Cable Mac,cable modem serial number, system up time, netork access WebDocument webDocument = "/dom[@domain='192.168.0.1']"; webDocument.WaitForDocumentLoaded(); // Report.Info(webDocument.GetHtml()); TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'Hub 3.0 device information']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalDeviceRows.Count; string totalDeviceInfoRows = rulesCount.ToString() + " : Rows :"; Report.Info(" Hub 3.0 device information ", totalDeviceInfoRows); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no active Hub 3.0 device information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows + " in Hub 3.0 device information !!! "); int rowNum = 1; string devInfo = "", devInfoCol1 = "", deviceInfo = "", devInfoSubstr = ""; foreach (var row in totalDeviceRows) { 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); if (colNum == 1) { devInfoCol1 = MacCol.InnerText; //Report.Info("Col1 Info: "+MacCol.InnerText); //Report.Info("Col1 Info: " + devInfoCol1); } if (colNum == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { devInfo = spanVal.InnerText; if (devInfo.Length > 0) { devInfoSubstr = devInfo.Substring(1, devInfo.Length - 1); // for validation purpose } else { //blank devInfoSubstr = ""; } //Report.Info( " devInfoSubstr " + devInfoSubstr); } //Report.Info("Col2 Info: "+devInfo); deviceInfo = devInfoCol1 + " "+ devInfo; //Report.Info( devInfoCol1 + " " + devInfo); Report.Info(deviceInfo); //Report.LogHtml(ReportLevel.Info, "deviceInfo", "<a>deviceInfo</a>"); //perform Hub 3.0 device information validation here //Standard specification compliant : DOCSIS 3.0 //Hardware version : 10 //Software version : 9.1.116V //Cable MAC address : C0:05:C2:00:24:1B //Cable modem serial number : AAAP51770041 //System up time : 0 days 17h:38m:47s //Network access : Allowed if (rowNum == 1) { //Standard specification compliant if (devInfoSubstr.Length == 0) { Report.Failure(" Standard specification compliant is BLANK "); } else if (devInfoSubstr.Trim().Equals(argument1.Trim())) { Report.Success(" Standard specification compliant "+ " PASS"); } else { Report.Failure(" Standard specification compliant "+ " FAIL"); } } else if (rowNum == 2) { //Hardware Version if (devInfoSubstr.Length == 0) { Report.Failure(" Hardware Version is BLANK "); } else if (devInfoSubstr.Trim() == argument2.Trim()) { Report.Success(" Hardware Version "+ " PASS"); } else { Report.Failure(" Hardware Version "+ " FAIL"); } } else if (rowNum == 3) { //Software Version if (devInfoSubstr.Length == 0) { Report.Failure(" Software Version is BLANK "); } else if (devInfoSubstr.Trim() == argument3.Trim()) { Report.Success(" Software Version "+ " PASS"); } else { Report.Failure(" Software Version "+ " FAIL"); } } else if (rowNum == 4) { //MAC Address - C0:05:C2:00:24:1B if (devInfoSubstr.Length == 0) { Report.Failure(" MAC Address is BLANK "); } else if (devInfoSubstr.Trim() == argument6.Trim()) { Report.Success(" MAC Address "+ " PASS"); } else { Report.Failure(" MAC Address "+ " FAIL"); } } else if (rowNum == 5) { //Cable modem serial number if (devInfoSubstr.Length == 0) { Report.Failure(" Cable modem serial number is BLANK "); } else if (devInfoSubstr.Trim() == argument4.Trim()) { Report.Success(" Cable modem serial number "+ " PASS"); } else { //validate Cable modem serial number Report.Failure(" Cable modem serial number "+ " FAIL"); } } else if (rowNum == 6) { //System up time if (devInfoSubstr.Length == 0) { Report.Failure(" System uptime is BLANK "); } else { //Validate system time format //Report.Info("Need to Validate system time format"); //Report.Failure(" System up time " + " FAIL"); } } else if (rowNum == 7) { //Network access if (devInfoSubstr.Length == 0) { Report.Failure(" Network access is BLANK "); } else if (devInfoSubstr.Trim() == argument5.Trim()) { Report.Success(" Network access "+ " PASS"); } else { Report.Failure(" Network access "+ " FAIL"); } } } colNum++; } // end of COLUMN for-loop rowNum++; } //end of totalDeviceRows for-loop } //end if IF-ELSE //-------------------------- WANIPSettingInfo - MAC Address ------------------------------// // /dom[@page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?device_status&mid=Info']//div[#'WANIPSettingInfo}}']/table //MAC address TableTag myTable3 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'WANIPSettingInfo}}']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows3 = myTable3.Find <TrTag>("./tbody//tr"); int rulesCount3 = totalDeviceRows3.Count; string totalDeviceInfoRows3 = rulesCount3.ToString() + " : Rows :"; Report.Info(" Hub 3.0 WANIPSettingInfo ", totalDeviceInfoRows3); if (rulesCount3 == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no WAN IP information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows3 + " in Hub 3.0 WANIPSettingInfo !!! "); int rowNum3 = 1; string WANIPInfo3 = "", WANIPInfoCol3 = "", WANInfo3 = "", WANIPInfoSubstr3 = ""; foreach (var row in totalDeviceRows3) { Report.Info("Row: " + rowNum3); Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum3 = 1; foreach (TdTag MacCol in cols) { Report.Info("MacCol: " + colNum3); if (colNum3 == 1) { WANIPInfoCol3 = MacCol.InnerText; Report.Info("Col1 Info: " + WANIPInfoCol3); } else if (colNum3 == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { WANIPInfo3 = spanVal.InnerText; WANIPInfoSubstr3 = WANIPInfo3.Substring(1, WANIPInfo3.Length - 1); // for validation purpose // Report.Info( " WANIPInfoSubstr " + WANIPInfoSubstr1); } WANInfo3 = WANIPInfoCol3 + " "+ WANIPInfo3; Report.Info(WANInfo3); if (rowNum3 == 1) { //MAC Address - C0:05:C2:CF:14:9D if (WANIPInfoSubstr3.Length == 0) { Report.Failure(" MAC Address is BLANK "); } else if (WANIPInfoSubstr3.Trim() != argument6.Trim()) { Report.Success(" MAC Address "+ " PASS"); } else { Report.Failure(" MAC Address "+ " FAIL"); } } } colNum3++; } // end of COLUMN for-loop rowNum3++; } //end of ROW for-loop : totalDeviceRows4 } //end if IF-ELSE : WAN IP settings -Info //------------------------------------- WAN IP settings - IPv6 Info -----------------------------------------------------// // IPv6 address, default gateway,IPv6 lease time, IPv6 lease expire, IPv6 DNS server TableTag myTable1 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'WANIPv6Info']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows1 = myTable1.Find <TrTag>("./tbody//tr"); int rulesCount1 = totalDeviceRows1.Count; string totalDeviceInfoRows1 = rulesCount1.ToString() + " : Rows :"; Report.Info(" Hub 3.0 WAN IPv6 information ", totalDeviceInfoRows1); if (rulesCount1 == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no WAN IP information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows1 + " in Hub 3.0 WAN IPv6 information !!! "); int rowNum1 = 1; string WANIPInfo1 = "", WANIPInfoCol1 = "", WANInfo1 = "", WANIPInfoSubstr1 = ""; foreach (var row in totalDeviceRows1) { Report.Info("Row: " + rowNum1); Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum1 = 1; foreach (TdTag MacCol in cols) { Report.Info("MacCol: " + colNum1); if (colNum1 == 1) { WANIPInfoCol1 = MacCol.InnerText; Report.Info("Col1 Info: " + WANIPInfoCol1); } else if (colNum1 == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { WANIPInfo1 = spanVal.InnerText; WANIPInfoSubstr1 = WANIPInfo1.Substring(1, WANIPInfo1.Length - 1); // for validation purpose // Report.Info( " WANIPInfoSubstr " + WANIPInfoSubstr1); } WANInfo1 = WANIPInfoCol1 + " "+ WANIPInfo1; Report.Info("WANInfo1 : " + WANInfo1); // Row: 1 IPv6 address // Row: 2 IPv6 default gateway // Row: 3 IPv6 lease time // Row: 4 IPv6 lease expire // Row: 5 IPv6 DNS servers if (rowNum1 == 1 || rowNum1 == 2 || rowNum1 == 5) { Report.Info(" To check IPv6 address type "); } else if (rowNum1 == 3) //IPv6 lease time { if (WANIPInfoSubstr1.Length == 0) { Report.Failure(" InValid IPv6 lease time "); } else { Report.Success(" Valid IPv6 lease time "); } } else if (rowNum1 == 4) //IPv6 lease expire //2017-08-10 11:56:40.00 { if (WANIPInfoSubstr1.Length == 0) { Report.Failure(" InValid IPv6 lease expire "); } else { Boolean CheckDateTime = CheckDateTimeValid(WANIPInfoSubstr1.Trim()); //calling CheckDateTimeValid() if (CheckDateTime) { Report.Success(" Valid IPv6 lease expire "); } else { Report.Failure(" InValid IPv6 lease expire "); } } } } colNum1++; } // end of COLUMN for-loop rowNum1++; } //end of ROW for-loop : totalDeviceRows1 } //end if IF-ELSE : WAN IP settings - IPv6 Info //-------------------------- WAN IP settings - IPv4 Info ------------------------------------------// //MAC address, IPv4 address, default gateway,IPv4 lease time, IPv4 lease expire, IPv4 DNS server TableTag myTable2 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'WANIPv4Info']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows2 = myTable2.Find <TrTag>("./tbody//tr"); int rulesCount2 = totalDeviceRows2.Count; string totalDeviceInfoRows2 = rulesCount2.ToString() + " : Rows :"; Report.Info(" Hub 3.0 WAN IP information ", totalDeviceInfoRows2); if (rulesCount2 == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no WAN IP information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows2 + " in Hub 3.0 WANIPv4 information !!! "); int rowNum2 = 1; string WANIPInfo2 = "", WANIPInfoCol2 = "", WANInfo2 = "", WANIPInfoSubstr2 = ""; foreach (var row in totalDeviceRows2) { Report.Info("Row: " + rowNum2); // Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum2 = 1; foreach (TdTag MacCol in cols) { Report.Info("MacCol: " + colNum2); if (colNum2 == 1) { WANIPInfoCol2 = MacCol.InnerText; //Report.Info("Col1 Info: "+MacCol.InnerText); //Report.Info("Col1 Info: "+WANIPInfoCol1); } else if (colNum2 == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { WANIPInfo2 = spanVal.InnerText; WANIPInfoSubstr2 = WANIPInfo2.Substring(1, WANIPInfo2.Length - 1); // for validation purpose //Report.Info( " WANIPInfoSubstr " + WANIPInfoSubstr); } Report.Info("Col2 Info: " + WANIPInfo2); WANInfo2 = WANIPInfoCol2 + " "+ WANIPInfo2; //Report.Info( WANIPInfoCol1 + " " + WANIPInfo); Report.Info("WANInfo2 : " + WANInfo2); //Report.LogHtml(ReportLevel.Info, "WANInfo", "<a>WANInfo</a>"); //perform WAN IP Settings validation here //IPv4 address : 80.2.153.121 //Default gateway : 80.2.153.97 //IPv4 lease time : 0 days 19h:24m:26s //IPv4 lease expire : 2016-07-01 04:09:29.00 //IPv4 DNS servers : 194.168.4.100 if (rowNum2 == 1 || rowNum2 == 2 || rowNum2 == 5) { //IP Address Validation if (WANIPInfoSubstr2.Length == 0) { Report.Failure(" InValid IP Address "); } else { Boolean CheckIPAddress = CheckIPAddressValid(WANIPInfoSubstr2.Trim()); //Calling CheckIPAddressValid() if (CheckIPAddress) { Report.Success("Valid IP Address"); } else { Report.Failure("InValid IP Address....It is : " + WANIPInfoSubstr2); } } } else if (rowNum2 == 3) { //IPv4 lease time validation if (WANIPInfoSubstr2.Length == 0) { Report.Failure(" InValid IPv4 lease time "); } else { /* * Boolean CheckDateTime = CheckDateTimeValid(WANIPInfoSubstr.Trim()); //calling CheckDateTimeValid() * if(CheckDateTime){ * Report.Success(" Valid IPv4 lease time "); * }else{ * Report.Failure(" InValid IPv4 lease time "); * } */ Report.Success(" Valid IPv4 lease time "); } } else if (rowNum2 == 4) { //string input = "2016-07-15 09:21:27.00"; //"???" if (WANIPInfoSubstr2.Length == 0) { Report.Failure(" InValid IPv4 lease expire "); } else { Boolean CheckDateTime = CheckDateTimeValid(WANIPInfoSubstr2.Trim()); //calling CheckDateTimeValid() //Boolean CheckDateTime = CheckDateTimeValid("???"); if (CheckDateTime) { Report.Success(" Valid IPv4 lease expire "); } else { Report.Failure(" InValid IPv4 lease expire "); } } } //end of rowNum1 IF-ELSE } colNum2++; } // end of COLUMN for-loop rowNum2++; } //end of ROW for-loop : totalDeviceRows1 } //end if IF-ELSE : WAN IP settings - IPv6 Info //--------------------------------------------- WANDSLiteInfo --------------------------------------------------------// // /dom[@page='' and @path='/' and @browsername='IE' and @pageurl='http://192.168.0.1/?device_status&mid=Info']//div[#'WANDSLiteInfo']/table TableTag myTable4 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'WANDSLiteInfo']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows4 = myTable4.Find <TrTag>("./tbody//tr"); int rulesCount4 = totalDeviceRows4.Count; string totalDeviceInfoRows4 = rulesCount4.ToString() + " : Rows :"; Report.Info(" Hub 3.0 WANDSLiteInfo ", totalDeviceInfoRows4); if (rulesCount4 == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no WANDSLiteInfo !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows4 + " in Hub 3.0 WANDSLiteInfo !!! "); int rowNum4 = 1; string WANIPInfo4 = "", WANIPInfoCol4 = "", WANInfo4 = "", WANIPInfoSubstr4 = ""; foreach (var row in totalDeviceRows4) { Report.Info("Row: " + rowNum4); Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum4 = 1; foreach (TdTag MacCol in cols) { Report.Info("MacCol: " + colNum4); colNum4++; } // end of COLUMN for-loop rowNum4++; } //end of ROW for-loop : totalDeviceRows4 } //end if IF-ELSE : WANDSLiteInfo }
public void Validate_Router_Status_Configuration() { //validate router status configuration tables -> Configuration, PrimaryDWFlow, PrimaryUPFlow Delay.Seconds(30); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; webDocument.WaitForDocumentLoaded(); //validate the Configuration table rows & columns // TableTag configTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'configuration']"); TableTag configTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'configuration']//table[@id='configuration']"); IList <TrTag> totalRows = configTable.Find <TrTag>("./tbody//tr"); int configRowsCount = totalRows.Count; // string totalConfigRowsCnt = "Total Rows(Configuration) : "+configRowsCount.ToString(); string totalConfigRowsCnt = configRowsCount.ToString(); Report.Info("Total Items(Configuration) ", totalConfigRowsCnt); if (configRowsCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no Router status-Configuration information !!"); return; } else { Report.Info(" There are " + totalConfigRowsCnt + " in General Configuration information !!! "); int rowNum = 1; string configInfo = "", configInfoTitle = ""; foreach (var row in totalRows) { Report.Info("Configuration -Row#: " + rowNum); // Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); Report.Info(" Configuration -Row-Total Columns ", cols.Count.ToString()); int colNum = 1; foreach (TdTag MacCol in cols) { // Report.Info("Configuration Col # " + colNum); if (colNum == 1) { configInfoTitle = MacCol.InnerText; // Report.Info("Col1 Info: "+MacCol.InnerText); Report.Info("Col1 Info: " + configInfoTitle); } if (colNum == 2) { IList <DivTag> divVals = MacCol.Find <DivTag>("./div"); // Report.Info("divVals count : " + divVals.Count.ToString()); foreach (DivTag divVal in divVals) { IList <SpanTag> spanVals = divVal.Find <SpanTag>("./span"); // Report.Info("spanVals count : " + spanVals.Count.ToString()); foreach (SpanTag spanVal in spanVals) { configInfo = spanVal.InnerText; } Report.Info("Col2 Info: " + configInfo); } } colNum++; } rowNum++; } //end of totalRows } //end if IF-ELSE -Configuration //validate the PPrimary Downstream Service Flow table rows & columns TableTag primaryDWTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'primaryDWFlow']"); IList <TrTag> totalRows1 = primaryDWTable.Find <TrTag>("./tbody//tr"); int primaryDWRowsCount = totalRows1.Count; // string totalPrimaryDWRowsCount = "Total Rows(primaryDW) : "+primaryDWRowsCount.ToString(); string totalPrimaryDWRowsCount = primaryDWRowsCount.ToString(); Report.Info("Total Items(PrimaryDW) ", totalPrimaryDWRowsCount); if (primaryDWRowsCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no Primary Downstream Service Flow information !!"); return; } else { Report.Info(" There are " + totalPrimaryDWRowsCount + " in Primary Downstream Service Flow information !!! "); int rowNum = 1; string primaryDWInfo = "", primaryDWInfoTitle = ""; foreach (var row in totalRows1) { Report.Info("Configuration -Row#: " + rowNum); // Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); Report.Info(" Configuration -Row-Total Columns ", cols.Count.ToString()); int colNum = 1; foreach (TdTag MacCol in cols) { // Report.Info("Configuration Col # " + colNum); if (colNum == 1) { primaryDWInfoTitle = MacCol.InnerText; // Report.Info("Col1 Info: "+MacCol.InnerText); Report.Info("Col1 Info: " + primaryDWInfoTitle); } if (colNum == 2) { primaryDWInfo = MacCol.InnerText; // Report.Info("Col2 Info: "+MacCol.InnerText); IList <DivTag> divVals = MacCol.Find <DivTag>("./div"); // Report.Info("divVals count : " + divVals.Count.ToString()); foreach (DivTag divVal in divVals) { IList <SpanTag> spanVals = divVal.Find <SpanTag>("./span"); // Report.Info("spanVals count : " + spanVals.Count.ToString()); foreach (SpanTag spanVal in spanVals) { primaryDWInfo = spanVal.InnerText; } Report.Info("Col2 Info: " + primaryDWInfo); } Report.Info("Col2 Info: " + primaryDWInfo); } colNum++; } rowNum++; } //end of totalRows } //end if IF-ELSE -Configuration //validate the Primary Upstream Service Flow table rows & columns TableTag primaryUPTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'primaryUPFlow']"); IList <TrTag> totalRows2 = primaryUPTable.Find <TrTag>("./tbody//tr"); int primaryUPRowsCount = totalRows2.Count; // string totalPrimaryUPRowsCount = "Total Rows(primaryUP) : "+primaryUPRowsCount.ToString(); string totalPrimaryUPRowsCount = primaryUPRowsCount.ToString(); Report.Info("Total Items(PrimaryUP) ", totalPrimaryUPRowsCount); if (primaryUPRowsCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no Primary Upstrean Service Flow information !!"); return; } else { Report.Info(" There are " + primaryUPRowsCount + " in Primary Upstrean Service Flow information !!! "); int rowNum = 1; string primaryUPInfo = "", primaryUPInfoTitle = ""; foreach (var row in totalRows2) { Report.Info("Configuration -Row#: " + rowNum); // Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); Report.Info(" Configuration -Row-Total Columns ", cols.Count.ToString()); int colNum = 1; foreach (TdTag MacCol in cols) { // Report.Info("Configuration Col # " + colNum); if (colNum == 1) { primaryUPInfoTitle = MacCol.InnerText; // Report.Info("Col1 Info: "+MacCol.InnerText); Report.Info("Col1 Info: " + primaryUPInfoTitle); } if (colNum == 2) { primaryUPInfo = MacCol.InnerText; // Report.Info("Col2 Info: "+MacCol.InnerText); IList <DivTag> divVals = MacCol.Find <DivTag>("./div"); // Report.Info("divVals count : " + divVals.Count.ToString()); foreach (DivTag divVal in divVals) { IList <SpanTag> spanVals = divVal.Find <SpanTag>("./span"); // Report.Info("spanVals count : " + spanVals.Count.ToString()); foreach (SpanTag spanVal in spanVals) { primaryUPInfo = spanVal.InnerText; } Report.Info("Col2 Info: " + primaryUPInfo); } Report.Info("Col2 Info: " + primaryUPInfo); } colNum++; } rowNum++; } //end of totalRows } //end if IF-ELSE -Configuration }
public void WPS_PIN_Verification_Validation() { Delay.Seconds(5); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'PriSecurityStatusTable']"); IList <TdTag> cols = myTable.Find <TdTag>("./tbody//td"); //Report.Info(" Total columns ",cols.Count.ToString()); bool isValidPIN = true; string WPSPIN = ""; foreach (TdTag col in cols) { WPSPIN = col.InnerText.ToString(); //Report.Info("WPS PIN Value",col.InnerText); Report.Info("WPS PIN Value", WPSPIN); //Report.Info("WPS PIN Length",col.InnerText.Length.ToString()); Report.Info("WPS PIN Length", WPSPIN.Length.ToString()); //if(col.InnerText.Length < 8){ if (WPSPIN.Length < 8) { isValidPIN = false; } else { break; } } if (isValidPIN) { Report.Success("Valid WPS PIN"); } else { Report.Failure("Invalid WPS PIN"); } TableTag table_WPS_PIN = webDocument.FindSingle("/dom[@domain='192.168.0.1']//table[#'PriSecurityStatusTable']"); Report.Screenshot("WPS_PIN_Length", table_WPS_PIN.Element, false); //Navigate to Admin-Info Report.Info("Verify the PIN with IP Address and BOX serial Number"); Ranorex.ATag Admin = "/dom[@domain='192.168.0.1']//li[#'Admin']/a[@innertext='Admin']"; Admin.DoubleClick(); //Admin.PerformClick(); Delay.Seconds(2); Ranorex.ATag AdminInfo = "/dom[@domain='192.168.0.1']//li[#'Info']/a[@innertext='Info']"; AdminInfo.DoubleClick(); AdminInfo.PerformClick(); Delay.Seconds(2); // Verify the PIN with cable modem serial Number // Delay.Seconds(20); TableTag myTable1 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'Hub 3.0 device information']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows1 = myTable1.Find <TrTag>("./tbody//tr"); int rulesCount1 = totalDeviceRows1.Count; string totalDeviceInfoRows1 = rulesCount1.ToString() + " : Rows :"; //Report.Info(" Hub 3.0 device information ",totalDeviceInfoRows1); // string cableSerialNumber=""; if (rulesCount1 == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no active Hub 3.0 device information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows1 + " in Hub 3.0 device information !!! "); int rowNum = 1; string devInfo = "", devInfoCol1 = "", deviceInfo = "", devInfoSubstr = ""; foreach (var row in totalDeviceRows1) { //Report.Info("Row: " + rowNum); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols1 = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum = 1; foreach (TdTag MacCol in cols1) { //Report.Info("MacCol: " + colNum); if (colNum == 1) { devInfoCol1 = MacCol.InnerText; //Report.Info("Col1 Info: "+MacCol.InnerText); //Report.Info("Col1 Info: " + devInfoCol1); } if (colNum == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { devInfo = spanVal.InnerText; if (devInfo.Length > 0) { devInfoSubstr = devInfo.Substring(1, devInfo.Length - 1); // for validation purpose } else { //blank devInfoSubstr = ""; } //Report.Info( " devInfoSubstr " + devInfoSubstr); } //Report.Info("Col2 Info: "+devInfo); deviceInfo = devInfoCol1 + " "+ devInfo; //Report.Info( devInfoCol1 + " " + devInfo); //Report.Info(deviceInfo); if (rowNum == 4) { //MAC Address - C0:05:C2:00:24:1B ( Arris1) if (devInfoSubstr.Length == 0) { Report.Failure(" MAC Address is BLANK "); } else if (devInfoSubstr.Trim() != WPSPIN) { Report.Info("WPSPIN : " + WPSPIN + " MAC Address : " + devInfoSubstr); Report.Success(" WPS PIN is different from MAC Address "+ " PASS"); } else { Report.Failure(" MAC Address "+ " FAIL"); } } else if (rowNum == 5) { //Cable modem serial number if (devInfoSubstr.Length == 0) { Report.Failure(" Cable modem serial number is BLANK "); } else if (devInfoSubstr.Trim() != WPSPIN) { Report.Info("WPSPIN : " + WPSPIN + " Cable Modem Serial Number : " + devInfoSubstr); Report.Success(" WPS PIN is different from Modem Serial Number "+ " PASS"); } else { //validate Cable modem serial number Report.Failure(" WPS PIN "+ " FAIL"); } } } colNum++; } //end of COLUMN forloop rowNum++; } //end of ROW forloop } //Verify the PIN with IP Addresses // Delay.Seconds(20); TableTag myTable2 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'WANIPv4Info']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows2 = myTable2.Find <TrTag>("./tbody//tr"); int rulesCount2 = totalDeviceRows2.Count; string totalDeviceInfoRows2 = rulesCount2.ToString() + " : Rows :"; //Report.Info(" Hub 3.0 WAN IP information Rows ",totalDeviceInfoRows2); if (rulesCount2 == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no WAN IP information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows2 + " in Hub 3.0 WAN IP information !!! "); int rowNum1 = 1; string WANIPInfo = "", WANIPInfoCol1 = "", WANInfo = "", WANIPInfoSubstr = ""; // string deviceIPAddress="",deviceGatwayIP=""; foreach (var row in totalDeviceRows2) { //Report.Info("Row: " + rowNum1); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols2 = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum1 = 1; foreach (TdTag MacCol in cols2) { //Report.Info("MacCol: " + colNum1); if (colNum1 == 1) { WANIPInfoCol1 = MacCol.InnerText; //Report.Info("Col1 Info: "+MacCol.InnerText); //Report.Info("Col1 Info: "+WANIPInfoCol1); } if (colNum1 == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { WANIPInfo = spanVal.InnerText; WANIPInfoSubstr = WANIPInfo.Substring(1, WANIPInfo.Length - 1); // for validation purpose //Report.Info( " WANIPInfoSubstr " + WANIPInfoSubstr); } //Report.Info("Col2 Info: "+WANIPInfo); WANInfo = WANIPInfoCol1 + " "+ WANIPInfo; //Report.Info( WANIPInfoCol1 + " " + WANIPInfo); //Report.Info(WANInfo); //Report.LogHtml(ReportLevel.Info, "WANInfo", "<a>WANInfo</a>"); //IPv4 address : 80.2.153.121 //Default gateway : 80.2.153.97 //IPv4 lease time : 0 days 19h:24m:26s //IPv4 lease expire : 2016-07-01 04:09:29.00 //IPv4 DNS servers : 194.168.4.100 if (rowNum1 == 1 || rowNum1 == 2 || rowNum1 == 5) { //IP Address Validation if (WANIPInfoSubstr.Length == 0) { Report.Failure(" InValid IP Address "); } else { Boolean CheckIPAddress = CheckIPAddressValid(WANIPInfoSubstr.Trim()); //Calling CheckIPAddressValid() if (CheckIPAddress) { Report.Success("Valid IP Address"); if (WANIPInfoSubstr.Trim() != WPSPIN) { Report.Info("WPSPIN : " + WPSPIN + " IP Address : " + WANIPInfoSubstr); if (rowNum1 == 1) { Report.Success(" WPS PIN is different from IPv4 address "+ " PASS"); } else if (rowNum1 == 2) { Report.Success(" WPS PIN is different from Default Gateway IPv4 address "+ " PASS"); } else if (rowNum1 == 5) { Report.Success(" WPS PIN is different from IPv4 DNS servers IPv4 address "+ " PASS"); } } } else { Report.Failure("InValid IP Address"); } } } } colNum1++; } //end of COLUMN forloop rowNum1++; } //end of ROW forloop } }
public void Verify_And_Validate_Device_Connection_Status_Info(string argument1, string argument2, string argument3, string argument4, string argument5, string argument6) { //Standard specification compliant : argument1 //Hardware version : argument2 //Software version : argument3 //Cable modem serial number : argument4 //Network access : argument5 //Cable MAC address : argument6 //Report.Info("Arg1 " + argument1); //Report.Info("Arg5 " + argument5); //Capture the following table info /* * /dom[@domain='192.168.0.1']//div[#'InfoHead']/table * /dom[@domain='192.168.0.1']//div[#'WANIP']/table * /dom[@domain='192.168.0.1']//div[#'WANIPSettingInfo}}']/table * /dom[@domain='192.168.0.1']//div[#'WANIPv6Info']/table * /dom[@domain='192.168.0.1']//div[#'WANIPv4Info']/table * /dom[@domain='192.168.0.1']//div[#'WANDSLiteInfo']/table * */ // Delay.Seconds(30); Duration newDuration = new Duration(240000); repo.WebDocument19216801.DivButtonsInfo.WaitForExists(newDuration); //Hub3.0 device info // //Hardware version, software ver,Cable Mac,cable modem serial number, system up time, netork access // "/dom[@domain='192.168.0.1']//div[#'Hub 3.0 device information']/table" =>Hub 3.0 device information WebDocument webDocument = "/dom[@domain='192.168.0.1']"; webDocument.WaitForDocumentLoaded(); //Report.Info(webDocument.GetHtml()); TableTag myTable = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'Hub 3.0 device information']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows = myTable.Find <TrTag>("./tbody//tr"); int rulesCount = totalDeviceRows.Count; string totalDeviceInfoRows = rulesCount.ToString() + " : Rows :"; Report.Info(" Hub 3.0 device information ", totalDeviceInfoRows); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no active Hub 3.0 device information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows + " in Hub 3.0 device information !!! "); int rowNum = 1; string devInfo = "", devInfoCol1 = "", deviceInfo = "", devInfoSubstr = ""; foreach (var row in totalDeviceRows) { //Report.Info("Row: " + rowNum); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum = 1; foreach (TdTag MacCol in cols) { //Report.Info("MacCol: " + colNum); if (colNum == 1) { devInfoCol1 = MacCol.InnerText; //Report.Info("Col1 Info: "+MacCol.InnerText); //Report.Info("Col1 Info: " + devInfoCol1); } if (colNum == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { devInfo = spanVal.InnerText; if (devInfo.Length > 0) { devInfoSubstr = devInfo.Substring(1, devInfo.Length - 1); // for validation purpose } else { //blank devInfoSubstr = ""; } //Report.Info( " devInfoSubstr " + devInfoSubstr); } //Report.Info("Col2 Info: "+devInfo); deviceInfo = devInfoCol1 + " "+ devInfo; //Report.Info( devInfoCol1 + " " + devInfo); Report.Info(deviceInfo); //Report.LogHtml(ReportLevel.Info, "deviceInfo", "<a>deviceInfo</a>"); //perform Hub 3.0 device information validation here //Standard specification compliant : DOCSIS 3.0 //Hardware version : 10 //Software version : 9.1.116V //Cable MAC address : C0:05:C2:00:24:1B //Cable modem serial number : AAAP51770041 //System up time : 0 days 17h:38m:47s //Network access : Allowed if (rowNum == 1) { //Standard specification compliant if (devInfoSubstr.Length == 0) { Report.Failure(" Standard specification compliant is BLANK "); } else if (devInfoSubstr.Trim().Equals(argument1.Trim())) { Report.Success(" Standard specification compliant "+ " PASS"); } else { Report.Failure(" Standard specification compliant "+ " FAIL"); } } else if (rowNum == 2) { //Hardware Version if (devInfoSubstr.Length == 0) { Report.Failure(" Hardware Version is BLANK "); } else if (devInfoSubstr.Trim() == argument2.Trim()) { Report.Success(" Hardware Version "+ " PASS"); } else { Report.Failure(" Hardware Version "+ " FAIL"); } } else if (rowNum == 3) { //Software Version if (devInfoSubstr.Length == 0) { Report.Failure(" Software Version is BLANK "); } else if (devInfoSubstr.Trim() == argument3.Trim()) { Report.Success(" Software Version "+ " PASS"); } else { Report.Failure(" Software Version "+ " FAIL"); } } else if (rowNum == 4) { //MAC Address - C0:05:C2:00:24:1B Report.Info(" devInfoSubstr "+ devInfoSubstr); Report.Info(" argument6 " + argument6); if (devInfoSubstr.Length == 0) { Report.Failure(" MAC Address is BLANK "); } else if (devInfoSubstr.Trim() == argument6.Trim()) { Report.Success(" MAC Address "+ " PASS"); } else { Report.Failure(" MAC Address "+ " FAIL"); } } else if (rowNum == 5) { //Cable modem serial number if (devInfoSubstr.Length == 0) { Report.Failure(" Cable modem serial number is BLANK "); } else if (devInfoSubstr.Trim() == argument4.Trim()) { Report.Success(" Cable modem serial number "+ " PASS"); } else { //validate Cable modem serial number Report.Failure(" Cable modem serial number "+ " FAIL"); } } else if (rowNum == 6) { //System up time if (devInfoSubstr.Length == 0) { Report.Failure(" System uptime is BLANK "); } else { //Validate system time format //Report.Info("Need to Validate system time format"); //Report.Failure(" System up time " + " FAIL"); } } else if (rowNum == 7) { //Network access if (devInfoSubstr.Length == 0) { Report.Failure(" Network access is BLANK "); } else if (devInfoSubstr.Trim() == argument5.Trim()) { Report.Success(" Network access "+ " PASS"); } else { Report.Failure(" Network access "+ " FAIL"); } } } colNum++; } // end of COLUMN for-loop rowNum++; } //end of ROW for-loop } //end if IF-ELSE // WAN IP settings // //MAC address, IPv4 address, default gateway,IPv4 lease time, IPv4 lease expire, IPv4 DNS server // "/dom[@domain='192.168.0.1']//div[#'WANIPv4Info']/table" => WANIPv4Info --WAN IP settings TableTag myTable1 = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'WANIPv4Info']/table"); //Count the total no of rows IList <TrTag> totalDeviceRows1 = myTable1.Find <TrTag>("./tbody//tr"); int rulesCount1 = totalDeviceRows1.Count; string totalDeviceInfoRows1 = rulesCount1.ToString() + " : Rows :"; Report.Info(" Hub 3.0 WAN IP information Rows ", totalDeviceInfoRows1); if (rulesCount == 0) { //Mouse.ScrollWheel(150); Report.Failure("Device Info ", "There are no WAN IP information !!"); return; } else { Report.Info(" There are " + totalDeviceInfoRows1 + " in Hub 3.0 WAN IP information !!! "); int rowNum1 = 1; string WANIPInfo = "", WANIPInfoCol1 = "", WANInfo = "", WANIPInfoSubstr = ""; foreach (var row in totalDeviceRows1) { //Report.Info("Row: " + rowNum1); //Report.Info(row.GetInnerHtml().ToString()); IList <TdTag> cols = row.Find <TdTag>("./td"); //Report.Info(" Total Column ", cols.Count.ToString()); int colNum1 = 1; foreach (TdTag MacCol in cols) { //Report.Info("MacCol: " + colNum1); if (colNum1 == 1) { WANIPInfoCol1 = MacCol.InnerText; //Report.Info("Col1 Info: "+MacCol.InnerText); //Report.Info("Col1 Info: "+WANIPInfoCol1); } if (colNum1 == 2) { IList <SpanTag> spanVals = MacCol.Find <SpanTag>("./span"); foreach (SpanTag spanVal in spanVals) { WANIPInfo = spanVal.InnerText; WANIPInfoSubstr = WANIPInfo.Substring(1, WANIPInfo.Length - 1); // for validation purpose //Report.Info( " WANIPInfoSubstr " + WANIPInfoSubstr); } //Report.Info("Col2 Info: "+WANIPInfo); WANInfo = WANIPInfoCol1 + " "+ WANIPInfo; //Report.Info( WANIPInfoCol1 + " " + WANIPInfo); Report.Info(WANInfo); //Report.LogHtml(ReportLevel.Info, "WANInfo", "<a>WANInfo</a>"); //perform WAN IP Settings validation here //IPv4 address : 80.2.153.121 //Default gateway : 80.2.153.97 //IPv4 lease time : 0 days 19h:24m:26s //IPv4 lease expire : 2016-07-01 04:09:29.00 //IPv4 DNS servers : 194.168.4.100 if (rowNum1 == 1 || rowNum1 == 2 || rowNum1 == 5) { //IP Address Validation if (WANIPInfoSubstr.Length == 0) { Report.Failure(" InValid IP Address "); } else { Boolean CheckIPAddress = CheckIPAddressValid(WANIPInfoSubstr.Trim()); //Calling CheckIPAddressValid() if (CheckIPAddress) { Report.Success("Valid IP Address"); } else { Report.Failure("InValid IP Address"); } } } else if (rowNum1 == 3) { //IPv4 lease time validation if (WANIPInfoSubstr.Length == 0) { Report.Failure(" InValid IPv4 lease time "); } else { /* * Boolean CheckDateTime = CheckDateTimeValid(WANIPInfoSubstr.Trim()); //calling CheckDateTimeValid() * if(CheckDateTime){ * Report.Success(" Valid IPv4 lease time "); * }else{ * Report.Failure(" InValid IPv4 lease time "); * } */ Report.Success(" Valid IPv4 lease time "); } } else if (rowNum1 == 4) { //string input = "2016-07-15 09:21:27.00"; //"???" // Report.Info("WANIPInfoSubstr : " , WANIPInfoSubstr); // Report.Info(WANIPInfoSubstr.Length.ToString()); if (WANIPInfoSubstr.Length == 0) { Report.Failure(" InValid IPv4 lease expire "); } else { Boolean CheckDateTime = CheckDateTimeValid(WANIPInfoSubstr.Trim()); //calling CheckDateTimeValid() //Boolean CheckDateTime = CheckDateTimeValid("???"); if (CheckDateTime) { Report.Success(" Valid IPv4 lease expire "); } else { Report.Failure(" InValid IPv4 lease expire "); } } } //end of rowNum1 IF-ELSE } colNum1++; } // end of COLUMN for-loop rowNum1++; } //end of ROW for-loop } //end if IF-ELSE /** * string addrString = "-200.0.0.1"; * Boolean CheckIPAddress = CheckIPAddressValid(addrString);//Calling CheckIPAddressValid() * if(CheckIPAddress){ * Report.Info("Valid IP - CheckIPAddressValid()"); * }else{ * Report.Info("InValid IP - CheckIPAddressValid()"); * } * * Boolean checkIP = CheckIPValid(addrString); //Calling CheckIPValid() * if(checkIP){ * Report.Info("Valid IP - CheckIPValid()"); * }else{ * Report.Info("InValid IP - CheckIPValid()"); * } **/ Report.Info("Device Status Info"); Mouse.ScrollWheel(3); Report.Screenshot(); }