示例#1
0
        public void StopKernel(IAdvSeleniumAPI api, bool bRedundancyTest)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a[6]/font").Click();    // Stop kernel
            Thread.Sleep(2000);

            EventLog.AddLog("Find pop up StopNode window handle");
            string main; object subobj;

            api.GetWinHandle(out main, out subobj);
            IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

            List <string> items = new List <string>();

            while (windowIterator.MoveNext())
            {
                items.Add(windowIterator.Current);
            }

            EventLog.AddLog("Main window handle= " + main);
            EventLog.AddLog("Window handle list items[0]= " + items[0]);
            EventLog.AddLog("Window handle list items[1]= " + items[1]);
            if (main != items[1])
            {
                EventLog.AddLog("Switch to items[1]");
                api.SwitchToWinHandle(items[1]);
            }
            else
            {
                EventLog.AddLog("Switch to items[0]");
                api.SwitchToWinHandle(items[0]);
            }

            if (bRedundancyTest == true)
            {
                Thread.Sleep(500);
                api.ByXpath("(//input[@name='SECONDARY_CONTROL'])[2]").Click();
                Thread.Sleep(1000);
            }
            api.ByName("submit").Enter("").Submit().Exe();

            if (bRedundancyTest == true)
            {
                EventLog.AddLog("Stop node and wait 100 seconds for redundancy test...");
                Thread.Sleep(100000);    // Wait 100s for Stop kernel finish
                EventLog.AddLog("It's been wait 100 seconds");
            }
            else
            {
                EventLog.AddLog("Stop node and wait 30 seconds...");
                Thread.Sleep(30000);    // Wait 30s for Stop kernel finish
                EventLog.AddLog("It's been wait 30 seconds");
            }

            EventLog.PrintScreen("Stop Node result");
            api.Close();
            EventLog.AddLog("Close stop node window and switch to main window");
            api.SwitchToWinHandle(main); // switch back to original window
        }                                // for Redundancy test
示例#2
0
文件: Form1.cs 项目: IAGDQA/WA
        private void CloudBrokerSetting(string sBrowser, string sProjectName, string sWebAccessIP, string sTestLogFolder)
        {
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("<CloudPC> Browser= Internet Explorer");
                api2 = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("<CloudPC> Browser= Mozilla FireFox");
                api2 = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }

            api2.LinkWebUI(baseUrl2 + "/broadWeb/bwconfig.asp?username=admin");
            api2.ById("userField").Enter("").Submit().Exe();
            PrintStep(api2, "<CloudPC> Login WebAccess");
            EventLog.AddLog("<CloudPC> Set MQTT broker Account");
            EventLog.AddLog("<CloudPC> UserName=admin Password=12345");
            api2.ByXpath("//a[contains(@href, '/broadWeb/mqtt/mqttBroker.asp')]").Click();
            api2.ByName("Enable").Click();
            api2.ByName("UserName").Clear();
            api2.ByName("UserName").Enter("admin").Exe();
            api2.ByName("Password").Clear();
            api2.ByName("Password").Enter("12345").Submit().Exe();
            Thread.Sleep(500);
            PrintStep(api2, "<CloudPC> SetMQTTbrokerAccount");
            api2.Quit();
            PrintStep(api2, "<CloudPC> Quit browser");
        }
示例#3
0
文件: Form1.cs 项目: IAGDQA/WA
        private void ViewandSaveCloudProjectInfo(string sBrowser, string sProjectName, string sWebAccessIP, string sTestLogFolder)
        {
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("<CloudPC> Browser= Internet Explorer");
                api2 = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("<CloudPC> Browser= Mozilla FireFox");
                api2 = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }
            EventLog.AddLog("<CloudPC> Capture the project manager page");
            api2.LinkWebUI(baseUrl2 + "/broadWeb/bwconfig.asp?username=admin");
            api2.ById("userField").Enter("").Submit().Exe();
            PrintStep(api2, "<CloudPC> Login WebAccess");

            // Configure project by project name
            EventLog.AddLog("<CloudPC> Capture the configure project page");
            api2.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep(api2, "<CloudPC> Configure project");

            Thread.Sleep(5000);
            EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_GtoC");

            api2.Quit();
            PrintStep(api2, "<CloudPC> Quit browser");
        }
示例#4
0
文件: Form1.cs 项目: windygu/WISE
    private void WorkSteps()
    {
        api = new AdvSeleniumAPI("IE", Application.StartupPath);
        System.Threading.Thread.Sleep(1000);
        StopNode();
        DeleteCloudProject();

        CloseBrowserBlock();
    }
