/// <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);
            }
        }
        static void Main(string[] args)
        {
            //declare variables.
            string    FOPS            = "https://fops.amatechtel.com";
            string    AtaProvisioning = "/tools/ataprovisioning/";
            string    AccountNumber   = "";
            FOPS      FOPSPage        = new FOPS();
            Stopwatch timer           = new Stopwatch();

            timer.Start();
            //init headless chrome browser
            var browser = new BrowserExt().CreateHeadlessBrowser(FOPS);

            //init GUI chrome browser, mostly just for testings sake.
            //var browser = new BrowserExt().CreateBrowser(FOPS);

            FOPSPage.FOPS_Login(browser, FOPS + AtaProvisioning);

            /*
             * support for command line arguements:
             * Handled as LMGD_Tester.exe <custAccountNumber>
             * no other arguements are needed and will be discarded.
             * if no arguement is passed app will ask for account number
             * before procedding
             */
            if (args.Length == 0)
            {
                //Get customer account number from end user...
                Console.WriteLine("Enter Account number: ");
                AccountNumber = Console.ReadLine();
            }

            //get ATA Info first
            var ReturnedATA = FOPSPage.GetAtaIp(browser, AccountNumber);

            Console.WriteLine(ReturnedATA.ToString());
            //Now Grab Radio info
            var ReturnedRadio = FOPSPage.GetRadioIP(browser, AccountNumber);

            timer.Stop();
            TimeSpan timeSpan    = timer.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds / 10);

            Console.WriteLine($"Results: \n{ReturnedRadio}\n{ReturnedATA}\nEND>>>");
            Console.WriteLine($"RunTime: {elapsedTime}");
            System.Windows.Forms.Clipboard.SetText($"Radio:\n{ReturnedRadio}\nATA:\n{ReturnedATA}");
            Console.WriteLine("Copied data to clipboard, press any key to exit...");
            //Clean up.
            browser.Quit();
            Console.ReadKey();
            Environment.Exit(0);
        }
示例#3
0
        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);
        }