private void CreateAlarmGroup() { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'pos=AlmGrpList')]").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/AlarmGrp/AlmGrpPg.asp') and contains(@href, 'action=add_almgr')]").Click(); string[] AlarmTagName = { "AT_AI0001", "AT_AO0001", "AT_DI0001", "AT_DO0001", "ConDis_0001", "SystemSec_0001", "Calc_ConAna", "ConAna_0001", "ConAna_0002", "ConAna_0004", "ConAna_0008", "ConAna_0016", "ConAna_0032","ConAna_0064", "ConAna_0128" }; for (int i = 0; i < AlarmTagName.Length; i++) { try { string tagName = "TagName" + (i + 1).ToString("000"); api.ByName(tagName).Enter(AlarmTagName[i]).Exe(); } catch (Exception ex) { EventLog.AddLog("CreateAlarmGroup" + ex.ToString()); i--; } } api.ByName("TagName").Enter("Alarm Group Set").Submit().Exe(); }
private void CreateAccTag() { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[4]/font/b").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/tag/tagPg.asp') and contains(@href, 'dt=AccType')]").Click(); // Acc point EventLog.AddLog("Create accumulation point"); api.ByName("AccFreq").Clear(); api.ByName("AccFreq").Enter("5").Exe(); SetupBasicAnalogTagConfig(); for (int i = 1; i <= 5; i++) { try { api.ByName("TagName").Clear(); api.ByName("TagName").Enter("Acc_" + i.ToString("0000")).Exe(); api.ByName("Source").Clear(); api.ByName("Source").Enter("ConDis_" + i.ToString("0000")).Submit().Exe(); } catch (Exception ex) { EventLog.AddLog("CreateAccTag error: " + ex.ToString()); i--; } } PrintStep("Create accumulation point"); }
private void CreateRealTimeTrend() { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'pos=RTrendList')]").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/rtrend/RTrendPg.asp') and contains(@href, 'action=add_rtrend')]").Click(); string[] CalcTagName = { "System", "ConAna", "ConDis", "ModBusAI", "ModBusAO", "ModBusDI", "ModBusDO", "OPCDA", "OPCUA", "Acc" }; for (int i = 0; i < CalcTagName.Length; i++) { try { string tagName = "TagName" + (i + 1).ToString("000"); string dispH = "DispH" + (i + 1).ToString("000"); string dispL = "DispL" + (i + 1).ToString("000"); api.ByName(tagName).Enter("Calc_" + CalcTagName[i]).Exe(); api.ByName(dispH).Enter("100").Exe(); api.ByName(dispL).Enter("0").Exe(); } catch (Exception ex) { EventLog.AddLog("CreateRealTimeTrend error: " + ex.ToString()); i--; } } api.ByName("Description").Enter("").Submit().Exe(); }
private void ExcuteExcelIn(string sSourceFile) { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/odbc/odbcPg1.asp?pos=import')]").Click(); api.ByName("XlsName").Clear(); api.ByName("XlsName").Enter(sSourceFile).Submit().Exe(); }
private void CreateSCADANode(string sWebAccessIP, string sUserEmail) { // Create SCADA node api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[2]/font/b").Click(); Thread.Sleep(1000); api.ByName("NodeName").Clear(); api.ByName("NodeName").Enter("TestSCADA").Exe(); api.ByName("AddressLong").Clear(); api.ByName("AddressLong").Enter(sWebAccessIP).Exe(); api.ByName("EMAIL_SERVER").Clear(); //Outgoing Email (SMTP) Server api.ByName("EMAIL_SERVER").Enter("smtp.mail.yahoo.com").Exe(); api.ByName("EMAIL_PORT").Clear(); api.ByName("EMAIL_PORT").Enter("587").Exe(); api.ByName("EMAIL_ADDRESS").Clear(); api.ByName("EMAIL_ADDRESS").Enter("*****@*****.**").Exe(); api.ByName("EMAIL_USER").Clear(); //Email Account Name api.ByName("EMAIL_USER").Enter("webaccess2016").Exe(); //api.ByXpath("input[@name='D_EMAIL_PASSWORD']").Clear(); // Email Password // 目前有問題無法成功輸入 //api.ByXpath("input[@name='D_EMAIL_PASSWORD']").Enter("123214").Exe(); //api.ByName("D_MAIL_PASSWORD").Clear(); //api.ByName("D_MAIL_PASSWORD").Enter("xxxx").Exe(); //api.ByName("D_MAIL_PASSWORDB").Clear(); //api.ByName("D_MAIL_PASSWORDB").Enter("xxxx").Exe(); api.ByName("EMAIL_FROM").Clear(); api.ByName("EMAIL_FROM").Enter("*****@*****.**").Exe(); api.ByName("EMAIL_TO_SRPT").Clear(); api.ByName("EMAIL_TO_SRPT").Enter("*****@*****.**").Exe(); api.ByName("EMAIL_TO").Clear(); api.ByName("EMAIL_TO").Enter("*****@*****.**").Exe(); api.ByName("EMAIL_CC").Clear(); api.ByName("EMAIL_CC").Enter(sUserEmail).Exe(); api.ByName("ALARM_LOG_TO_ODBC").Click(); api.ByName("CHANGE_LOG_TO_ODBC").Click(); api.ByName("DATA_LOG_TO_ODBC").Click(); api.ByName("DATA_LOG_USE_RTDB").Click(); EventLog.AddLog("Enter some required info done and submit start"); int iSubmitResult = api.ByName("Max_Number_of_Client").Enter("").Submit().Exe(); // for IE special if (iSubmitResult == 0) { EventLog.AddLog("submit success!!"); } else { EventLog.AddLog("submit fail!!"); } Thread.Sleep(1000); PrintStep("Create SCADA Node"); }
private void ViewandCheckCloudTagInfo() { PrintTitle("ViewandCheckCloudTagInfo"); api.LinkWebUI(txtCloudIp.Text + "/broadWeb/bwconfig.asp?username=admin"); api.ById("userField").Enter("").Submit().Exe(); PrintStep(); // Configure project by project name string sProjectName = "WISE%2DDQA"; // WISE-DQA api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); PrintStep(); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//td[2]/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/a/font").Click(); // 檢查AUTOTEST-DO0是否可以正確被選取到 若刪除AUTOTEST-AI0 tag失敗,那會取到AUTOTEST-AI0的值 System.Threading.Thread.Sleep(2000); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); if (ai_point > 0) { PrintTitle("Check the next tag name AI-1"); string sTagChangedName = api.ByXpath("//tr[2]/td[2]").GetText().Trim(); if (sTagChangedName != "AUTOTEST-AI_1") { PrintTitle("Fail for result [" + sTagChangedName + "]."); } else { PrintTitle("Success"); } } else if (di_point > 0) { PrintTitle("Check the next tag name DI-1"); string sTagChangedName = api.ByXpath("//tr[2]/td[2]").GetText().Trim(); if (sTagChangedName != "AUTOTEST-DI_1") { PrintTitle("Fail for result [" + sTagChangedName + "]."); } else { PrintTitle("Success"); } } PrintStep(); } // G2C
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
private void CreateModbusServerConfig() { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/modbusSrv/ModbusSrvPortLst.asp')]").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/modbusSrv/addupModbusSrvPort.asp') and contains(@href, 'act=add')]").Click(); api.ByName("srvName").Enter("ModbusServer").Exe(); api.ById("PortType").SelectVal("TCPIP").Exe(); api.ByName("ENABLE_EXCEPTION").Click(); api.ByXpath("//button[@type='submit']").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/modbusSrv/addModbusSrvTag.asp')]").Click(); for (int i = 1; i <= 10; i++) { api.ByName("Address").Clear(); api.ByName("Address").Enter("4" + i.ToString("0000")).Exe(); api.ByName("TagName").Clear(); api.ByName("TagName").Enter("ConAna_" + i.ToString("0000")).Submit().Exe(); } }
private void StopNode() { PrintTitle("StopNode"); api.LinkWebUI(txtCloudIp.Text + "/broadWeb/bwconfig.asp?username=admin"); api.ById("userField").Enter("").Submit().Exe(); PrintStep(); string sProjectName = "WISE%2DDQA"; // WISE-DQA api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); PrintStep(); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a[6]/font").Click(); // Stop kernel System.Threading.Thread.Sleep(2000); 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); } if (main != items[1]) { api.SwitchToWinHandle(items[1]); } else { 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(); System.Threading.Thread.Sleep(30000); // Wait 30s for Stop kernel finish api.Close(); api.SwitchToWinHandle(main); // switch back to original window PrintStep(); }
private void ReturnSCADAPage() { //driver.SwitchTo().Window(driver.CurrentWindowHandle); // Return parent frame //driver.SwitchTo().Frame("leftFrame"); // Focus on left frame //driver.FindElement(By.XPath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name=TestSCADA')]")).Click(); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name=TestSCADA')]").Click(); }
private void DeleteCloudTag() // C2G { PrintTitle("DeleteCloudTag"); api.LinkWebUI(txtCloudIp.Text + "/broadWeb/bwconfig.asp?username=admin"); api.ById("userField").Enter("").Submit().Exe(); PrintStep(); // Configure project by project name string sProjectName = "WISE%2DDQA"; // WISE-DQA api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); PrintStep(); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); // 刪除第一個Tag api.ByXpath("//td[2]/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/a/font").Click(); System.Threading.Thread.Sleep(2000); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/tag/deleteTag.asp') and contains(@href, 'action=delete_tag')]").Click(); // delete string alertText = api.GetAlartTxt(); if (alertText == "Delete this tag, are you sure?") { api.Accept(); } api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name=" + GetNodeName() + "')]").Click(); StartDownload(api); }
private void CreateSystemTag() { EventLog.AddLog("Create System tags start..."); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[7]/font/b").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/tag/tagPg.asp') and contains(@href, 'dt=SysType')]").Click(); api.ByName("ParaName").SelectVal("TM_Sec").Exe(); Thread.Sleep(500); SetupBasicSystemTagConfig(); for (int i = 1; i <= 5; i++) { try { api.ByName("TagName").Clear(); api.ByName("TagName").Enter("SystemSec_" + i.ToString("0000")).Submit().Exe(); } catch (Exception ex) { EventLog.AddLog("CreateSystemTag error: " + ex.ToString()); i--; } } }
private void AddComport() { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[3]/font/b").Click(); Thread.Sleep(500); api.ByName("infName").SelectVal("TCPIP").Exe(); Thread.Sleep(500); api.ByName("ComportNbr").Clear(); api.ByName("ComportNbr").Enter("3").Submit().Exe(); // comport = 3 }
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"); }
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 }
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(); }
private void StartViewRealTimeTrend() { // Start view EventLog.AddLog("Start view"); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a/font").Click(); PrintStep("Start View"); // Control browser EventLog.AddLog("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) { 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 EventLog.AddLog("admin login"); 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", ""); if (iEnterText > 0) { tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'a', 0); System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'd', 0); //d System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'm', 0); //m System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'i', 0); //i System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'n', 0); //n System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); System.Threading.Thread.Sleep(500); tpc.F_PostMessage(iWA_MainPage, tpc.V_WM_KEYDOWN, tpc.V_VK_F3, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get Login keyboard handle"); } int iRealTimeTrend_Handle; switch (slanguage) { case "ENG": iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "Realtime Trend List"); break; case "CHT": iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "即時趨勢列表"); break; case "CHS": iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "实时趋势列表"); break; case "JPN": iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "リアルタイム トレンド一覧"); break; case "KRN": iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "실시간 트랜드 리스트"); break; case "FRN": iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "Liste courbes en temps réel"); break; default: iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "Realtime Trend List"); break; } //int iRealTimeTrend_Handle = tpc.F_FindWindow("#32770", "Realtime Trend List"); int iEnterText2 = tpc.F_FindWindowEx(iRealTimeTrend_Handle, 0, "Edit", ""); if (iEnterText2 > 0) { tpc.F_PostMessage(iEnterText2, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); } else { EventLog.AddLog("Cannot get Realtime Trend List handle"); } }
private void PowerUserLoginCheck(string sProjectName, string sWebAccessIP, string sTestLogFolder, string sBrowser) { EventLog.AddLog("Power 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 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, "PowerUser"); SendCharToHandle(iEnter_PW, 100, "12345678"); 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("PowerUserCheck"); api.Quit(); PrintStep("Quit browser"); }
private void GroundPC_DeleteTag() { // Delete AT_AI0004/AT_AO0004/AT_DI0004/AT_DO0004/OPCDA_0004/OPCUA_0004/Acc_0004/ConAna_0004/SystemSec_0004 EventLog.AddLog("<GroundPC> Delete AT_AI0004/AT_AO0004/AT_DI0004/AT_DO0004 tags"); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[3]/img").Click(); //ModSim api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("(//input[@name='tsel'])[4]").Click(); //AT_AI0004 api.ByXpath("(//input[@name='tsel'])[254]").Click(); //AT_AO0004 api.ByXpath("(//input[@name='tsel'])[504]").Click(); //AT_DI0004 api.ByXpath("(//input[@name='tsel'])[754]").Click(); //AT_DO0004 api.ByCss("span.e5").Click(); // delete string alertText = api.GetAlartTxt(); if (alertText == "Are you sure you want to delete these tags?" || alertText == "Are you sure you want to delete these 4 tags?") { api.Accept(); } PrintStep(api, "<GroundPC> Delete AT_AI0004/AT_AO0004/AT_DI0004/AT_DO0004 tags"); EventLog.AddLog("<GroundPC> Delete OPCDA_0004 tag"); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//tr[2]/td/table/tbody/tr/td/a[3]/img").Click(); //OPCDA api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("(//input[@name='tsel'])[4]").Click(); //OPCDA_0004 api.ByCss("span.e5").Click(); // delete string alertText2 = api.GetAlartTxt(); if (alertText2 == "Are you sure you want to delete these tags?" || alertText2 == "Are you sure you want to delete these 1 tags?") { api.Accept(); } PrintStep(api, "<GroundPC> Delete OPCDA_0004 tag"); EventLog.AddLog("<GroundPC> Delete OPCUA_0004 tag"); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//tr[3]/td/table/tbody/tr/td/a[3]/img").Click(); //OPCUA api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("(//input[@name='tsel'])[4]").Click(); //OPCUA_0004 api.ByCss("span.e5").Click(); // delete string alertText3 = api.GetAlartTxt(); if (alertText3 == "Are you sure you want to delete these tags?" || alertText3 == "Are you sure you want to delete these 1 tags?") { api.Accept(); } PrintStep(api, "<GroundPC> Delete OPCUA_0004 tag"); EventLog.AddLog("<GroundPC> Delete Acc_0004 tag"); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=AccList')]").Click(); //Acc Point api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("(//input[@name='tsel'])[4]").Click(); //Acc_0004 //api.ByXpath("(//a[contains(text(),'Delete')])[4]").Click(); // delete api.ByXpath("//a[2]/font/b").Click(); string alertText4 = api.GetAlartTxt(); //if (alertText4 == "Delete this Accumulation Point(TagName=Acc_0004), are you sure? ") if (alertText4 == "Are you sure you want to delete these 1 tags?") { api.Accept(); } PrintStep(api, "<GroundPC> Delete Acc_0004 tag"); EventLog.AddLog("<GroundPC> Delete ConAna_0004 tag"); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=ConstList')]").Click(); //Const Point api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("(//input[@name='tsel'])[4]").Click(); //ConAna_0004 //api.ByXpath("(//a[contains(text(),'Delete')])[4]").Click(); // delete api.ByXpath("//a[2]/font/b").Click(); string alertText5 = api.GetAlartTxt(); //if (alertText5 == "Delete this Constant Point(TagName=ConAna_0004), are you sure? ") if (alertText5 == "Are you sure you want to delete these 1 tags?") { api.Accept(); } PrintStep(api, "<GroundPC> Delete ConAna_0004 tag"); EventLog.AddLog("<GroundPC> Delete SystemSec_0004 tag"); api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp?pos=SysList')]").Click(); //System Point api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("(//input[@name='tsel'])[4]").Click(); //SystemSec_0004 //api.ByXpath("(//a[contains(text(),'Delete')])[4]").Click(); // delete api.ByXpath("//a[2]/font/b").Click(); string alertText6 = api.GetAlartTxt(); //if (alertText6 == "Delete this System Point(TagName=SystemSec_0004), are you sure? ") if (alertText6 == "Are you sure you want to delete these 1 tags?") { api.Accept(); } PrintStep(api, "<GroundPC> Delete SystemSec_0004 tag"); }
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); } }
private void Create_DailyReport_ExcelReport(string sUserEmail) { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/WaExlViewer/WaExlViewer.asp')]").Click(); for (int t = 1; t <= 4; t++) /////// template 1~4 ; 8min { api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click(); api.ByName("rptName").Clear(); api.ByName("rptName").Enter(string.Format("ER_ODBC_T{0}_DR_8min_LastValue_ER", t)).Exe(); api.ByXpath("(//input[@name='dataSrc'])[2]").Click(); // ODBC api.ByName("selectTemplate").SelectVal(string.Format("template{0}.xlsx", t)).Exe(); switch (slanguage) { case "ENG": api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe(); break; case "CHT": api.ByName("speTimeFmt").SelectTxt("日報表").Exe(); break; case "CHS": api.ByName("speTimeFmt").SelectTxt("日报表").Exe(); break; case "JPN": api.ByName("speTimeFmt").SelectTxt("日報").Exe(); break; case "KRN": api.ByName("speTimeFmt").SelectTxt("일간 보고").Exe(); break; case "FRN": api.ByName("speTimeFmt").SelectTxt("Rapport quotidien").Exe(); break; default: api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe(); break; } // set end date api.ByName("tEnd").Click(); Thread.Sleep(500); api.ByXpath("//button[@type='button']").Click(); api.ByXpath("(//button[@type='button'])[2]").Click(); api.ByName("interval").Clear(); api.ByName("interval").Enter("8").Exe(); // Time Interval = 8 api.ByXpath("(//input[@name='fileType'])[2]").Click(); // Time Unit: Minute api.ByXpath("//input[@name='valueType']").Click(); // Data Type: Last Value // 湊到最大上限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++) { api.ById("tagsLeftList").SelectTxt(ReportTagName[i]).Exe(); } api.ById("torightBtn").Click(); api.ById("tagsRightList").SelectTxt(ReportTagName[0]).Exe(); api.ByXpath("(//input[@name='attachFormat'])[2]").Click(); // Send Email: Excel Report api.ByName("emailto").Clear(); api.ByName("emailto").Enter(sUserEmail).Exe(); //api.ByName("rptName").Enter("").Submit().Exe(); 這邊不能用這種方式submit...很奇怪 反而按submit的button可以正常送出 api.ByName("cfgSubmit").Click(); } for (int t = 1; t <= 4; t++) ////// template 1~4 ; 1hour { api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click(); api.ByName("rptName").Clear(); api.ByName("rptName").Enter(string.Format("ER_ODBC_T{0}_DR_1hour_LastValue_ER", t)).Exe(); api.ByXpath("(//input[@name='dataSrc'])[2]").Click(); // ODBC api.ByName("selectTemplate").SelectVal(string.Format("template{0}.xlsx", t)).Exe(); switch (slanguage) { case "ENG": api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe(); break; case "CHT": api.ByName("speTimeFmt").SelectTxt("日報表").Exe(); break; case "CHS": api.ByName("speTimeFmt").SelectTxt("日报表").Exe(); break; case "JPN": api.ByName("speTimeFmt").SelectTxt("日報").Exe(); break; case "KRN": api.ByName("speTimeFmt").SelectTxt("일간 보고").Exe(); break; case "FRN": api.ByName("speTimeFmt").SelectTxt("Rapport quotidien").Exe(); break; default: api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe(); break; } // set end date api.ByName("tEnd").Click(); Thread.Sleep(500); api.ByXpath("//button[@type='button']").Click(); api.ByXpath("(//button[@type='button'])[2]").Click(); api.ByName("interval").Clear(); api.ByName("interval").Enter("1").Exe(); // Time Interval = 1 api.ByXpath("(//input[@name='fileType'])[3]").Click(); // Time Unit: hour api.ByXpath("//input[@name='valueType']").Click(); // Data Type: Last Value // 湊到最大上限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(); // Send Email: Excel Report api.ByName("emailto").Clear(); api.ByName("emailto").Enter(sUserEmail).Exe(); api.ByName("cfgSubmit").Click(); } for (int d = 1; d <= 3; d++) ////// data type = Maximum or Minimum or Average { api.ByXpath("//a[contains(@href, 'addRptCfg.aspx')]").Click(); api.ByName("rptName").Clear(); if (d == 1) { api.ByName("rptName").Enter("ER_ODBC_T1_DR_1hour_Max_ER").Exe(); } else if (d == 2) { api.ByName("rptName").Enter("ER_ODBC_T1_DR_1hour_Min_ER").Exe(); } else if (d == 3) { api.ByName("rptName").Enter("ER_ODBC_T1_DR_1hour_Avg_ER").Exe(); } api.ByXpath("(//input[@name='dataSrc'])[2]").Click(); // ODBC api.ByName("selectTemplate").SelectVal("template1.xlsx").Exe(); switch (slanguage) { case "ENG": api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe(); break; case "CHT": api.ByName("speTimeFmt").SelectTxt("日報表").Exe(); break; case "CHS": api.ByName("speTimeFmt").SelectTxt("日报表").Exe(); break; case "JPN": api.ByName("speTimeFmt").SelectTxt("日報").Exe(); break; case "KRN": api.ByName("speTimeFmt").SelectTxt("일간 보고").Exe(); break; case "FRN": api.ByName("speTimeFmt").SelectTxt("Rapport quotidien").Exe(); break; default: api.ByName("speTimeFmt").SelectTxt("Daily Report").Exe(); break; } // set end date api.ByName("tEnd").Click(); Thread.Sleep(500); api.ByXpath("//button[@type='button']").Click(); api.ByXpath("(//button[@type='button'])[2]").Click(); api.ByName("interval").Clear(); api.ByName("interval").Enter("1").Exe(); // Time Interval = 1 api.ByXpath("(//input[@name='fileType'])[3]").Click(); // Time Unit: hour api.ByXpath(string.Format("(//input[@name='valueType'])[{0}]", d + 1)).Click(); // Data Type // 湊到最大上限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(); // Send Email: Excel Report api.ByName("emailto").Clear(); api.ByName("emailto").Enter(sUserEmail).Exe(); api.ByName("cfgSubmit").Click(); } }
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); } }
//==============================================================// private void ViewandSaveCloudTagInfo() { PrintTitle("Start WA View"); api.LinkWebUI(txtCloudIp.Text + "/broadWeb/bwconfig.asp?username=admin"); api.ById("userField").Enter("").Submit().Exe(); PrintStep(); // Configure project by project name string sProjectName = "WISE%2DDQA"; // WISE-DQA api.ByXpath("//a[contains(@href, '/broadWeb/bwMain.asp?pos=project') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); PrintStep(); // Start kernel PrintTitle("Start kernel"); StartNode(); System.Threading.Thread.Sleep(5000); // Start view PrintTitle("Start view"); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a/font").Click(); PrintStep(); System.Threading.Thread.Sleep(1000); // Control browser PrintTitle("Control browser"); int iIE_Handl = tpc.F_FindWindow("IEFrame", "Node : " + RenameModname() + "-AUTOTEST - main:untitled"); // 注意是CTestSCADA而不是TestSCADA!! Jammy這邊要改!! 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 : " + RenameModname() + "-AUTOTEST - Internet Explorer"); // 注意是CTestSCADA而不是TestSCADA Jammy這邊要改!! 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"); PrintTitle("Get handle is [" + iWA_MainPage.ToString() + "]."); if (iWA_MainPage > 0) { System.Threading.Thread.Sleep(5000); tpc.F_PostMessage(iWA_MainPage, tpc.V_WM_KEYDOWN, tpc.V_VK_ESCAPE, 0); System.Threading.Thread.Sleep(1000); } // Login keyboard PrintTitle("Login keyboard"); int iLoginKeyboard_Handle = tpc.F_FindWindow("#32770", "Login"); int iEnterText = tpc.F_FindWindowEx(iLoginKeyboard_Handle, 0, "Edit", ""); if (iEnterText > 0) { SendCharToHandle(iEnterText, 100, "admin"); tpc.F_PostMessage(iEnterText, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); } System.Threading.Thread.Sleep(1000); SendKeys.SendWait("^{F5}"); System.Threading.Thread.Sleep(1000); int iPointInfo_Handle = tpc.F_FindWindow("#32770", "Point Info"); int iEnterText_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Edit", ""); if (iEnterText_PointInfo > 0) { if (ai_point > 0) { // AT_AI0 PrintTitle("Print Screen AI Tag."); SendCharToHandle(iEnterText_PointInfo, 100, "AUTOTEST-AI_0"); System.Threading.Thread.Sleep(1500); PrintScreen("PlugandPlay_TagInfoSyncTest_AUTOTEST-AI_0", System.IO.Directory.GetCurrentDirectory()); for (int i = 1; i <= 20; i++) { tpc.F_PostMessage(iEnterText_PointInfo, tpc.V_WM_KEYDOWN, tpc.V_VK_BACK, 0); System.Threading.Thread.Sleep(100); } } if (di_point > 0) { PrintTitle("Print Screen DI Tag."); SendCharToHandle(iEnterText_PointInfo, 100, "AUTOTEST-DI_0"); System.Threading.Thread.Sleep(1500); PrintScreen("PlugandPlay_TagInfoSyncTest_AUTOTEST-DI_0", System.IO.Directory.GetCurrentDirectory()); for (int i = 1; i <= 20; i++) { tpc.F_PostMessage(iEnterText_PointInfo, tpc.V_WM_KEYDOWN, tpc.V_VK_BACK, 0); System.Threading.Thread.Sleep(100); } } if (do_point > 0) { // AT_AI0 PrintTitle("Print Screen DO Tag."); SendCharToHandle(iEnterText_PointInfo, 100, "AUTOTEST-DO_0"); System.Threading.Thread.Sleep(1500); PrintScreen("PlugandPlay_TagInfoSyncTest_AUTOTEST-DO_0", System.IO.Directory.GetCurrentDirectory()); for (int i = 1; i <= 20; i++) { tpc.F_PostMessage(iEnterText_PointInfo, tpc.V_WM_KEYDOWN, tpc.V_VK_BACK, 0); System.Threading.Thread.Sleep(100); } } // AT_DO0100 //PrintTitle("Exe4012E_AISetting"); //SendCharToHandle(iEnterText_PointInfo, 100, "AUTOTEST-DO0"); //System.Threading.Thread.Sleep(1500); //PrintScreen("PlugandPlay_TagInfoSyncTest_AUTOTEST-DO0", System.IO.Directory.GetCurrentDirectory()); //for (int i = 1; i <= 20; i++) //{ // tpc.F_PostMessage(iEnterText_PointInfo, tpc.V_WM_KEYDOWN, tpc.V_VK_BACK, 0); // System.Threading.Thread.Sleep(100); //} } tpc.F_PostMessage(iPointInfo_Handle, tpc.V_WM_KEYDOWN, tpc.V_VK_ESCAPE, 0); }
private void CreateMap(string sTestLogFolder) { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); if (slanguage == "CHS") // f**k china special case.. { api.ByXpath("//a[contains(@href, '/broadWeb/bmap/bmapcreate.asp?')]").Click(); System.Threading.Thread.Sleep(2000); EventLog.AddLog("Click 'New Google Map' test"); api.ByXpath("//a[contains(@href, '/broadWeb/gmap/gmapcreate.asp?')]").ClickAndWait(1000); EventLog.PrintScreen("CreateMapTest_GoogleMap"); PrintStep("Google Map click test"); } else { api.ByXpath("//a[contains(@href, '/broadWeb/gmap/gmapcreate.asp')]").Click(); System.Threading.Thread.Sleep(2000); //TestGoogleMap/BaiduMap EventLog.AddLog("Click 'New Baidu Map' test"); api.ByXpath("//a[contains(@href, '/broadWeb/bmap/bmapcreate.asp?')]").ClickAndWait(1000); EventLog.PrintScreen("CreateMapTest_BiaduMap"); EventLog.AddLog("Click 'New Google Map' test"); api.ByXpath("//a[contains(@href, '/broadWeb/gmap/gmapcreate.asp?')]").ClickAndWait(1000); EventLog.PrintScreen("CreateMapTest_GoogleMap"); PrintStep("Google&Baidu Map click test"); } //Excel-In sample map EventLog.AddLog("Excel in sample map"); api.ByXpath("//a[contains(@href, 'gmaptoJsPg1.asp?pos=import')]").Click(); string sCurrentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location); string sourceSampleFile = sCurrentFilePath + "\\MapSample\\MapSample.xls"; string destWApath = @"C:\Inetpub\wwwroot\broadweb\gmap\MapSample.xls"; System.IO.File.Copy(sourceSampleFile, destWApath, true); api.ByName("dataFileName").Clear(); api.ByName("dataFileName").Enter("MapSample").Submit().Exe(); api.ByName("act").Click(); System.Threading.Thread.Sleep(2000); EventLog.PrintScreen("CreateMapTest_Import_SampleMap"); PrintStep("Excel In Map"); //Options EventLog.AddLog("Options setting..."); EventLog.AddLog("Marker title font set"); api.ByXpath("(//a[contains(@href, '#')])[4]").Click(); System.Threading.Thread.Sleep(1000); api.ByXpath("(//input[@name='aa'])[2]").Click(); System.Threading.Thread.Sleep(500); api.ByXpath("(//input[@name='aa'])[3]").Click(); System.Threading.Thread.Sleep(500); api.ByXpath("(//input[@name='aa'])[1]").Click(); System.Threading.Thread.Sleep(500); api.ByXpath("(//input[@name='bb'])[2]").Click(); System.Threading.Thread.Sleep(500); api.ByXpath("(//input[@name='bb'])[1]").Click(); System.Threading.Thread.Sleep(500); api.ByXpath("//input[@id='cc']").Click(); api.ByXpath("//div[@id='fontpicker']/div").Click(); //Font Family = "Microsoft YaHei" System.Threading.Thread.Sleep(500); api.ByXpath("//select[@id='dd']").Click(); api.ByXpath("//select[@id='dd']").Enter("16").Exe(); //Font Size = 16 System.Threading.Thread.Sleep(500); //api.ById("ee").Clear(); //api.ById("ee").Enter("FF0000").Exe(); //Title Color = RED //System.Threading.Thread.Sleep(1000); PrintStep("Marker Title Font setting"); EventLog.AddLog("Marker label font set"); api.ByXpath("//input[@id='ff']").Click(); api.ByXpath("//div[@id='fontpicker']/div[19]").Click(); //Font Family = "Bookman Old Style" System.Threading.Thread.Sleep(500); api.ByXpath("//select[@id='gg']").Click(); api.ByXpath("//select[@id='gg']").Enter("16").Exe(); //Font Size = 16 System.Threading.Thread.Sleep(500); api.ById("hh").Clear(); api.ById("hh").Enter("0000FF").Exe(); //Title Color = Bule System.Threading.Thread.Sleep(500); api.ById("ee").Clear(); api.ById("ee").Enter("FF00EE").Exe(); //Title Color = Purple System.Threading.Thread.Sleep(500); api.ByXpath("//div[@id='opt']/div[27]/input").Click(); System.Threading.Thread.Sleep(500); PrintStep("Marker Label Font"); //Save EventLog.AddLog("Save map"); api.ByXpath("(//a[contains(@href, '#')])[2]").Click(); System.Threading.Thread.Sleep(1000); SendKeys.SendWait("{ENTER}"); System.Threading.Thread.Sleep(1000); PrintStep("Save"); EventLog.PrintScreen("CreateMapTest_ModifiedMap"); System.Threading.Thread.Sleep(1000); //Excel-Out EventLog.AddLog("Excel out modified map"); api.ByXpath("//a[contains(@href, 'gmaptoJsPg1.asp?pos=export')]").Click(); api.ByName("chk").Click(); api.ByName("dataFileName").Clear(); api.ByName("dataFileName").Enter("gmap_" + DateTime.Now.ToString("yyyyMMdd")).Submit().Exe(); api.ByName("act").Click(); PrintStep("Excel Out Map"); try { string sourceFile = @"C:\Inetpub\wwwroot\broadweb\gmap\gmap_" + DateTime.Now.ToString("yyyyMMdd") + ".xls"; string destFile = sTestLogFolder + "\\CreateMapTest_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".xls"; EventLog.AddLog("Copy export file form " + sourceFile + " to " + destFile); System.IO.File.Copy(sourceFile, destFile, true); System.Threading.Thread.Sleep(1000); } catch (Exception ex) { EventLog.AddLog(ex.ToString()); } //Delete EventLog.AddLog("Delete map"); api.ByXpath("(//a[contains(@href, '#')])[3]").Click(); System.Threading.Thread.Sleep(1000); api.Accept(); System.Threading.Thread.Sleep(1000); PrintStep("Delete"); }
private void StartViewDataLogTrend(string sProjectName, string sTestLogFolder) { // Start view EventLog.AddLog("Start view"); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a/font").Click(); PrintStep("Start View"); Thread.Sleep(5000); // Control browser EventLog.AddLog("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(1500); } else { EventLog.AddLog("Cannot get Start View WebAccess Main Page handle"); } // Login keyboard EventLog.AddLog("admin login"); 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", ""); if (iEnterText > 0) { tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'a', 0); System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'd', 0); //d System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'm', 0); //m System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'i', 0); //i System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'n', 0); //n System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); System.Threading.Thread.Sleep(500); //PostMessage(iWA_MainPage, WM_KEYDOWN, VK_F4, 0); SendKeys.SendWait("{F4}"); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get Login keyboard handle"); } int iDataLogTrend_Handle; switch (slanguage) { case "ENG": iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "Datalog Trend List"); break; case "CHT": iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "資料記錄趨勢列表"); break; case "CHS": iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "历史趋势列表"); break; case "JPN": iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "データログ トレンド一覧"); break; case "KRN": iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "데이터로그 트랜드 리스트"); break; case "FRN": iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "Liste courbes historiques"); break; default: iDataLogTrend_Handle = tpc.F_FindWindow("#32770", "Datalog Trend List"); break; } int iEnterText2 = tpc.F_FindWindowEx(iDataLogTrend_Handle, 0, "Edit", ""); if (iEnterText2 > 0) { tpc.F_PostMessage(iEnterText2, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); } else { EventLog.AddLog("Cannot get DataLog Trend List handle"); } /* * int iOK_Button_of_DataLogTrendList = tpc.F_FindWindowEx(iDataLogTrend_Handle, 0, "Button", "OK"); * if (iOK_Button_of_DataLogTrendList > 0) * { * // Change interval value * EventLog.AddLog("Click Change button of PointInfo window"); * tpc.F_PostMessage(iOK_Button_of_DataLogTrendList, tpc.V_BM_CLICK, 0, 0); * System.Threading.Thread.Sleep(1000); * } * else * EventLog.AddLog("Cannot get iOK_Button_of_DataLogTrendList handle"); * * Thread.Sleep(3000); * PrintScreen("DataLogData", sTestLogFolder); */ for (int iInterval = 1; iInterval <= 3; iInterval++) { string[] sInterval = { "1 sec", "2 sec", "5 sec", "10 sec", "20 sec", "40 sec", "1Min", "2Min", "3Min", "4Min", "8Min", "16Min", "28Min", "1Hour", "2Hour", "4Hour", "6Hour", "8Hour", "12Hour", "1Day", "2Day", "3Day", "4Day", "5Day" }; int iii = sInterval.Length; Thread.Sleep(4000); SendKeys.SendWait("{F4}"); // Right most Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_RightMost_Step1", sInterval[iInterval - 1])); SendKeys.SendWait("{F2}"); // Left Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Left_Step2", sInterval[iInterval - 1])); SendKeys.SendWait("{F2}"); // Left Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Right_Step3", sInterval[iInterval - 1])); SendKeys.SendWait("{F3}"); // Right Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Right_Step4", sInterval[iInterval - 1])); SendKeys.SendWait("{F3}"); // Right Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Right_Step5", sInterval[iInterval - 1])); SendKeys.SendWait("{F1}"); // Left most Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_LeftMost_Step6", sInterval[iInterval - 1])); SendKeys.SendWait("{F4}"); // Right most Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_RightMost_Step7", sInterval[iInterval - 1])); Thread.Sleep(1000); SendKeys.SendWait("^{F5}"); // quick key of PointInfo window Thread.Sleep(1000); EventLog.AddLog("Open Point Info window"); int iPointInfo_Handle; switch (slanguage) { case "ENG": iPointInfo_Handle = tpc.F_FindWindow("#32770", "Point Info"); break; case "CHT": iPointInfo_Handle = tpc.F_FindWindow("#32770", "點資訊"); break; case "CHS": iPointInfo_Handle = tpc.F_FindWindow("#32770", "点信息"); break; case "JPN": iPointInfo_Handle = tpc.F_FindWindow("#32770", "ポイント情報"); break; case "KRN": iPointInfo_Handle = tpc.F_FindWindow("#32770", "포인트 정보"); break; case "FRN": iPointInfo_Handle = tpc.F_FindWindow("#32770", "Info point"); break; default: iPointInfo_Handle = tpc.F_FindWindow("#32770", "Point Info"); break; } // 用來改變interval //int iPointInfo_Handle = tpc.F_FindWindow("#32770", "Point Info"); int iEnterText_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Edit", ""); if (iEnterText_PointInfo > 0) { EventLog.AddLog("Change Datalog Trend Interval"); SendCharToHandle(iEnterText_PointInfo, 100, "%ADTRDST"); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get EnterText_PointInfo handle"); } int iChange_Button_of_PointInfo = 0; switch (slanguage) { case "ENG": iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Change"); break; case "CHT": iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "改變"); break; case "CHS": iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "改变"); break; case "JPN": iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "変更"); break; case "KRN": iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "변경"); break; case "FRN": iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Modifier"); break; default: iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Change"); break; } if (iChange_Button_of_PointInfo > 0) { // Change interval value EventLog.AddLog("Click Change button of PointInfo window"); tpc.F_PostMessage(iChange_Button_of_PointInfo, tpc.V_BM_CLICK, 0, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get iChange_Button_of_PointInfo handle"); } int iEditWindow_of_interval = tpc.F_FindWindow("#32770", "%ADTRDST"); int iEnterValue_of_interval = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "BW_DSPINUP"); // 換設定interval視窗裡的向右鍵 if (iEnterValue_of_interval > 0) { // Change interval value EventLog.AddLog("Click add one interval button Change window"); tpc.F_PostMessage(iEnterValue_of_interval, tpc.V_BM_CLICK, 0, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get iEnterValue_of_interval handle"); } int iEnterButton_ChangeWindow = 0; switch (slanguage) { case "ENG": iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "Enter"); // 按設定interval視窗裡的enter break; case "CHT": iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "輸入"); break; case "CHS": iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "回车"); break; case "JPN": iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "エンター"); break; case "KRN": iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "Enter"); break; case "FRN": iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "Valider"); break; default: iEnterButton_ChangeWindow = tpc.F_FindWindowEx(iEditWindow_of_interval, 0, "Button", "Enter"); // 按設定interval視窗裡的enter break; } if (iEnterButton_ChangeWindow > 0) { // Change interval value EventLog.AddLog("Click Enter button Change window"); tpc.F_PostMessage(iEnterButton_ChangeWindow, tpc.V_BM_CLICK, 0, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get iEnterButton_ChangeWindow handle"); } int iExitButton_PointInfo = 0; switch (slanguage) { case "ENG": iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Exit"); // 按PointInfo視窗裡的Exit break; case "CHT": iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "退出"); break; case "CHS": iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "退出"); break; case "JPN": iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "終了"); break; case "KRN": iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "종료"); break; case "FRN": iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Quitter"); break; default: iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Exit"); // 按PointInfo視窗裡的Exit break; } if (iExitButton_PointInfo > 0) { // Change interval value EventLog.AddLog("Click Exit button of PointInfo window"); tpc.F_PostMessage(iExitButton_PointInfo, tpc.V_BM_CLICK, 0, 0); System.Threading.Thread.Sleep(1000); } else { EventLog.AddLog("Cannot get iExitButton_PointInfo handle"); } if (iInterval == sInterval.Length) { Thread.Sleep(4000); SendKeys.SendWait("{F4}"); // Right most Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_RightMost_Step1", sInterval[iInterval - 1])); SendKeys.SendWait("{F2}"); // Left Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Left_Step2", sInterval[iInterval - 1])); SendKeys.SendWait("{F2}"); // Left Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Right_Step3", sInterval[iInterval - 1])); SendKeys.SendWait("{F3}"); // Right Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Right_Step4", sInterval[iInterval - 1])); SendKeys.SendWait("{F3}"); // Right Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_Right_Step5", sInterval[iInterval - 1])); SendKeys.SendWait("{F1}"); // Left most Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_LeftMost_Step6", sInterval[iInterval - 1])); SendKeys.SendWait("{F4}"); // Right most Thread.Sleep(4000); EventLog.PrintScreen(string.Format("DataLogTrend_Interval_{0}_RightMost_Step7", sInterval[iInterval - 1])); } /* * ////////這邊開始左左右右//////// * DateTime dt = DateTime.Now.AddSeconds(-270); // 開始時間設定為4分半前 * for (int LLRR = 1; LLRR <= 4; LLRR++) * { * Thread.Sleep(1000); * SendKeys.SendWait("^{F5}"); // quick key of PointInfo window * Thread.Sleep(1000); * * EventLog.AddLog("Open Point Info window"); * //int iPointInfo_Handle; * switch (slanguage) * { * case "ENG": * iPointInfo_Handle = tpc.F_FindWindow("#32770", "Point Info"); * break; * case "CHT": * iPointInfo_Handle = tpc.F_FindWindow("#32770", "點資訊"); * break; * case "CHS": * iPointInfo_Handle = tpc.F_FindWindow("#32770", "点信息"); * break; * case "JPN": * iPointInfo_Handle = tpc.F_FindWindow("#32770", "ポイント情報"); * break; * case "KRN": * iPointInfo_Handle = tpc.F_FindWindow("#32770", "포인트 정보"); * break; * case "FRN": * iPointInfo_Handle = tpc.F_FindWindow("#32770", "Info point"); * break; * * default: * iPointInfo_Handle = tpc.F_FindWindow("#32770", "Point Info"); * break; * } * * //用來改變時間 * iEnterText_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Edit", ""); * if (iEnterText_PointInfo > 0) * { * EventLog.AddLog("Change Datalog Trend Interval"); * SendCharToHandle(iEnterText_PointInfo, 100, "%TDTRDSTM"); * System.Threading.Thread.Sleep(1000); * } * else * EventLog.AddLog("Cannot get EnterText_PointInfo handle"); * // 注意! 尚未加上多國語言版本 * iChange_Button_of_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Change"); // 按 PointInfo視窗裡的change 按扭 * if (iChange_Button_of_PointInfo > 0) * { * // Change interval value * EventLog.AddLog("Click Change button of PointInfo window"); * tpc.F_PostMessage(iChange_Button_of_PointInfo, tpc.V_BM_CLICK, 0, 0); * System.Threading.Thread.Sleep(1000); * } * else * EventLog.AddLog("Cannot get iChange_Button_of_PointInfo handle"); * * int iTDTRDSTM_window = tpc.F_FindWindow("#32770", "%TDTRDSTM"); * int iEditField_of_TDTRDSTM = tpc.F_FindWindowEx(iTDTRDSTM_window, 0, "Edit", ""); * int iBackspace_of_TDTRDSTM = tpc.F_FindWindowEx(iTDTRDSTM_window, 0, "Button", ""); * for (int i = 0; i < 37; i++) // 換設定interval視窗裡的Backspace * { * iBackspace_of_TDTRDSTM = tpc.F_FindWindowEx(iTDTRDSTM_window, iBackspace_of_TDTRDSTM, "Button", ""); * } * if (iBackspace_of_TDTRDSTM > 0) * { * // * EventLog.AddLog("Click Backspace button Change window"); * tpc.F_PostMessage(iBackspace_of_TDTRDSTM, tpc.V_BM_CLICK, 0, 0); * System.Threading.Thread.Sleep(1000); * } * else * EventLog.AddLog("Cannot get iBackspace_of_TDTRDSTM handle"); * * if (iEditField_of_TDTRDSTM > 0) * { * string sTime; * if(LLRR <= 2) //前兩次往左推2單位時間 * sTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", dt.AddSeconds(-(90*LLRR))); * else //後兩次往右推2單位時間 * sTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", dt.AddSeconds(90*(LLRR-2))); * * EventLog.AddLog("Enter the date time in Edit field"); * SendCharToHandle(iEditField_of_TDTRDSTM, 100, sTime); * System.Threading.Thread.Sleep(1000); * tpc.F_PostMessage(iEditField_of_TDTRDSTM, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); * } * else * EventLog.AddLog("Cannot get iEditField_of_TDTRDSTM handle"); * * Thread.Sleep(1000); * iExitButton_PointInfo = tpc.F_FindWindowEx(iPointInfo_Handle, 0, "Button", "Exit"); // 按PointInfo視窗裡的Exit * // 注意! 尚未加上多國語言版本 * if (iExitButton_PointInfo > 0) * { * // Change interval value * EventLog.AddLog("Click Exit button of PointInfo window"); * tpc.F_PostMessage(iExitButton_PointInfo, tpc.V_BM_CLICK, 0, 0); * System.Threading.Thread.Sleep(1000); * } * else * EventLog.AddLog("Cannot get iExitButton_PointInfo handle"); * } */ } // Export Data (ctrl+F4) , 會在C:\WebAccess\Client\TestProject_TestSCADA 產生 $view001.htm 檔 EventLog.AddLog("Send ctrl+F4 keyboard command to export data"); if (iWA_MainPage > 0) { /* * SendMessage(iWA_MainPage, WM_KEYDOWN, VK_CONTROL, 0); * SendMessage(iWA_MainPage, WM_KEYDOWN, VK_F4, 0); * Thread.Sleep(1000); * SendMessage(iWA_MainPage, WM_KEYUP, VK_F4, 0); * SendMessage(iWA_MainPage, WM_KEYUP, VK_CONTROL, 0); */ /* * keybd_event(VK_CONTROL, 0, 0, 0); * PostMessage(iWA_MainPage, WM_KEYDOWN, VK_F4, 0); * PostMessage(iWA_MainPage, WM_KEYUP, VK_F4, 0); * keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); */ Thread.Sleep(1000); SendKeys.SendWait("^{F4}"); // [Aaron] I have no idea how to implement ctrl+F4...so this poor method used. // this method will press ctrl + F4 key with no handle input Thread.Sleep(1500); } else { EventLog.AddLog("Cannot get Start View WebAccess Main Page handle"); } // copy $view001.htm to log path. EventLog.AddLog("copy $view001.htm to log path."); { string fileNameSrc = "$view001.htm"; string fileNameTar = string.Format("DataLogGroup_{0:yyyyMMdd_hhmmss}.htm", DateTime.Now); string sourcePath = string.Format(@"C:\WebAccess\Client\{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); if (System.IO.File.Exists(sourceFile)) { System.IO.File.Copy(sourceFile, destFile, true); } else { EventLog.AddLog("Cannot get $view001.htm file"); } } if (iWA_MainPage > 0) { Thread.Sleep(5000); //delay 5s before close $view001 window EventLog.AddLog("Send alt+F4 keyboard command to close $view001.htm window"); SendKeys.SendWait("%{F4}"); Thread.Sleep(500); } else { EventLog.AddLog("Cannot find $view001.htm window"); } //PrintScreen("DataLogData", sTestLogFolder); }
private void Create_Report() { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/syslog/RptList.asp')]").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/syslog/rptPg.asp') and contains (@href, 'action=new')]").Click(); api.ByName("ReportName").Clear(); api.ByName("ReportName").Enter("ReportTest").Exe(); api.ByName("Title1").Clear(); api.ByName("Title1").Enter("OverAll Title").Exe(); api.ByName("Title2").Clear(); api.ByName("Title2").Enter("Page Title").Exe(); api.ByName("Title3").Clear(); api.ByName("Title3").Enter("SubTitle").Exe(); api.ByName("ReportText1").Clear(); api.ByName("ReportText1").Enter("ReportTest").Exe(); // 最大上限12個tag string[] ReportTagName = { "Calc_ConAna", "Calc_ConDis", "Calc_ModBusAI", "Calc_ModBusAO", "Calc_ModBusDI", "Calc_ModBusDO", "Calc_OPCDA", "Calc_OPCUA", "Calc_System", "AT_AI0100", "AT_DI0100", "ConAna_0100" }; for (int i = 1; i <= 12; i++) { api.ByName("TagName" + i.ToString("000")).Clear(); api.ByName("TagName" + i.ToString("000")).Enter(ReportTagName[i - 1]).Exe(); } //Shift Report// api.ByName("ShiftReport").Click(); api.ByName("ShiftEmailTo").Clear(); api.ByName("ShiftEmailTo").Enter("*****@*****.**").Exe(); api.ByName("ExcelRpt1").Click(); //api.ByName("ShiftEditTag").Click(); api.ByXpath("//input[@name='ShiftEditTag']").Click(); for (int m = 1; m <= 4; m++) { api.ByName("Title" + m.ToString("0") + "_1").Clear(); api.ByName("Title" + m.ToString("0") + "_1").Enter("shift_tag1_title" + m).Exe(); } api.ByName("DispFactor").Clear(); api.ByName("DispFactor").Enter("10").Submit().Exe(); //Daily Report// api.ByName("DailyReport").Click(); api.ByName("DailyEmailTo").Clear(); api.ByName("DailyEmailTo").Enter("*****@*****.**").Exe(); api.ByName("ExcelRpt2").Click(); //api.ByName("DailyEditTag").Click(); api.ByXpath("//input[@name='DailyEditTag']").Click(); for (int m = 1; m <= 4; m++) { api.ByName("Title" + m.ToString("0") + "_1").Clear(); api.ByName("Title" + m.ToString("0") + "_1").Enter("daily_tag1_title" + m).Exe(); } api.ByName("DispFactor").Clear(); api.ByName("DispFactor").Enter("10").Submit().Exe(); //Monthly Report// api.ByName("MonthReport").Click(); api.ByName("MonthEmailTo").Clear(); api.ByName("MonthEmailTo").Enter("*****@*****.**").Exe(); api.ByName("ExcelRpt3").Click(); //api.ByName("MonthEditTag").Click(); api.ByXpath("//input[@name='MonthEditTag']").Click(); for (int m = 1; m <= 4; m++) { api.ByName("Title" + m.ToString("0") + "_1").Clear(); api.ByName("Title" + m.ToString("0") + "_1").Enter("month_tag1_title" + m).Exe(); } api.ByName("DispFactor").Clear(); api.ByName("DispFactor").Enter("10").Submit().Exe(); api.ByName("ReportName").Enter("").Submit().Exe(); }
private void ViewAlarmData(string sTestLogFolder) { // Start view EventLog.AddLog("Start view"); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a/font").Click(); PrintStep("Start View"); // Control browser EventLog.AddLog("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 EventLog.AddLog("admin login"); 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", ""); if (iEnterText > 0) { tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'a', 0); System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'd', 0); //d System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'm', 0); //m System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'i', 0); //i System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_CHAR, 'n', 0); //n System.Threading.Thread.Sleep(100); tpc.F_PostMessage(iEnterText, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); System.Threading.Thread.Sleep(500); } else { EventLog.AddLog("Cannot get Login keyboard handle"); } EventLog.AddLog("Send F5 to show alarm summary"); tpc.F_PostMessage(iWA_MainPage, tpc.V_WM_KEYDOWN, tpc.V_VK_F5, 0); System.Threading.Thread.Sleep(2000); EventLog.PrintScreen("AlarmSummary"); EventLog.AddLog("Send F6 to show alarm group data"); tpc.F_PostMessage(iWA_MainPage, tpc.V_WM_KEYDOWN, tpc.V_VK_F6, 0); System.Threading.Thread.Sleep(2000); int iAlarmGroup_Handle; switch (slanguage) { case "ENG": iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "Alarm Group List"); break; case "CHT": iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "警報群組目錄"); break; case "CHS": iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "报警群组目录"); break; case "JPN": iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "アラーム グループ一覧"); break; case "KRN": iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "알람 그룹리스트 "); break; case "FRN": iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "Liste des groupes d'alarme"); break; default: iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "Alarm Group List"); break; } //int iAlarmGroup_Handle = tpc.F_FindWindow("#32770", "Alarm Group List"); int iEnterText2 = tpc.F_FindWindowEx(iAlarmGroup_Handle, 0, "Edit", ""); if (iEnterText2 > 0) { tpc.F_PostMessage(iEnterText2, tpc.V_WM_KEYDOWN, tpc.V_VK_RETURN, 0); } else { EventLog.AddLog("Cannot get Alarm Group List handle"); } Thread.Sleep(3000); EventLog.PrintScreen("AlarmGroupData"); }
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); }
private void ReturnSCADAPage() { api.SwitchToCurWindow(0); api.SwitchToFrame("leftFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/bwMainRight.asp') and contains(@href, 'name=TestSCADA')]").Click(); }