示例#5
0
    private void WorkSteps()
    {
        errorCnt = 0;
        api      = new AdvSeleniumAPI("IE", Application.StartupPath);
        System.Threading.Thread.Sleep(1000);
        LinkWebBlock();
        LogInBlock();
        ChangeIO_TagName();
        CloudConfig();
        System.Threading.Thread.Sleep(5000);
        //<------------------ 確認雲端上的部份
        ViewandSaveCloudTagInfo();


        //<------------------
        CloseBrowserBlock();
    }
示例#6
0
文件: Form1.cs 项目: IAGDQA/WA
        private void PrintStep(IAdvSeleniumAPI api, string sTestItem)
        {
            DataGridViewRow  dgvRow;
            DataGridViewCell dgvCell;

            var list = api.GetStepResult();

            foreach (var item in list)
            {
                AdvSeleniumAPI.ResultClass _res = (AdvSeleniumAPI.ResultClass)item;
                //
                dgvRow = new DataGridViewRow();
                if (_res.Res == "fail")
                {
                    dgvRow.DefaultCellStyle.ForeColor = Color.Red;
                }
                dgvCell = new DataGridViewTextBoxCell(); //Column Time
                //
                if (_res == null)
                {
                    continue;
                }
                //
                dgvCell.Value = sTestItem;
                dgvRow.Cells.Add(dgvCell);
                //
                dgvCell       = new DataGridViewTextBoxCell();
                dgvCell.Value = _res.Decp;
                dgvRow.Cells.Add(dgvCell);
                //
                dgvCell       = new DataGridViewTextBoxCell();
                dgvCell.Value = _res.Res;
                dgvRow.Cells.Add(dgvCell);
                //
                dgvCell       = new DataGridViewTextBoxCell();
                dgvCell.Value = _res.Err;
                dgvRow.Cells.Add(dgvCell);
                //
                dgvCell       = new DataGridViewTextBoxCell();
                dgvCell.Value = _res.Tdev;
                dgvRow.Cells.Add(dgvCell);

                m_DataGridViewCtrlAddDataRow(dgvRow);
            }
            Application.DoEvents();
        }
示例#7
0
    private void WorkSteps()
    {
        errorCnt = 0;
        api      = new AdvSeleniumAPI("IE", Application.StartupPath);
        System.Threading.Thread.Sleep(1000);
        //<------------------ 確認雲端上刪除Tag的部份
        DeleteCloudTag(); // C2G
        CloseBrowserBlock();
        System.Threading.Thread.Sleep(1000);
        //<------------------
        api = new AdvSeleniumAPI("FireFox", Application.StartupPath);
        LinkWebBlock();
        LogInBlock();
        CheckWAConfig();

        CloseBrowserBlock();
    }
示例#8
0
文件: Form1.cs 项目: aaronhuang945/WA
        private void StartDownload(IAdvSeleniumAPI api, string sTestLogFolder)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a[3]/font").Click();    // "Download" click
            Thread.Sleep(2000);
            EventLog.AddLog("Find pop up download window handle");
            string main; object subobj;                     // Find pop up download window handle

            api.GetWinHandle(out main, out subobj);
            IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

            List <string> items = new List <string>();

            while (windowIterator.MoveNext())
            {
                items.Add(windowIterator.Current);
            }

            EventLog.AddLog("Main window handle= " + main);
            EventLog.AddLog("Window handle list items[0]= " + items[0]);
            EventLog.AddLog("Window handle list items[1]= " + items[1]);
            if (main != items[1])
            {
                EventLog.AddLog("Switch to items[1]");
                api.SwitchToWinHandle(items[1]);
            }
            else
            {
                EventLog.AddLog("Switch to items[0]");
                api.SwitchToWinHandle(items[0]);
            }
            api.ByName("submit").Enter("").Submit().Exe();

            EventLog.AddLog("Start to download and wait 80 seconds...");
            Thread.Sleep(80000);    // Wait 80s for Download finish
            EventLog.AddLog("It's been wait 80 seconds");

            api.Close();
            EventLog.AddLog("Close download window and switch to main window");
            api.SwitchToWinHandle(main);

            PrintStep("Download");
        }
示例#9
0
        public void StartKernel(IAdvSeleniumAPI api)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a[5]/font").Click();    // start kernel
            Thread.Sleep(2000);
            EventLog.AddLog("Find pop up StartNode window handle");
            string main; object subobj;

            api.GetWinHandle(out main, out subobj);
            IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

            List <string> items = new List <string>();

            while (windowIterator.MoveNext())
            {
                items.Add(windowIterator.Current);
            }

            EventLog.AddLog("Main window handle= " + main);
            EventLog.AddLog("Window handle list items[0]= " + items[0]);
            EventLog.AddLog("Window handle list items[1]= " + items[1]);
            if (main != items[1])
            {
                EventLog.AddLog("Switch to items[1]");
                api.SwitchToWinHandle(items[1]);
            }
            else
            {
                EventLog.AddLog("Switch to items[0]");
                api.SwitchToWinHandle(items[0]);
            }
            api.ByName("submit").Enter("").Submit().Exe();

            EventLog.AddLog("Start node and wait 30 seconds...");
            Thread.Sleep(30000);    // Wait 30s for start kernel finish
            EventLog.AddLog("It's been wait 30 seconds");
            EventLog.PrintScreen("Start Node result");
            api.Close();
            EventLog.AddLog("Close start node window and switch to main window");
            api.SwitchToWinHandle(main);        // switch back to original window
        }
