Exemplo n.º 1
0
    void CheckWAConfig()
    {
        PrintTitle("Check Enable Status");
        api.ById("advancedFunction").ClickAndWait(1000);
        api.ById("dataLog").ClickAndWait(1000);
        api.ByTxt("WebAccess I/O Configuration").ClickAndWait(1000);
        //
        if (ai_point > 0)
        {
            PrintTitle("Check AI-1 would be disable");
            api.ByTxt("AI").ClickAndWait(1000);
            string resStr = api.ByXpath("(//input[@type='checkbox'])[22]").GetAttr("checked");
            PrintTitle("Check AI-0 result is [" + resStr + "]");
        }
        else if (di_point > 0)
        {
            PrintTitle("Check DI-0 would be disable");
            string resStr = api.ByXpath("(//input[@type='checkbox'])[6]").GetAttr("checked");
            PrintTitle("Check DI-0 result is [" + resStr + "]");
        }

        //if (do_point > 0)
        //{
        //    PrintTitle("Check DO-0");
        //    api.ByTxt("DO/Relay").ClickAndWait(1000);
        //    string resStr = api.ByXpath("(//input[@type='checkbox'])[14]").GetAttr("checked");
        //    PrintTitle("Check DO-0 result is [" + resStr + "]");
        //}


        PrintStep();
    }
Exemplo n.º 2
0
 void CloudConfig()
 {
     api.ById("configuration").ClickAndWait(1000);
     api.ByTxt("Cloud").ClickAndWait(3000);
     api.Select(4).ByXpath("//select[@id='selCloud']").Exe();
     api.Wait(1000);
     api.Enter(txtCloudIp.Text).Clear().ById("Nm").Exe();
     api.Enter("WISE-DQA").Clear().ById("PNm").Exe();
     api.Enter(RenameModname() + "-AUTOTEST").Clear().ById("NNm").Exe();
     api.Enter("60").Clear().ById("HbF").Exe();
     api.Enter("80").Clear().ById("PWeb").Exe();
     api.Enter("admin").Clear().ById("Pu").Exe();
     api.Enter("12345").Clear().ById("Pw").Exe();
     api.ById("btnWebAccessSubmit").Click();
     PrintStep();
 }
Exemplo n.º 3
0
    void CheckWAConfig()
    {
        PrintTitle("Check Enable Status");
        api.ById("advancedFunction").ClickAndWait(1000);
        api.ById("dataLog").ClickAndWait(1000);
        api.ByTxt("WebAccess I/O Configuration").ClickAndWait(1000);
        //
        PrintTitle("Disable IO Tag");
        if (di_point > 0)
        {
            if (api.ByXpath("(//input[@type='checkbox'])[4]").GetAttr("checked") == "true")
            {
                PrintTitle("Disable DI-0 checkbox");
                api.ByXpath("(//input[@type='checkbox'])[4]").Click();
                api.ByXpath("//div[@id='tabWebAccessLog']/div/div/div/div[2]/div/button").Click();
            }
        }

        if (do_point > 0)
        {
            api.ByTxt("DO/Relay").ClickAndWait(1000);
            if (api.ByXpath("(//input[@type='checkbox'])[14]").GetAttr("checked") == "true")
            {
                PrintTitle("Disable DO-0 checkbox");
                api.ByXpath("(//input[@type='checkbox'])[14]").Click();
                api.ByXpath("//div[@id='tabWebAccessLog']/div/div/div/div[2]/div/button").Click();
            }
        }

        if (ai_point > 0)
        {
            api.ByTxt("AI").ClickAndWait(1000);
            if (api.ByXpath("(//input[@type='checkbox'])[20]").GetAttr("checked") == "true")
            {
                PrintTitle("Disable AI-0 checkbox");
                api.ByXpath("(//input[@type='checkbox'])[20]").Click();
                api.ByXpath("//div[@id='tabWebAccessLog']/div/div/div/div[2]/div/button").Click();
            }
        }
        PrintStep();
    }
