Example #1
0
File: Form1.cs Project: IAGDQA/WA
        private void GroundPlugandPlaySetting(string sBrowser, string sProjectName, string sProjectName2, string sWebAccessIP, string sWebAccessIP2, string sTestLogFolder)
        {
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("<GroundPC> Browser= Internet Explorer");
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("<GroundPC> Browser= Mozilla FireFox");
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }

            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep(api, "<GroudPC> Login WebAccess");

            // Configure project by project name
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep(api, "<GroundPC> Configure project");

            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/node/nodePg.asp?') and contains(@href, 'action=node_property')]").Click();

            EventLog.AddLog("<GroundPC> Cloud Connection Settings");
            api.ByName("CLOUD_ENABLE").Click();
            Thread.Sleep(500);
            api.ByName("CLOUD_PROJNAME").Clear();
            api.ByName("CLOUD_PROJNAME").Enter(sProjectName2).Exe();
            api.ByName("CLOUD_SCADANAME").Clear();
            api.ByName("CLOUD_SCADANAME").Enter("CTestSCADA").Exe();
            api.ByName("DEFAULT_BUTTON").Click();
            api.ByName("CLOUD_IP").Clear();
            api.ByName("CLOUD_IP").Enter(sWebAccessIP2).Exe();

            /*
             * TCP comport-1883             -> win7 / win8 / win10
             * WebSocket and SSL -443       -> win8 / win10
             * WebSocket and Non-SSL=80     -> win8 / win 10
             */
            api.ByName("CLOUD_COMPORT").Clear();
            api.ByName("CLOUD_COMPORT").Enter("1883").Exe();            // port = 1883
            api.ByXpath("(//input[@name='CLOUD_TCP'])[2]").Click();     // Connection Type = TCP

            api.ByName("CLOUD_USERNAME").Clear();
            api.ByName("CLOUD_USERNAME").Enter("admin").Exe();
            api.ByName("CLOUD_PASSWORD").Clear();
            api.ByName("CLOUD_PASSWORD").Enter("12345").Submit().Exe();
            PrintStep(api, "Cloud Connection Settings");

            EventLog.AddLog("<GroundPC> Cloud White list setting");
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/WaCloudWhitelist/CloudWhitelist.asp?')]").Click();

            ////////////////////////////////// Cloud White list Setting //////////////////////////////////
            {   // AI/AO/DI/DO
                EventLog.AddLog("<GroundPC> Modbus tag setting");

                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("通信埠3(tcpip)").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("通讯端口3(tcpip)").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("포트3(tcpip)").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                    break;
                }
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 500; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                //api.ByXpath("//input[@value='Save']").Click();
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }

                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);

                api.ByXpath("//a[contains(text(),'2')]").Click();   // page 2
                Thread.Sleep(3000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Port4(opc)
            {
                EventLog.AddLog("<GroundPC> Port4(opc) setting");
                //api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("通信埠4(opc)").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("通讯端口4(opc)").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("포트4(opc)").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                    break;
                }
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Port5(tcpip)
            {
                EventLog.AddLog("<GroundPC> Port5(tcpip) setting");
                //api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("通信埠5(tcpip)").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("通讯端口5(tcpip)").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("포트5(tcpip)").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                    break;
                }
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Acc Point
            {
                EventLog.AddLog("<GroundPC> Acc Point setting");
                //api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("累算點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("累算点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("누적 포인트").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Point d'accumul.").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Calc Point
            {
                EventLog.AddLog("<GroundPC> Calc Point setting");
                //api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("計算點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("计算点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("산출 포인트").Exe();     // 翻譯可能有問題 與acc一樣
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Point calc.").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // Const Point
            {
                EventLog.AddLog("<GroundPC> Const Point setting");
                //api.ById("tagTypes").SelectTxt("Const Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("Const Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("常數點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("常数点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("Const Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("상수 포인트").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("Point const.").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("Const Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);

                api.ByXpath("//a[contains(text(),'2')]").Click();   // page 2
                Thread.Sleep(3000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            Thread.Sleep(1000);
            // System Point
            {
                EventLog.AddLog("<GroundPC> System Point setting");
                //api.ById("tagTypes").SelectTxt("System Point").Exe();
                switch (slanguage)
                {
                case "ENG":
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;

                case "CHT":
                    api.ById("tagTypes").SelectTxt("系統點").Exe();
                    break;

                case "CHS":
                    api.ById("tagTypes").SelectTxt("系统点").Exe();
                    break;

                case "JPN":
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;

                case "KRN":
                    api.ById("tagTypes").SelectTxt("시스템 포인트").Exe();
                    break;

                case "FRN":
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;

                default:
                    api.ById("tagTypes").SelectTxt("System Point").Exe();
                    break;
                }
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(1000);
                api.ByName("SetConfigAll").Click();
                api.ByName("SetDataLogAll").Click();
                Thread.Sleep(500);
                api.ByName("SetDeadBandValue").Enter("0").Exe();
                Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                Thread.Sleep(1000);

                /*
                 * api.ByName("SetDeadBand").Clear();
                 * api.ByName("SetDeadBand").Enter("0").Exe();
                 *
                 * for (int i = 2; i <= 250; i++)
                 * {
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Clear();
                 *  api.ByXpath("(//input[@name='SetDeadBand'])[" + i + "]").Enter("0").Exe();
                 * }
                 */
                switch (slanguage)
                {
                case "ENG":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "CHT":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "CHS":
                    api.ByXpath("//input[@value='保存']").Click();
                    break;

                case "JPN":
                    api.ByXpath("//input[@value='Save']").Click();
                    break;

                case "KRN":
                    api.ByXpath("//input[@value='저장']").Click();
                    break;

                case "FRN":
                    api.ByXpath("//input[@value='Enregistrer']").Click();
                    break;

                default:
                    api.ByXpath("//input[@value='Save']").Click();
                    break;
                }
                Thread.Sleep(500);
                api.ByXpath("//input[@value='Ok']").Click();
                Thread.Sleep(100);
            }
            ////////////////////////////////// Cloud White list Setting //////////////////////////////////
            PrintStep(api, "CloudWhitelistSetting");
            ReturnSCADAPage(api);

            EventLog.AddLog("<GroundPC> Download...");
            wacf.Download(api);

            api.Quit();
            PrintStep(api, "Quit browser");
        }
Example #2
0
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            baseUrl = "http://" + sWebAccessIP;

            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("Browser= Internet Explorer");
                //driver = new FirefoxDriver();
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("Browser= Mozilla FireFox");
                //driver = new FirefoxDriver();
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }


            // Launch Firefox and login
            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep("Login WebAccess");

            // Configure project by project name
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep("Configure project");

            //Create Alarm Group
            EventLog.AddLog("Create Alarm Group...");
            CreateAlarmGroup();
            PrintStep("Create Alarm Group");

            api.Quit();
            PrintStep("Quit browser");

            bool bSeleniumResult      = true;
            int  iTotalSeleniumAction = dataGridView1.Rows.Count;

            for (int i = 0; i < iTotalSeleniumAction - 1; i++)
            {
                DataGridViewRow row             = dataGridView1.Rows[i];
                string          sSeleniumResult = row.Cells[2].Value.ToString();
                if (sSeleniumResult != "pass")
                {
                    bSeleniumResult = false;
                    EventLog.AddLog("Test Fail !!");
                    EventLog.AddLog("Fail TestItem = " + row.Cells[0].Value.ToString());
                    EventLog.AddLog("BrowserAction = " + row.Cells[1].Value.ToString());
                    EventLog.AddLog("Result = " + row.Cells[2].Value.ToString());
                    EventLog.AddLog("ErrorCode = " + row.Cells[3].Value.ToString());
                    EventLog.AddLog("ExeTime(ms) = " + row.Cells[4].Value.ToString());
                    break;
                }
            }

            if (bSeleniumResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }

            //return 0;
        }
Example #3
0
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            /*
             * if (!Directory.Exists(string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr", sProjectName)) ||
             *  !Directory.Exists(string.Format("C:\\WebAccess\\Node\\{0}_TestSCADA\\bgr", sProjectName)))
             * {
             *  MessageBox.Show("Make sure you are in the WebAccess localhost PC!!");
             *  MessageBox.Show("If yes, please download the project and excute this program again :)");
             *  EventLog.AddLog(string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr or C:\\WebAccess\\Node\\{1}_TestSCADA\\bgr not exist!! please check again.", sProjectName, sProjectName));
             *  return 0;
             * }
             */
            baseUrl = "http://" + sWebAccessIP;

            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("Browser= Internet Explorer");
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("Browser= Mozilla FireFox");
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }


            // Launch Firefox and login
            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");

            api.ById("userField").Enter("").Submit().Exe();
            PrintStep("Login WebAccess");

            // Configure project by project name
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep("Configure project");

            //Step 0: Download
            try
            {
                EventLog.AddLog("Download...");
                wacf.Download(api);
            }
            catch (Exception ex)
            {
                EventLog.AddLog(ex.ToString());
            }

            //Step1: Copy "ConstTag_Set.scr" and "alm_set_ConAna_51.scr" and "alm_ack.scr"
            //        to C:\WebAccess\Node\config\ProjectName\bgr  and  C:\WebAccess\Node\ProjectName\bgr
            {
                //string sCurrentFilePath = Directory.GetCurrentDirectory();
                string sCurrentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location);

                string sourceFile1 = sCurrentFilePath + "\\GlobalScriptSample\\ConstTag_Set.scr";
                string destFile1_1 = string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr\\ConstTag_Set.scr", sProjectName);
                string destFile1_2 = string.Format("C:\\WebAccess\\Node\\{0}_TestSCADA\\bgr\\ConstTag_Set.scr", sProjectName);

                string sourceFile2 = sCurrentFilePath + "\\GlobalScriptSample\\alm_set_ConAna_51.scr";
                string destFile2_1 = string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr\\alm_set_ConAna_51.scr", sProjectName);
                string destFile2_2 = string.Format("C:\\WebAccess\\Node\\{0}_TestSCADA\\bgr\\alm_set_ConAna_51.scr", sProjectName);

                string sourceFile3 = sCurrentFilePath + "\\GlobalScriptSample\\alm_ack.scr";
                string destFile3_1 = string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr\\alm_ack.scr", sProjectName);
                string destFile3_2 = string.Format("C:\\WebAccess\\Node\\{0}_TestSCADA\\bgr\\alm_ack.scr", sProjectName);

                System.IO.File.Copy(sourceFile1, destFile1_1, true);
                System.IO.File.Copy(sourceFile1, destFile1_2, true);
                System.IO.File.Copy(sourceFile2, destFile2_1, true);
                System.IO.File.Copy(sourceFile2, destFile2_2, true);
                System.IO.File.Copy(sourceFile3, destFile3_1, true);
                System.IO.File.Copy(sourceFile3, destFile3_2, true);
            }

            //Step2: Set global script
            EventLog.AddLog("Set global script...");
            CreateGlobalScript();
            PrintStep("Set global script");

            api.Quit();
            PrintStep("Quit browser");

            bool bSeleniumResult      = true;
            int  iTotalSeleniumAction = dataGridView1.Rows.Count;

            for (int i = 0; i < iTotalSeleniumAction - 1; i++)
            {
                DataGridViewRow row             = dataGridView1.Rows[i];
                string          sSeleniumResult = row.Cells[2].Value.ToString();
                if (sSeleniumResult != "pass")
                {
                    bSeleniumResult = false;
                    EventLog.AddLog("Test Fail !!");
                    EventLog.AddLog("Fail TestItem = " + row.Cells[0].Value.ToString());
                    EventLog.AddLog("BrowserAction = " + row.Cells[1].Value.ToString());
                    EventLog.AddLog("Result = " + row.Cells[2].Value.ToString());
                    EventLog.AddLog("ErrorCode = " + row.Cells[3].Value.ToString());
                    EventLog.AddLog("ExeTime(ms) = " + row.Cells[4].Value.ToString());
                    break;
                }
            }

            if (bSeleniumResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }

            //return 0;
        }