示例#10
0
文件: Form1.cs 项目: IAGDQA/WA
        private void GroundPC_DeleteUpdateTag(string sBrowser, string sProjectName, string sWebAccessIP, 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, "<GroundPC> 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");


            // Step1. Delete tag
            EventLog.AddLog("<GroundPC> Delete AT_AI0004/AT_AO0004/AT_DI0004/AT_DO0004/OPCDA_0004/OPCUA_0004/Acc_0004/ConAna_0004/SystemSec_0004 tags start...");
            GroundPC_DeleteTag();

            // Step2. Update tag
            EventLog.AddLog("<GroundPC> Update AT_AI0005/AT_AO0005/AT_DI0005/AT_DO0005/OPCDA_0005/OPCUA_0005/Acc_0005/ConDis_0005/SystemSec_0005 tags start...");
            GroundPC_UpdateTag();   //做這之前要先確認左邊的樹狀圖是"全展開"or"Modsim要展開其它不展開"的狀態

            ReturnSCADAPage(api);
            // Step3. Download project
            EventLog.AddLog("<GroundPC> Download...");
            wacf.Download(api);

            api.Quit();
            PrintStep(api, "<GroundPC> Quit browser");
        }
示例#11
0
    private void StartDownload(IAdvSeleniumAPI api)
    {
        PrintTitle("StartDownload");
        api.SwitchToCurWindow(0);
        api.SwitchToFrame("rightFrame", 0);
        api.ByXpath("//tr[2]/td/a[3]/font").Click();    // "Download" click

        string main; object subobj;                     // Find pop up download window handle

        api.GetWinHandle(out main, out subobj);
        IEnumerator <String> windowIterator = (IEnumerator <String>)subobj;

        List <string> items = new List <string>();

        while (windowIterator.MoveNext())
        {
            items.Add(windowIterator.Current);
        }

        if (main != items[1])
        {
            api.SwitchToWinHandle(items[1]);
        }
        else
        {
            api.SwitchToWinHandle(items[0]);
        }
        api.ByName("submit").Enter("").Submit().Exe();

        System.Threading.Thread.Sleep(80000);
        //PrintScreen("Download result", sTestLogFolder);
        api.Close();
        api.SwitchToWinHandle(main);

        PrintStep();
    }
示例#12
0
文件: Form1.cs 项目: aaronhuang945/WA
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            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);
            }

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

            EventLog.AddLog("Go to Event log setting page");
            api.ByXpath("//a[contains(@href, '/broadWeb/syslog/LogPg.asp?pos=event')]").Click();

            // select project name
            EventLog.AddLog("select project name");
            api.ByName("ProjNameSel").SelectTxt(sProjectName).Exe();
            Thread.Sleep(3000);

            // set today as start date
            string sToday  = string.Format("{0:dd}", DateTime.Now);
            int    iToday  = Int32.Parse(sToday); // 為了讓讀出來的日期去掉第一個零 ex: "06" -> "6"
            string ssToday = string.Format("{0}", iToday);

            api.ByName("DateStart").Click();
            Thread.Sleep(1000);
            api.ByTxt(ssToday).Click();
            Thread.Sleep(1000);
            EventLog.AddLog("select start date to today: " + ssToday);

            api.ByName("PageSizeSel").Enter("").Submit().Exe();
            PrintStep("Set and get Event Log data");
            EventLog.AddLog("Get Event Log data");

            Thread.Sleep(10000); // wait to get ODBC data

            // print screen
            string fileNameTar = string.Format("EventLogData_{0:yyyyMMdd_hhmmss}", DateTime.Now);

            EventLog.PrintScreen(fileNameTar);

            /*
             * EventLog.AddLog("Save data to excel");
             * SaveDatatoExcel(sProjectName, sTestLogFolder);
             */
            EventLog.AddLog("Check event log data");
            bool bCheckResult = CheckEventLogData();

            PrintStep("CheckEventLogData");

            Thread.Sleep(500);
            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 && bCheckResult)
            {
                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;
        }
