/// <summary> /// Check webpage for specific elements related to each radio then transfers control to /// the proper method. If nothing is found /// </summary> /// <param name="browser"></param> public string GetRadioType(ChromeDriver browser) { string radio = "Nothing found..."; BrowserExt TestRadio = new BrowserExt(); if (TestRadio.IsElemenentPresent(By.Id("CanopyUsername"), browser) == true) { Console.WriteLine("Found 450 Radio...attempting login/reboot"); return(radio = ScrapeFourFifty(browser)); } else if (TestRadio.IsElemenentPresent(By.Id("loginBtn"), browser) == true) { Console.WriteLine("Found ePMP radio...attempting login/reboot"); return(radio = Scrape_ePMP(browser)); } else if (TestRadio.IsElemenentPresent(By.Id("login_form"), browser) == true) { Console.WriteLine("Found Wimax radio...attempting login/reboot"); return(radio = ScrapeWimax(browser)); } else { Console.WriteLine("Couldn't determine radio type...exiting app"); browser.Quit(); return(radio); } }
public string Cambium(ChromeDriver browser) { BrowserExt ElementCheck = new BrowserExt(); //Browser should be looking at ATA page by now string ATAInfo = ""; browser.FindElementById("user_name").SendKeys(userName); browser.FindElementById("password").SendKeys(passWord); if (ElementCheck.IsElemenentPresent(By.Id("login"), browser) == true) { browser.FindElementById("login").Click(); //loginBtn.Click(); } else { //If login button is not present we'll create it ourselves same way DOM originally does it. ((IJavaScriptExecutor)browser).ExecuteScript("document.write('<input id='login' type='submit' onclick='OnSubmit(this.form);');"); browser.FindElementById("login").Click(); } //Get phone lines and their status, format and add to ATAInfo string. try { var line1 = browser.FindElementById("sipStatus_1").Text; var line1_hook = browser.FindElementById("hookStatus_1").Text; var line1_Status = browser.FindElementById("useStatus_1").Text; var line2 = browser.FindElementById("sipStatus_2").Text; var line2_hook = browser.FindElementById("hookStatus_2").Text; var line2_Status = browser.FindElementById("useStatus_2").Text; ATAInfo = $"Phone lines in ATA:\nline 1 is {line1} and is {line1_hook} hook and currently {line1_Status}\n"; ATAInfo += $"line 2 is {line2} and is {line2_hook} hook and currently {line2_Status}\n"; //Find DHCP table var LAN_HostBtn = browser.FindElementById("menuSubList"); LAN_HostBtn.FindElements(By.TagName("li"))[1].Click(); } catch (Exception e) { Console.WriteLine($"Error on ATA homepage, ref: {e.ToString()}"); return(ATAInfo = "Couldn't get into ATA"); } //Gather DHCP table info.. try { var DHCP_Table = browser.FindElementById("PageList"); DHCP_Table = DHCP_Table.FindElement(By.TagName("table")); var DHCP_Rows = DHCP_Table.FindElements(By.TagName("tr")); var DHCP_Count = DHCP_Rows.Count; string DHCP_Info = $"{DHCP_Count.ToString()} Devices were found in DHCP Table:\n"; int counter = 1; //Iterate over each row, grab all DHCP items listed there foreach (var Row in DHCP_Rows) { var info = Row.FindElements(By.TagName("td")); /*Should be 7 items per Entry in DHCP table * 0 - MAC address * 1 - LAN IP * 2 - Interface Type * 3 - Address Source * 4 - Expires in * 5 - Device Name * 6 - DHCP Status */ DHCP_Info += $"DCHP Item# {counter.ToString()} MAC: {info[0].Text} IP: {info[1].Text} Host Name: {info[5].Text} DHCP Status: {info[6].Text}\n"; counter++; } ATAInfo += DHCP_Info; } catch (NotFoundException NoDCHP) { Console.WriteLine($"Nothing found in DHCP Table {NoDCHP.ToString()}"); ATAInfo += "Nothing found in DHCP Table"; //throw; } catch (Exception e) { Console.WriteLine($"Some other DHCP error occured... {e.ToString()}"); ATAInfo += "Nothing found in DHCP table"; } //Should be all done with ATA, go ahead and reboot dat hoe! browser.FindElementById("loginReboot").Click(); //Combine information ATAInfo += "Rebooted / Rebuilt ATA"; try { var handleAlert = browser.SwitchTo().Alert(); handleAlert.Accept(); } catch (Exception e) { Console.WriteLine("Couldn't handle Alert, was not able to reboot ATA"); Console.WriteLine(e.StackTrace); } return(ATAInfo); }