Example #4
0
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            if (!Directory.Exists(string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr", sProjectName)) ||
                !Directory.Exists(string.Format("C:\\WebAccess\\Node\\{0}_TestSCADA\\bgr", sProjectName)))
            {
                MessageBox.Show("Make sure you are in the WebAccess localhost PC!!");
                EventLog.AddLog(string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\bgr or C:\\WebAccess\\Node\\{1}_TestSCADA\\bgr not exist!! please check again.", sProjectName, sProjectName));
                return(0);
            }

            baseUrl = "http://" + sWebAccessIP;

            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("Browser= Internet Explorer");
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("Browser= Mozilla FireFox");
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }


            // Launch Firefox and login
            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep("Login WebAccess");

            // Configure project by project name
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep("Configure project");
            //Thread.Sleep(2000);
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
            api.ByXpath(string.Format("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name={0}')]", sProjectName)).Click();
            //href="/broadWeb/bwMainRight.asp?pos=project&amp;idbw=1&amp;name=TestProject"

            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'pos=UserList')]").Click();
            //"/broadWeb/bwMainRight.asp?pos=UserList&amp;name=TestProject&amp;idbw=1


            // Copy "GeneralUser.bgr" and "PowerUser.bgr" and "RestrictedUser.bgr"
            //        to C:\WebAccess\Node\config\ProjectName\bgr  and  C:\WebAccess\Node\ProjectName\bgr
            EventLog.AddLog("copy bgr file to local pc");
            CopyBGRFileToLocal(sProjectName);

            EventLog.AddLog("Add users...");
            AddUsers();

            api.Quit();
            PrintStep("Quit browser");

            bool bSeleniumResult      = true;
            int  iTotalSeleniumAction = dataGridView1.Rows.Count;

            for (int i = 0; i < iTotalSeleniumAction - 1; i++)
            {
                DataGridViewRow row             = dataGridView1.Rows[i];
                string          sSeleniumResult = row.Cells[2].Value.ToString();
                if (sSeleniumResult != "pass")
                {
                    bSeleniumResult = false;
                    EventLog.AddLog("Test Fail !!");
                    EventLog.AddLog("Fail TestItem = " + row.Cells[0].Value.ToString());
                    EventLog.AddLog("BrowserAction = " + row.Cells[1].Value.ToString());
                    EventLog.AddLog("Result = " + row.Cells[2].Value.ToString());
                    EventLog.AddLog("ErrorCode = " + row.Cells[3].Value.ToString());
                    EventLog.AddLog("ExeTime(ms) = " + row.Cells[4].Value.ToString());
                    break;
                }
            }

            if (bSeleniumResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }

            //return 0;
        }