示例#13
0
文件: Form1.cs 项目: aaronhuang945/WA
        long Form1_Load(string sWebAccessIP, string sBrowser, string Recipe_File_Name, string Unit_Name, string Recipe_Name, string Value)
        {
            try
            {
                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();
                api.ByXpath("//input[@id='submit1']").Click();   //??
                PrintStep("Login WebAccess");

                //Step0: select first project and scada
                EventLog.AddLog("Create a recipe");
                api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
                //iCheckIfSCADAExis = api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name=TestSCADA')]").Click();
                //api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project&pid=2&ProjName=TestProjectGGGG')]").Click();      //??

                //Step1: select recipe and add new recipe
                api.SwitchToFrame("rightFrame", 0);
                api.ByXpath("//a[contains(@href, '/broadWeb/recipe/rpList.asp')]").Click();
                api.ByXpath("//a[contains(@href, '/broadWeb/recipe/rpPg.asp') and contains(@href, 'action=add_recipe')]").Click();

                //Step2: set recipe data
                bool bResult = CreateRecipe(Recipe_File_Name, Unit_Name, Recipe_Name, Value);
                PrintStep("create a recipe");

                api.Quit();

                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);
                }
            }
            catch (Exception ex)
            {
                EventLog.AddLog(ex.ToString());
                return(-1);
            }
        }
示例#14
0
文件: Form1.cs 项目: aaronhuang945/WA
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            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);
            }

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

            EventLog.AddLog("Check analog tag data...");
            bool bAnaChk = AnalogTagDataCheck(sProjectName);

            EventLog.AddLog("Check discrete tag data...");
            bool bDisChk = DiscreteTagDataCheck(sProjectName);

            /*
             * EventLog.AddLog("Save data to excel");
             * SaveDatatoExcel(sProjectName, sTestLogFolder);
             */
            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 && bAnaChk && bDisChk)
            {
                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;
        }
示例#15
0
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            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");


            //Case1: Excel in
            EventLog.AddLog("Excel in...");
            //string sSourceFile = "C:\\WALogData\\bwTagImport_AutoTest"; //debug
            //string sCurrentFilePath = Directory.GetCurrentDirectory();
            string sCurrentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location);

            string sSourceFile = sCurrentFilePath + "\\ExcelIn\\bwTagImport_AutoTest";

            EventLog.AddLog("Set project name to excel file");
            SetExcelProjectName(sProjectName, sSourceFile);
            EventLog.AddLog("Set project name to excel file done!");

            ExcuteExcelIn(sSourceFile);
            Thread.Sleep(20000);
            string fileNameTar_in = string.Format("ExcelIn_{0:yyyyMMdd_hhmmss}", DateTime.Now);

            EventLog.PrintScreen(fileNameTar_in);
            PrintStep("Excel in");

            api.Refresh();
            ReturnSCADAPage();

            //Case2: Excel out
            EventLog.AddLog("Excel out...");
            string sdestFile = sTestLogFolder + string.Format("\\bwTagExport_{0:yyyyMMdd_hhmmss}", DateTime.Now);

            ExcuteExcelOut(sdestFile);
            Thread.Sleep(20000);
            string fileNameTar_out = string.Format("ExcelOut_{0:yyyyMMdd_hhmmss}", DateTime.Now);

            EventLog.PrintScreen(fileNameTar_out);
            PrintStep("Excel out");

            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;
        }
示例#16
0
        private void ViewandSaveGroundWhiteListInfo(string sBrowser, string sProjectName, string sWebAccessIP, 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);
            }
            EventLog.AddLog("<GroundPC> Capture the project manager page");
            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep(api, "<GroundPC> Login WebAccess");

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

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

            ////////////////////////////////// View Cloud White list Setting //////////////////////////////////
            {   // AI/AO/DI/DO
                EventLog.AddLog("<GroundPC> Modbus tag setting");
                api.ById("tagTypes").SelectTxt("Port3(tcpip)").Exe();
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);

                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_ModsimWhiteList_Page1");
                api.ByXpath("//a[contains(text(),'2')]").Click();   // page 2
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_ModsimWhiteList_Page2");
            }

            // Port4(opc)
            {
                EventLog.AddLog("<GroundPC> Port4(opc) setting");
                api.ById("tagTypes").SelectTxt("Port4(opc)").Exe();
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_OPCDAWhiteList");
            }

            // Port5(tcpip)
            {
                EventLog.AddLog("<GroundPC> Port5(tcpip) setting");
                api.ById("tagTypes").SelectTxt("Port5(tcpip)").Exe();
                Thread.Sleep(2000);
                api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_OPCUAWhiteList");
            }

            // Acc Point
            {
                EventLog.AddLog("<GroundPC> Acc Point setting");
                api.ById("tagTypes").SelectTxt("Acc Point").Exe();
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_AccWhiteList");
            }

            // Calc Point
            {
                EventLog.AddLog("<GroundPC> Calc Point setting");
                api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_CalcWhiteList");
            }

            // Const Point
            {
                EventLog.AddLog("<GroundPC> Const Point setting");
                api.ById("tagTypes").SelectTxt("Const Point").Exe();
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_ConstWhiteList_Page1");
                api.ByXpath("//a[contains(text(),'2')]").Click();   // page 2
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_ConstWhiteList_Page2");
            }

            // System Point
            {
                EventLog.AddLog("<GroundPC> System Point setting");
                api.ById("tagTypes").SelectTxt("System Point").Exe();
                //api.ById("SubContent").Click();   // page1
                Thread.Sleep(2000);
                EventLog.PrintScreen("PlugandPlay_DeleteProjectTest_CtoG_SystemWhiteList");
            }
            ////////////////////////////////// View Cloud White list Setting //////////////////////////////////
            PrintStep(api, "ViewandSaveGroundWhitelistSetting");

            api.Quit();
            PrintStep(api, "<GroundPC> Quit browser");
        }