Exemplo n.º 4
0
        private void Create_SelfDefined_Datalog_ExcelReport(string sUserEmail)
        {
            api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click();

            api.ByName("rptName").Clear();
            api.ByName("rptName").Enter("ExcelReport_SelfDefined_DataLog_Excel").Exe();
            api.ByName("dataSrc").Click();  // Click "Data Log" button
            api.ByName("selectTemplate").SelectVal("template1.xlsx").Exe();
            switch (slanguage)
            {
            case "ENG":
                api.ByName("speTimeFmt").SelectTxt("Self-Defined").Exe();
                break;

            case "CHT":
                api.ByName("speTimeFmt").SelectTxt("自訂").Exe();
                break;

            case "CHS":
                api.ByName("speTimeFmt").SelectTxt("自订").Exe();
                break;

            case "JPN":
                api.ByName("speTimeFmt").SelectTxt("Self-Defined").Exe();
                break;

            case "KRN":
                api.ByName("speTimeFmt").SelectTxt("Self-Defined").Exe();
                break;

            case "FRN":
                api.ByName("speTimeFmt").SelectTxt("Self-Defined").Exe();
                break;

            default:
                api.ByName("speTimeFmt").SelectTxt("Self-Defined").Exe();
                break;
            }

            // set today as start/end date
            string sToday    = DateTime.Now.ToString("%d");
            string sTomorrow = DateTime.Now.AddDays(+1).ToString("%d");

            api.ByName("tStart").Click();
            Thread.Sleep(500);
            api.ByTxt(sToday).Click();
            Thread.Sleep(500);
            api.ByXpath("(//button[@type='button'])[2]").Click();

            if (sTomorrow != "1")
            {
                api.ByName("tEnd").Click();
                Thread.Sleep(500);
                api.ByTxt(sTomorrow).Click();
                Thread.Sleep(500);
                api.ByXpath("(//button[@type='button'])[2]").Click();
            }
            else  // 跳頁
            {
                api.ByName("tEnd").Click();
                Thread.Sleep(500);
                api.ByCss("span.ui-icon.ui-icon-circle-triangle-e").Click();
                Thread.Sleep(500);
                api.ByTxt(sTomorrow).Click();
                Thread.Sleep(500);
                api.ByXpath("(//button[@type='button'])[2]").Click();
            }

            api.ByName("interval").Clear();
            api.ByName("interval").Enter("1").Exe();
            api.ByXpath("(//input[@name='fileType'])[2]").Click();

            // 湊到最大上限32個TAG
            string[] ReportTagName = { "Calc_ConAna",       "Calc_ConDis",   "Calc_ModBusAI", "Calc_ModBusAO", "Calc_ModBusDI",  "Calc_ModBusDO",     "Calc_OPCDA",        "Calc_OPCUA", "Calc_System",
                                       "Calc_ANDConDisAll", "Calc_ANDDIAll", "Calc_ANDDOAll", "Calc_AvgAIAll", "Calc_AvgAOAll",  "Calc_AvgConAnaAll", "Calc_AvgSystemAll",
                                       "AT_AI0050",         "AT_AI0100",     "AT_AI0150",     "AT_AO0050",     "AT_AO0100",      "AT_AO0150",         "AT_DI0050",         "AT_DI0100",  "AT_DI0150",  "AT_DO0050",
                                       "AT_DO0100",         "AT_DO0150",     "ConAna_0100",   "ConDis_0100",   "SystemSec_0100", "SystemSec_0200" };
            for (int i = 0; i < ReportTagName.Length; i++)
            {
                try
                {
                    api.ById("tagsLeftList").SelectTxt(ReportTagName[i]).Exe();
                }
                catch (Exception ex)
                {
                    EventLog.AddLog("CreateExcelReport error: " + ex.ToString());
                    i--;
                }
            }
            api.ById("torightBtn").Click();
            api.ById("tagsRightList").SelectTxt(ReportTagName[0]).Exe();

            api.ByXpath("(//input[@name='attachFormat'])[2]").Click();
            api.ByName("emailto").Clear();
            api.ByName("emailto").Enter(sUserEmail).Exe();
            api.ByName("cfgSubmit").Click();
        }
