示例#1
0
文件: Form1.cs 项目: aaronhuang945/WA
        private void CreateOPCComportDevice()
        {
            // Create com port
            EventLog.AddLog("Create com port");
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            Thread.Sleep(1000);
            api.ByName("infName").SelectVal("OPC").Exe();
            Thread.Sleep(1000);
            api.ByName("ComportNbr").Clear();
            api.ByName("ComportNbr").Enter("4").Exe();  // comport = 4
            api.ByName("OPCServer").Clear();
            api.ByName("OPCServer").Enter("Kepware.KEPServerEX.V5").Submit().Exe();
            //api.ByName("submit").Click();
            Thread.Sleep(1000);
            PrintStep("Create OPC Communication Port");

            // add device
            EventLog.AddLog("add device");
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=comport') and contains(@href, 'name=4')]").Click(); // name = 4
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            api.ByName("DeviceName").Clear();
            api.ByName("DeviceName").Enter("OPCDA").Submit().Exe();
            //api.ByName("submit").Click();
            api.Refresh();
            PrintStep("Create OPCDA Device");
        }
示例#2
0
        private void CreateOPCComportDevice(string sIP)
        {
            // Create com port
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            Thread.Sleep(1000);
            api.ByName("infName").SelectVal("TCPIP").Exe();
            Thread.Sleep(1000);
            api.ByName("ComportNbr").Clear();
            api.ByName("ComportNbr").Enter("5").Submit().Exe();  // comport = 5
            //api.ByName("submit").Click();
            Thread.Sleep(1000);
            PrintStep("Create OPC Communication Port");

            // add device
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=comport') and contains(@href, 'name=5')]").Click(); // name = 5
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/device/devPg.asp') and contains(@href, 'action=add')]").Click();    // add

            api.ByName("DeviceTypeSel").SelectVal("OPCUA").Exe();
            Thread.Sleep(1000);
            api.ByName("P_IPAddr").Clear();
            api.ByName("P_IPAddr").Enter(sIP).Exe();
            api.ByName("P_PortNbr").Clear();
            api.ByName("P_PortNbr").Enter("49320").Exe();
            api.ByName("DeviceName").Clear();
            api.ByName("DeviceName").Enter("OPCUA").Submit().Exe();
            //api.ByName("submit").Click();
            api.Refresh();
            PrintStep("Create OPCUA Device");
        }
示例#3
0
文件: Form1.cs 项目: aaronhuang945/WA
        private void AddDevice(string sWebAccessIP)
        {
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("leftFrame", 0);
            api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=comport') and contains(@href, 'name=3')]").Click(); // port = 3
            api.SwitchToCurWindow(0);
            api.SwitchToFrame("rightFrame", 0);
            api.ByXpath("//a[3]/font/b").Click();
            api.ByName("DeviceName").Clear();
            api.ByName("DeviceName").Enter("ModSim").Exe();
            api.ByName("DeviceTypeSel").SelectTxt("Modicon").Exe();
            api.ByName("P_IPAddr").Clear();
            api.ByName("P_IPAddr").Enter(sWebAccessIP).Exe();
            api.ByName("P_PortNbr").Clear();
            api.ByName("P_PortNbr").Enter("502").Exe();
            api.ByName("P_DevAddr").Clear();
            api.ByName("P_DevAddr").Enter("1").Submit().Exe();

            api.Refresh();
        }
示例#4
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;
        }