示例#17
0
        private bool CheckDeletedTagInfo(string sBrowser, string sProjectName, string sWebAccessIP, 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);
            }
            EventLog.AddLog("<GroundPC> Capture the project manager page");
            api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin");
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep(api, "<GroundPC> Login WebAccess");

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

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

            //// AI AO DI DO ////
            EventLog.AddLog("Check AI AO DI DO deleted tag..");
            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);

            bool bTotalResult = true;

            for (int i = 1; i <= 500; i++)
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check AI AO tag info");

            api.ByXpath("//a[contains(text(),'2')]").Click(); // page 2
            Thread.Sleep(2000);
            for (int i = 1; i <= 496; i++)                    // 因為被前面PlugandPlay_DeleteUpdateTagTest_GtoC刪除4個點AT_AI0004/AT_AO0004/AT_DI0004/AT_DO0004 所以剩496個tag
            {                                                 //所以剩496個tag
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check DI DO tag info");

            //// OPCDA ////
            EventLog.AddLog("Check OPCDA deleted tag..");
            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(2000);
            for (int i = 1; i <= 249; i++)  // 因為被前面PlugandPlay_DeleteUpdateTagTest_GtoC刪除1個點OPCDA_0004 所以剩249個tag
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check OPCDA tag info");

            //// OPCUA ////
            EventLog.AddLog("Check OPCUA deleted tag..");
            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);
            for (int i = 1; i <= 249; i++)  // 因為被前面PlugandPlay_DeleteUpdateTagTest_GtoC刪除1個點OPCUA_0004 所以剩249個tag
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check OPCUA tag info");

            //// Acc ////
            EventLog.AddLog("Check Acc deleted tag..");
            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;
            }
            Thread.Sleep(2000);
            for (int i = 1; i <= 249; i++)  // 因為被前面PlugandPlay_DeleteUpdateTagTest_GtoC刪除1個點Acc_0004 所以剩249個tag
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check Acc tag info");

            //// Calc ////
            EventLog.AddLog("Check Calculate deleted tag..");
            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();
                break;

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

            default:
                api.ById("tagTypes").SelectTxt("Calc Point").Exe();
                break;
            }
            Thread.Sleep(2000);
            for (int i = 1; i <= 136; i++)
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check Calculate tag info");

            //// Const ////
            EventLog.AddLog("Check Constant deleted tag..");
            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;
            }
            Thread.Sleep(2000);
            for (int i = 1; i <= 500; i++)
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check Const tag info(Page1)");

            api.ByXpath("//a[contains(text(),'2')]").Click(); // page 2
            Thread.Sleep(2000);
            for (int i = 1; i <= 249; i++)                    // 因為被前面PlugandPlay_DeleteUpdateTagTest_GtoC刪除1個點ConAna_0004 所以剩249個tag
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check Const tag info(Page2)");

            //// System ////
            EventLog.AddLog("Check System deleted tag..");
            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;
            }
            Thread.Sleep(2000);
            for (int i = 1; i <= 249; i++)  // 因為被前面PlugandPlay_DeleteUpdateTagTest_GtoC刪除1個點SystemSec_0004 所以剩249個tag
            {
                string sCheckbox = api.ByXpath(string.Format("//tr[{0}]/td[1]/input[1]", i)).GetAttr("checked");

                if (sCheckbox == "true")
                {
                    string sTagNmae = api.ByXpath(string.Format("//tr[{0}]/td[2]", i)).GetText();
                    EventLog.AddLog("<GroundPC> The deleted tag <" + sTagNmae + "> is not disable in cloud white list. Test fail!!");
                    bTotalResult = false;
                }
            }
            PrintStep(api, "<GroundPC> Check System tag info");

            api.Quit();
            PrintStep(api, "<GroundPC> Quit browser");

            return(bTotalResult);
        }