Exemplo n.º 5
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);
            }

            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;
        }
Exemplo n.º 6
0
        private bool bAlarmLogCheck(string sProjectName)
        {
            bool bCheckAlarm = true;

            //string[] ToBeTestTag = { "AT_AI0001", "AT_AO0001", "AT_DI0001", "AT_DO0001", "Calc_ConAna", "Calc_ConDis", "ConAna_0001", "ConDis_0001", "SystemSec_0001" };
            string[] ToBeTestTag = { "Calc_ConAna", "SystemSec_0001", "AT_AO0001", "AT_AI0001", "ConDis_0001", "ConAna_0001", "ConAna_0125", "ConAna_0250" };

            for (int i = 0; i < ToBeTestTag.Length; i++)
            {
                EventLog.AddLog("Go to Alarm log setting page");
                api.ByXpath("//a[contains(@href, '/broadWeb/syslog/LogPg.asp') and contains(@href, 'pos=alarm')]").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 = DateTime.Now.ToString("%d");
                api.ByName("DateStart").Click();
                Thread.Sleep(1000);
                api.ByTxt(sToday).Click();
                Thread.Sleep(1000);
                EventLog.AddLog("select start date to today: " + sToday);

                // select one tag to get ODBC data
                EventLog.AddLog("select " + ToBeTestTag[i] + " to get ODBC data");
                api.ById("alltags").Click();

                api.ById("TagNameSel").SelectTxt(ToBeTestTag[i]).Exe();

                api.ById("addtag").Click();
                api.ById("TagNameSelResult").SelectTxt(ToBeTestTag[i]).Exe();

                Thread.Sleep(1000);
                api.ByName("PageSizeSel").Enter("").Submit().Exe();
                PrintStep("Set and get " + ToBeTestTag[i] + " alarm ODBC tag data");
                EventLog.AddLog("Get " + ToBeTestTag[i] + " ODBC data");

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

                api.ByXpath("//*[@id=\"myTable\"]/thead[1]/tr/th[3]/a").Click(); // click time to sort data
                Thread.Sleep(5000);
                //api.ByXpath("//*[@id=\"myTable\"]/thead[1]/tr/th[4]/a").Click();    // click tagname to sort data
                //Thread.Sleep(5000);

                bool bRes_ConAna = true;
                if (ToBeTestTag[i] == "ConAna_0001" || ToBeTestTag[i] == "ConAna_0125" || ToBeTestTag[i] == "ConAna_0250")
                {
                    bRes_ConAna = bCheckConAnaRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_ConDis = true;
                if (ToBeTestTag[i] == "ConDis_0001")
                {
                    bRes_ConDis = bCheckConDisRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_AI = true;
                if (ToBeTestTag[i] == "AT_AI0001")
                {
                    bRes_AI = bCheckAIRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_AO = true;
                if (ToBeTestTag[i] == "AT_AO0001")
                {
                    bRes_AO = bCheckAORecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_Sys = true;
                if (ToBeTestTag[i] == "SystemSec_0001")
                {
                    bRes_Sys = bCheckSysRecordAlarm(ToBeTestTag[i]);
                }

                bool bRes_Calc = true;
                if (ToBeTestTag[i] == "Calc_ConAna")
                {
                    bRes_Calc = bCheckCalcRecordAlarm(ToBeTestTag[i]);
                }

                if ((bRes_ConAna && bRes_AI && bRes_AO && bRes_Sys && bRes_Calc) == false)
                {
                    bCheckAlarm = false;
                    break;
                }
                // print screen
                EventLog.PrintScreen(ToBeTestTag[i] + "_AlarmLogData");

                api.ByXpath("//*[@id=\"div1\"]/table/tbody/tr[1]/td[3]/a[5]/font").Click();     //return to homepage
            }

            return(bCheckAlarm);
        }