private void DeleteCloudProject() // Delete Cloud Project { PrintTitle("DeleteCloudProject"); 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/project/deleteProject.asp?') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); // Confirm to delete porject sProjectName = "WISE-DQA"; // WISE-DQA string alertText = api.GetAlartTxt(); if (alertText == "Delete this project (" + sProjectName + "), are you sure?") { api.Accept(); } }
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 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 void GroundPC_DeleteProject(string sBrowser, string sProjectName, string sWebAccessIP, string sTestLogFolder) { if (sBrowser == "Internet Explorer") { EventLog.AddLog("<GroundPC> Browser= Internet Explorer"); api = new AdvSeleniumAPI("IE", ""); System.Threading.Thread.Sleep(1000); } else if (sBrowser == "Mozilla FireFox") { EventLog.AddLog("<GroundPC> Browser= Mozilla FireFox"); api = new AdvSeleniumAPI("FireFox", ""); System.Threading.Thread.Sleep(1000); } api.LinkWebUI(baseUrl + "/broadWeb/bwconfig.asp?username=admin"); api.ById("userField").Enter("").Submit().Exe(); PrintStep(api, "<GroundPC> Login WebAccess"); EventLog.AddLog("<GroundPC> Delete " + sProjectName + " project."); api.ByXpath("//a[contains(@href, '/broadWeb/project/deleteProject.asp?') and contains(@href, 'ProjName=" + sProjectName + "')]").Click(); // Confirm to delete project string alertText = api.GetAlartTxt(); //if (alertText == "Delete this project (" + sProjectName + "), are you sure?") // api.Accept(); switch (slanguage) { case "ENG": if (alertText == "Delete this project (" + sProjectName + "), are you sure?") { api.Accept(); } break; case "CHT": if (alertText == "您確定要刪除這個工程(" + sProjectName + ")?") { api.Accept(); } break; case "CHS": if (alertText == "您肯定要删除工程(" + sProjectName + ")吗?") { api.Accept(); } break; case "JPN": if (alertText == "このプロジェクト (" + sProjectName + ") を削除してもよろしいですか?") { api.Accept(); } break; case "KRN": if (alertText == "이 프로젝트(" + sProjectName + ")를 삭제합니다. 계속하시겠습니까?") { api.Accept(); } break; case "FRN": if (alertText == "Supprimer ce projet (" + sProjectName + "), êtes-vous sûr ?") { api.Accept(); } break; default: if (alertText == "Delete this project (" + sProjectName + "), are you sure?") { api.Accept(); } break; } PrintStep(api, "<GroundPC> Delete " + sProjectName + "Node"); Thread.Sleep(10000); api.Quit(); PrintStep(api, "<CloudPC> Quit browser"); }
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 CreateEventLogData(string sProjectName) { api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//a[contains(@href, '/broadWeb/eventlog/EveLogList.asp')]").Click(); api.ByXpath("//a[contains(@href, '/broadWeb/eventLog/eveLogPg.asp') and contains(@href, 'pos=add')]").Click(); switch (slanguage) { case "ENG": api.ByName("EventTypeSel").SelectTxt("Event Tag == Reference Value").Exe(); break; case "CHT": api.ByName("EventTypeSel").SelectTxt("事件測點 == 參考值").Exe(); break; case "CHS": api.ByName("EventTypeSel").SelectTxt("事件点 == 参考值").Exe(); break; case "JPN": api.ByName("EventTypeSel").SelectTxt("イベントタグ == 参照値").Exe(); break; case "KRN": api.ByName("EventTypeSel").SelectTxt("이벤트 태그 == Reference Value").Exe(); break; case "FRN": api.ByName("EventTypeSel").SelectTxt("Repère d'Evénement == Valeur de Référence").Exe(); break; default: api.ByName("EventTypeSel").SelectTxt("Event Tag == Reference Value").Exe(); break; } api.ByName("EventLogName").Clear(); api.ByName("EventLogName").Enter("EventLog_" + sProjectName).Exe(); api.ByName("EventTag").Clear(); api.ByName("EventTag").Enter("ConAna_0241").Exe(); api.ByName("EventRefVal").Clear(); api.ByName("EventRefVal").Enter("51").Exe(); PrintStep("Set Event Log trigger event"); api.ByName("EventLogTag").Click(); api.ByName("ChSel").SelectVal("240").Exe(); Thread.Sleep(2000); api.Accept(); Thread.Sleep(1000); for (int i = 1; i <= 9; i++) { try { api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_000{0}", i)).Exe(); } catch (Exception ex) { EventLog.AddLog("CreateEventLogData 1~9 error: " + ex.ToString()); i--; } } PrintStep("Create 1~9 tags to log"); EventLog.AddLog("Create 1~9 tags to log"); for (int i = 10; i <= 99; i++) { try { api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_00{0}", i)).Exe(); } catch (Exception ex) { EventLog.AddLog("CreateEventLogData 10~99 error: " + ex.ToString()); i--; } } PrintStep("Create 10~99 tags to log"); EventLog.AddLog("Create 10~99 tags to log"); for (int i = 100; i <= 240; i++) { try { if (i == 240) { api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_0{0}", i)).Submit().Exe(); } else { api.ByName(string.Format("TagName{0}", i)).Enter(string.Format("ConAna_0{0}", i)).Exe(); } } catch (Exception ex) { EventLog.AddLog("CreateEventLogData 100~240 error: " + ex.ToString()); i--; } } PrintStep("Create 100~240 tags to log"); EventLog.AddLog("Create 100~240 tags to log"); Thread.Sleep(1000); api.ByName("EventRefVal").Enter("").Submit().Exe(); Thread.Sleep(1000); }
private void CreateProject(string sProjectName, string sWebAccessIP) { EventLog.AddLog("Create a new project"); // Create a new project //driver.FindElement(By.Name("ProjName")).Clear(); //driver.FindElement(By.Name("ProjName")).SendKeys(projName); //driver.FindElement(By.Name("ProjIPLong")).Clear(); //driver.FindElement(By.Name("ProjIPLong")).SendKeys(sWebAccessIP); //driver.FindElement(By.Name("ProjIPLong")).Submit(); api.ByName("ProjName").Clear(); int i = api.ByName("ProjName").Enter(sProjectName).Exe(); //PrintStep("123123"); api.ByName("ProjIPLong").Clear(); api.ByName("ProjIPLong").Enter(sWebAccessIP).Submit().Exe(); //api.ByName("ProjIPLong").Submit().Exe(); // Confirm to create //string alertText = driver.SwitchTo().Alert().Text; string alertText = api.GetAlartTxt(); switch (slanguage) { case "ENG": if (alertText == "Do you want to create a new project ( Project Name : " + sProjectName + " )? ") { api.Accept(); } break; case "CHT": if (alertText == "您要建立新的工程 ( 工程名稱 : " + sProjectName + " )? ") { api.Accept(); } break; case "CHS": if (alertText == "你想建立新的工程 ( 工程名称 : " + sProjectName + " )? ") { api.Accept(); } break; case "JPN": if (alertText == "新しいプロジェクトを作成しますか ( プロジェクト名 : " + sProjectName + " )? ") { api.Accept(); } break; case "KRN": if (alertText == "새 프로젝트를 생성할까요? ( 프로젝트명 : " + sProjectName + " )? ") { api.Accept(); } break; case "FRN": if (alertText == "Voulez-vous créer un nouveau projet ( Nom projet : " + sProjectName + " )? ") { api.Accept(); } break; default: if (alertText == "Do you want to create a new project ( Project Name : " + sProjectName + " )? ") { api.Accept(); } break; } }