示例#18
0
文件: Form1.cs 项目: 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");
        }
示例#19
0
文件: Form1.cs 项目: IAGDQA/WA
        private bool ViewandSaveCloudTagInfo(string sBrowser, string sProjectName, string sWebAccessIP, string sTestLogFolder)
        {
            if (sBrowser == "Internet Explorer")
            {
                EventLog.AddLog("<CloudPC> Browser= Internet Explorer");
                api2 = new AdvSeleniumAPI("IE", "");
                System.Threading.Thread.Sleep(1000);
            }
            else if (sBrowser == "Mozilla FireFox")
            {
                EventLog.AddLog("<CloudPC> Browser= Mozilla FireFox");
                api2 = new AdvSeleniumAPI("FireFox", "");
                System.Threading.Thread.Sleep(1000);
            }
            EventLog.AddLog("<CloudPC> Capture the project manager page");
            api2.LinkWebUI(baseUrl2 + "/broadWeb/bwconfig.asp?username=admin");
            api2.ById("userField").Enter("").Submit().Exe();
            PrintStep(api2, "<CloudPC> Login WebAccess");

            // Configure project by project name
            EventLog.AddLog("<CloudPC> Capture the configure project page");
            api2.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();
            PrintStep(api2, "<CloudPC> Configure project");


            api2.SwitchToCurWindow(0);
            api2.SwitchToFrame("leftFrame", 0);

            api2.ByXpath("//tr[4]/td/a/font").Click();      // Acc_0005_Test
            bool bAccCheck = AnalogTagCheck("Acc_0005_Test");

            api2.ByXpath("//tr[253]/td/a/font").Click();    // AT_AI0005_Test
            bool bAICheck = AnalogTagCheck("AT_AI0005_Test");

            api2.ByXpath("//tr[502]/td/a/font").Click();    // AT_AO0005_Test
            bool bAOCheck = AnalogTagCheck("AT_AO0005_Test");

            api2.ByXpath("//tr[751]/td/a/font").Click();    // AT_DI0005_Test
            bool bDICheck = DiscreteTagUpdateCheck("AT_DI0005_Test");

            api2.ByXpath("//tr[1000]/td/a/font").Click();   // AT_DO0005_Test
            bool bDOCheck = DiscreteTagUpdateCheck("AT_DO0005_Test");

            api2.ByXpath("//tr[1635]/td/a/font").Click();   // ConDis_0005_Test
            bool bConDisCheck = DiscreteTagUpdateCheck("ConDis_0005_Test");

            api2.ByXpath("//tr[2134]/td/a/font").Click();   // OPCDA_0005_Test
            bool bOPCDACheck = AnalogTagCheck("OPCDA_0005_Test");

            api2.ByXpath("//tr[2383]/td/a/font").Click();   // OPCUA_0005_Test
            bool bOPCUACheck = AnalogTagCheck("OPCUA_0005_Test");

            api2.ByXpath("//tr[2632]/td/a/font").Click();   // SystemSec_0005_Test
            bool bSysCheck = AnalogTagCheck("SystemSec_0005_Test");

            api2.Quit();
            PrintStep(api2, "<CloudPC> Quit browser");

            if (bAccCheck && bAICheck && bAOCheck && bDICheck && bDOCheck && bConDisCheck && bOPCDACheck && bOPCUACheck && bSysCheck)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#20
0
文件: Form1.cs 项目: IAGDQA/WA
 private void ReturnSCADAPage(IAdvSeleniumAPI api)
 {
     api.SwitchToCurWindow(0);
     api.SwitchToFrame("leftFrame", 0);
     api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name=TestSCADA')]").Click();
 }
示例#21
0
文件: Form1.cs 项目: aaronhuang945/WA
        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");

            //Step 0: Download
            //EventLog.AddLog("Download...");
            //StartDownload(api, sTestLogFolder);

            //Step1: Copy DatalogTrendHotKey.kmp, dlogtrd.bxx and dlogtrd.dxx to specified path
            //        to C:\WebAccess\Node\config\ProjectName\bgr
            {
                //string sCurrentFilePath = Directory.GetCurrentDirectory();
                string sCurrentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location);

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

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

                string sourceFile3 = sCurrentFilePath + "\\DatalogTrendSettingFile\\dlogtrd.dxx";
                string destFile3_1 = string.Format("C:\\WebAccess\\Node\\config\\{0}_TestSCADA\\drw\\dlogtrd.dxx", 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);
            }

            //Create Data Log Trend
            EventLog.AddLog("Create Data Log Trend...");
            CreateDataLogTrend();
            PrintStep("Create Data Log Trend");

            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;
        }