Example #5
0
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser, string sUserEmail)
        {
            baseUrl = "http://" + sWebAccessIP;
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("Browser= Internet Explorer");
                //driver = new FirefoxDriver();
                api = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("Browser= Mozilla FireFox");
                //driver = new FirefoxDriver();
                api = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }

            // Launch Firefox and login
            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep("Login WebAccess");

            //Step0: LogData Maintenance setting
            EventLog.AddLog("Go to LogData Maintenance page");
            SetLogDataMaintenance(sTestLogFolder);
            PrintStep("Set LogData Maintenance");

            //Step1
            EventLog.AddLog("Create Project Node...");
            CreateProject(sProjectName, sWebAccessIP);
            PrintStep("Create Project Node");
            Thread.Sleep(1000);

            api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep("Configure project");
            Thread.Sleep(500);

            //Step2
            EventLog.AddLog("Create SCADA Node...");
            CreateSCADANode(sWebAccessIP, sUserEmail);

            /* Because of frequent timeout issue of creating SCADA node, use the mechanism judgement instead of checking selenium result */
            //Step3 check if scada node exist
            bool bResult = ReturnSCADAPage(20000);

            PrintStep("CheckSCADANode");

            api.Quit();
            //PrintStep("Quit browser");

            if (bResult)
            {
                Result.Text      = "PASS!!";
                Result.ForeColor = Color.Green;
                EventLog.AddLog("Test Result: PASS!!");
                return(0);
            }
            else
            {
                Result.Text      = "FAIL!!";
                Result.ForeColor = Color.Red;
                EventLog.AddLog("Test Result: FAIL!!");
                return(-1);
            }
        }