public string Spa2102(ChromeDriver browser) { string ATAInfo = "Found SPA2102, just create a ticket a this point, this thing is an\nancient piece of junk that needs to be replaced. "; var OrgURL = browser.Url; try { //have to dismiss alert first go around, navigate to admin login page, THEN login browser.SwitchTo().Alert().Dismiss(); browser.Navigate().GoToUrl(browser.Url + "/admin/advanced"); browser.SwitchTo().Alert().SetAuthenticationCredentials(userName, passWord); var DarkRows = browser.FindElementsByTagName("d3d3d3"); var LightRows = browser.FindElementsByTagName("dcdcdc"); var uptime = DarkRows[4].FindElements(By.Id("td")); ATAInfo = $"Uptime: {uptime[3].Text}\nRebooted/Rebuit ATA. "; browser.Navigate().GoToUrl(OrgURL + "/admin/reboot"); //BrowserHelper.CreateBrowser(browser.Url); } catch (NoAlertPresentException BadAlert) { Console.WriteLine($"No alert found when attempting reboot, are lines in use? ref: {BadAlert.ToString()}"); ATAInfo += "No alert found when attempting reboot, are lines in use?"; } catch (Exception e) { return(ATAInfo = $"Unknown Error occured. Please try again. Ref: {e.ToString()}"); } return(ATAInfo); }
public string Spa122(ChromeDriver browser) { string ATAInfo = ""; try { browser.FindElementByName("user").SendKeys(userName); browser.FindElementByName("pwd").SendKeys(passWord); //login button? no unique ID for it so trying this way, hopefully I can count browser.FindElements(By.TagName("input"))[5].Click(); } catch (ElementNotVisibleException e) { Console.WriteLine($"Ran into error: {e.ToString()} \nAttempting refresh of page."); //sometimes page wouldn't load for spa122, will attempt a refresh, but this could go on endlessly soooo //nvm just re run old code vs callin whole method. browser.Navigate().Refresh(); browser.FindElementByName("user").SendKeys(userName); browser.FindElementByName("pwd").SendKeys(passWord); //login button? no unique ID for it so trying this way, hopefully I can count browser.FindElements(By.TagName("input"))[5].Click(); // throw; } catch (Exception e) { return(ATAInfo = $"Some error occured logging into ATA, ref: {e.ToString()}"); } try { //Go to network setup page. browser.FindElementById("trt_Network_Service.asp").Click(); var networkSettings = browser.FindElementById("d_4"); networkSettings.FindElement(By.TagName("a")).Click(); //Show DHCP reservations. browser.FindElementById("t3").Click(); //id's could be numbered like an array? need to find an spa122 with mulitples to test that, too bad they're becoming rare...or is it that bad? lolol var DHCP_Name = browser.FindElementByName("dhcp_select_name_0"); var DHCP_IP = browser.FindElementByName("dhcp_select_ip_0"); var DHCP_MAC = browser.FindElementByName("dhcp_select_mac_0"); ATAInfo += $"DCHP item: \nName:{DHCP_Name.Text}\nLAN IP: {DHCP_IP.Text}\nMAC: {DHCP_MAC.Text}"; } catch (NotFoundException NotHere) { Console.WriteLine($"Nothing found in DHCP Table {NotHere.ToString()}"); ATAInfo += "Nothing found in DCHP table\n"; //throw; } catch (Exception e) { return(ATAInfo = $"Couldn't get into ATA {e.ToString()}"); } //Considering there's only one ethernet port on the SPA122, will assume there's one item in DHCP, not always 100% //accurate as not every customer lets SPA122 run DHCP, but should be enough to go off of as far as equipment functionality //ATAInfo += $"Number of items found in DHCP: {DHCP_IP.Count.ToString()}"; //Console.WriteLine($"Number of items found in DHCP: {DHCP_IP.Count.ToString()}"); //for (int dhcp_list = 0; dhcp_list >= DHCP_IP.Count; dhcp_list++) //{ // ATAInfo += $"DHCP client name: {DHCP_Name[dhcp_list].Text} IP: {DHCP_IP[dhcp_list].Text} MAC: {DHCP_MAC[dhcp_list].Text}"; // Console.WriteLine($"DHCP client name: {DHCP_Name[dhcp_list].Text} IP: {DHCP_IP[dhcp_list].Text} MAC: {DHCP_MAC[dhcp_list].Text}"); //} try { //Check phones browser.FindElementById("trt_voice.asp").Click(); //this page is a mess, hope we really REALLY can count...you really don't wanna see this DOM man. but if you do uncomment this next line, ye be warned //Console.WriteLine(browser.PageSource.ToString()); //Data I want is stored in iframe will have to switch in and out of it. browser.SwitchTo().Frame(browser.FindElementById("iframe")); //Should be leading DIV containing ALL the info related to voice/uptime. var infoDiv = browser.FindElementById("Information"); var infoTable = infoDiv.FindElements(By.TagName("tr"))[8]; infoTable = infoTable.FindElements(By.TagName("td"))[3]; ATAInfo += $"ATA up time: {infoTable.FindElement(By.TagName("font")).Text}"; //Line 1: infoTable = infoDiv.FindElements(By.TagName("tr"))[16]; ATAInfo += $"Line 1 is {infoTable.FindElements(By.TagName("font"))[0].Text} hook and {infoTable.FindElements(By.TagName("font"))[1].Text} to SIP Server"; //line 2 infoTable = infoDiv.FindElements(By.TagName("tr"))[43]; //yeah that many rows in this table ATAInfo += $"Line 2 is {infoTable.FindElements(By.TagName("font"))[0].Text} hook and {infoTable.FindElements(By.TagName("font"))[1].Text} to SIP Server"; } catch (Exception NoIframe) { ATAInfo += $"Couldn't get voice info, no Iframe found or trouble switching to Iframe, ref: {NoIframe.ToString()}"; Console.WriteLine($"Couldn't get voice info, no Iframe found or trouble switching to Iframe, ref: {NoIframe.ToString()}"); throw; } Console.WriteLine("Going to reboot ATA..."); //Getting out of iframe, back into orginal DOM browser.SwitchTo().DefaultContent(); //move to reboot ATA browser.FindElementById("trt_Management.asp").Click(); var adminPage = browser.FindElementById("d_20"); //should be reboot button. adminPage.FindElement(By.TagName("a")).Click(); browser.FindElementById("t4").Click(); //handle JS alert try { BrowserHelper.HandleAlerts(browser); } catch (NoAlertPresentException BadAlert) { Console.WriteLine($"No alert found when attempting reboot, are lines in use? ref: {BadAlert.ToString()}"); ATAInfo += "No alert found when attempting reboot, are lines in use?"; // throw; } return(ATAInfo); }