示例#22
0
文件: Form1.cs 项目: aaronhuang945/WA
        private void RestrictedUserLoginCheck(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            EventLog.AddLog("Restricted user check");
            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
            int i = api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();

            PrintStep("Configure project");

            // Start view
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//tr[2]/td/a/font").Click();
            PrintStep("Start View");

            // Control browser
            int iIE_Handl, iIE_Handl_2, iIE_Handl_3, iIE_Handl_4, iIE_Handl_5, iIE_Handl_6, iIE_Handl_7, iWA_MainPage = 0;

            switch (slanguage)
            {
            case "ENG":
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "Node : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Node : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;

            case "CHT":
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "節點 : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "節點 : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;

            case "CHS":
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "节点 : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "节点 : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;

            case "JPN":
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "ノード : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "ノード : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;

            case "KRN":
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "노드 : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "노드 : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;

            case "FRN":
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "Noeud : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Noeud : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;

            default:
                iIE_Handl    = tpc.F_FindWindow("IEFrame", "Node : TestSCADA - main:untitled");
                iIE_Handl_2  = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
                iIE_Handl_3  = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Node : TestSCADA - Internet Explorer");
                iIE_Handl_4  = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
                iIE_Handl_5  = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
                iIE_Handl_6  = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
                iIE_Handl_7  = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
                iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
                break;
            }

            /*
             * int iIE_Handl = tpc.F_FindWindow("IEFrame", "Node : TestSCADA - main:untitled");
             * int iIE_Handl_2 = tpc.F_FindWindowEx(iIE_Handl, 0, "Frame Tab", "");
             * int iIE_Handl_3 = tpc.F_FindWindowEx(iIE_Handl_2, 0, "TabWindowClass", "Node : TestSCADA - Internet Explorer");
             * int iIE_Handl_4 = tpc.F_FindWindowEx(iIE_Handl_3, 0, "Shell DocObject View", "");
             * int iIE_Handl_5 = tpc.F_FindWindowEx(iIE_Handl_4, 0, "Internet Explorer_Server", "");
             * int iIE_Handl_6 = tpc.F_FindWindowEx(iIE_Handl_5, 0, "AfxOleControl42s", "");
             * int iIE_Handl_7 = tpc.F_FindWindowEx(iIE_Handl_6, 0, "AfxWnd42s", "");
             * int iWA_MainPage = tpc.F_FindWindowEx(iIE_Handl_7, 0, "ActXBroadWinBwviewWClass", "Advantech View 001 - main:untitled");
             */

            if (iWA_MainPage > 0)
            {
                //SendMessage(iWA_MainPage, BM_CLICK, 0, 0);
                //SendMessage(iWA_MainPage, WM_RBUTTONDOWN, 0, 0);
                //SendMessage(iWA_MainPage, WM_RBUTTONDOWN, MK_RBUTTON, 0);
                tpc.F_PostMessage(iWA_MainPage, tpc.V_WM_KEYDOWN, tpc.V_VK_ESCAPE, 0);
                System.Threading.Thread.Sleep(1000);
            }
            else
            {
                EventLog.AddLog("Cannot get Start View WebAccess Main Page handle");
            }

            // Login keyboard
            int iLoginKeyboard_Handle;

            switch (slanguage)
            {
            case "ENG":
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Login");
                break;

            case "CHT":
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "登入");
                break;

            case "CHS":
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "登录");
                break;

            case "JPN":
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "ログイン");
                break;

            case "KRN":
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "로그인");
                break;

            case "FRN":
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Connexion");
                break;

            default:
                iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Login");
                break;
            }
            int iEnterText = tpc.F_FindWindowEx(iLoginKeyboard_Handle, 0, "Edit", "");
            int iEnter_PW  = tpc.F_GetWindow(iEnterText, tpc.V_GW_HWNDNEXT);

            if (iEnterText > 0 && iEnter_PW > 0)
            {
                SendCharToHandle(iEnterText, 100, "RestrictedUser");
                SendCharToHandle(iEnter_PW, 100, "34567890");

                tpc.F_PostMessage(iEnterText, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0);

                System.Threading.Thread.Sleep(1000);
            }
            else
            {
                EventLog.AddLog("Cannot get Login keyboard handle");
            }

            Thread.Sleep(2000);
            EventLog.PrintScreen("RestrictedUserCheck");

            api.Quit();
            PrintStep("Quit browser");
        }
示例#23
0
文件: Form1.cs 项目: aaronhuang945/WA
        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 Report

            EventLog.AddLog("Create Report...");
            Create_Report();
            PrintStep("Create Report");

            EventLog.PrintScreen("ReportTest");

            /*
             * // copy ExcelReport_SelfDefined_DataLog_Excel_ex.xlsx to log path.
             * //C:\inetpub\wwwroot\broadweb\WaExlViewer\report\TestProject_TestSCADA\ExcelReport_SelfDefined_DataLog_Excel
             * {
             *  string fileNameSrc = "ExcelReport_SelfDefined_DataLog_Excel_ex.xlsx";
             *  string fileNameTar = string.Format("ExcelReport_SelfDefined_DataLog_Excel_ex_{0:yyyyMMdd_hhmmss}.xlsx", DateTime.Now);
             *
             *  string sourcePath = string.Format(@"C:\inetpub\wwwroot\broadweb\WaExlViewer\report\{0}_TestSCADA", sProjectName);
             *  string targetPath = sTestLogFolder;
             *
             *  // Use Path class to manipulate file and directory paths.
             *  string sourceFile = System.IO.Path.Combine(sourcePath, fileNameSrc);
             *  string destFile = System.IO.Path.Combine(targetPath, fileNameTar);
             *  System.IO.File.Copy(sourceFile, destFile, true);
             * }
             */
            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;
        }
示例#24
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;
        }
示例#25
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;
        }
示例#26
0
文件: Form1.cs 项目: IAGDQA/WA
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            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/bwRoot.asp?username=admin");
            api.ByXpath("//a[contains(@href, '/broadWeb/bwconfig.asp?username=admin')]").Click();
            api.ById("userField").Enter("").Submit().Exe();
            PrintStep("Login WebAccess");

            // Configure project by project name
            api.ByXpath("(//a[contains(@href, 'userName=admin&projectName1=" + sProjectName + "')])[2]").Click();   //跳到NodeRED設定頁面
            PrintStep("Configure NodeRED page");

            // Dashboard NodeRED test

            /*
             * 主要動作
             * 1 新增第2個分頁
             * 2 在第2個分頁導入node red資料
             * 3 新增第3個分頁 刪除第3個分頁 (因為導入資料後 無法作滑鼠點擊的動作 只好用這個動作取代滑鼠點擊)
             * 4 第2個分頁重新命名 並 deploy
             * 5 觸發且讀取得到的值並判斷是否正確
             * 6 刪除第2個分頁
             */
            bool bNodeREDResult = bNodeREDDashboardNodeTest(sProjectName, sTestLogFolder);

            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 && bNodeREDResult)
            {
                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);
            }
        }
示例#27
0
文件: Form1.cs 项目: IAGDQA/WA
        private void GroundPC_DeleteProject(string sBrowser, string sProjectName, string sWebAccessIP, 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, "<GroundPC> Login WebAccess");

            EventLog.AddLog("<GroundPC> Delete " + sProjectName + " project.");
            api.ByXpath("//a[contains(@href, '/broadWeb/project/deleteProject.asp?') and contains(@href, 'ProjName=" + sProjectName + "')]").Click();

            // Confirm to delete project
            string alertText = api.GetAlartTxt();

            //if (alertText == "Delete this project (" + sProjectName + "), are you sure?")
            //    api.Accept();
            switch (slanguage)
            {
            case "ENG":
                if (alertText == "Delete this project (" + sProjectName + "), are you sure?")
                {
                    api.Accept();
                }
                break;

            case "CHT":
                if (alertText == "您確定要刪除這個工程(" + sProjectName + ")?")
                {
                    api.Accept();
                }
                break;

            case "CHS":
                if (alertText == "您肯定要删除工程(" + sProjectName + ")吗?")
                {
                    api.Accept();
                }
                break;

            case "JPN":
                if (alertText == "このプロジェクト (" + sProjectName + ") を削除してもよろしいですか?")
                {
                    api.Accept();
                }
                break;

            case "KRN":
                if (alertText == "이 프로젝트(" + sProjectName + ")를 삭제합니다. 계속하시겠습니까?")
                {
                    api.Accept();
                }
                break;

            case "FRN":
                if (alertText == "Supprimer ce projet (" + sProjectName + "), êtes-vous sûr ?")
                {
                    api.Accept();
                }
                break;

            default:
                if (alertText == "Delete this project (" + sProjectName + "), are you sure?")
                {
                    api.Accept();
                }
                break;
            }
            PrintStep(api, "<GroundPC> Delete " + sProjectName + "Node");

            Thread.Sleep(10000);

            api.Quit();
            PrintStep(api, "<CloudPC> Quit browser");
        }
示例#28
0
文件: Form1.cs 项目: aaronhuang945/WA
        long Form1_Load(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser)
        {
            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");

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

            try
            {
                EventLog.AddLog("start kernel");
                wacf.StartKernel(api);
            }
            catch (Exception ex)
            {
                EventLog.AddLog(ex.ToString());
            }

            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;
        }
示例#29
0
文件: Form1.cs 项目: aaronhuang945/WA
        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);
            }
        }