private void StartNode() { PrintTitle("StartNode"); api.SwitchToCurWindow(0); api.SwitchToFrame("rightFrame", 0); api.ByXpath("//tr[2]/td/a[5]/font").Click(); // start kernel 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]); } api.ByName("submit").Enter("").Submit().Exe(); PrintStep(); System.Threading.Thread.Sleep(5000); // Wait 30s for start kernel finish api.Close(); api.SwitchToWinHandle(main); // switch back to original window PrintStep(); }
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 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 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 bool bNodeREDDashboardNodeTest(string sProjectName, string sTestLogFolder) { bool bTestResult = true; string[] sDashboardNodeName = { "RTBar_BuildinWidget_InternalDataSource", "RTBar_BuildinWidget_ExternalDataSource", "GroupAid" }; // Custom widget node 必須與widget builder測試完成後 搭配測試 待完成後再補上 for (int i = 1; i <= sDashboardNodeName.Length; i++) { //Step1: add workspace api.ByXpath("//a[contains(@href, '#debug')]").Click(); //切到debug視窗 api.ByXpath("//a[@id='btn-workspace-add-tab']/i").Click(); //新增Sheet2 (主要操作區) //Step2: import test case string sCurrentFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location); string sourceFile = sCurrentFilePath + string.Format("\\NodeREDSample\\{0}.txt", sDashboardNodeName[i - 1]); StreamReader sr = new StreamReader(sourceFile, Encoding.Default); string line; string sNodeRED_Sample = ""; while ((line = sr.ReadLine()) != null) { sNodeRED_Sample += line.ToString(); //Console.WriteLine(line.ToString()); } //Replace project name here sNodeRED_Sample = sNodeRED_Sample.Replace("TestProjectName", sProjectName); /* this method doesn't work...WTF * api.ByXpath("//a[@id='btn-sidemenu']/i").Click(); // click side menu * api.ByXpath("//a[@id='menu-item-import']").MoveToEle(); // moveToElement * Thread.Sleep(2000); * api.ById("menu-item-import-clipboard").Click(); // click Import * Thread.Sleep(2000); * */ SendKeys.SendWait("^{i}"); // import tag Thread.Sleep(2000); if (sNodeRED_Sample.Length > 700) // 如果要寫入的字串太長 會出錯 故用關鍵字wires拆開字串並分別寫入 { string[] sNodeRED_SampleTemp = sNodeRED_Sample.Split(new string[] { "wires" }, StringSplitOptions.RemoveEmptyEntries); for (int gg = 0; gg < sNodeRED_SampleTemp.Length; gg++) { if (gg == 0) { api.ById("clipboard-import").Enter(sNodeRED_SampleTemp[gg]).Exe(); } else { api.ById("clipboard-import").Enter("wires" + sNodeRED_SampleTemp[gg]).Exe(); } } } else { api.ById("clipboard-import").Enter(sNodeRED_Sample).Exe(); } api.ById("clipboard-dialog-ok").Click(); // click ok api.ByXpath("//a[@id='btn-workspace-add-tab']/i").Click(); //新增Sheet3 Thread.Sleep(500); api.ByXpath("//div[2]/ul/li[3]/a").DoubleClick(); //點擊Sheet3 -> 為了使貼上去的資料固定住 api.ByXpath("//button[@type='button']").Click(); //刪除Sheet3 api.ByXpath("//div[2]/ul/li[2]/a").Click(); //點擊Sheet2 Thread.Sleep(2000); api.ByXpath("//div[2]/ul/li[2]/a").DoubleClick(); Thread.Sleep(2000); api.ById("node-input-workspace-name").Clear(); Thread.Sleep(2000); api.ById("node-input-workspace-name").Enter(sDashboardNodeName[i - 1]).Exe(); Thread.Sleep(2000); api.ByXpath("(//button[@type='button'])[2]").Click(); Thread.Sleep(2000); //Step3: Deploy setting api.ByXpath("//a[@id='btn-deploy']/span").Click(); // deploy Thread.Sleep(3000); //Step4-1: Trigger api.ByCss("g.node_button.node_left_button > rect.node_button_button").Click(); Thread.Sleep(2000); //Step4-2: Create dashboard node api.ByCss("g.node_button.node_right_button > rect.node_button_button").Click(); Thread.Sleep(20000); EventLog.AddLog("Find pop up dashboard 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]); } Thread.Sleep(1000); EventLog.AddLog(sDashboardNodeName[i - 1] + " Dashboard test..."); string sProducedDashboardName = api.ByCss("div > div > div.title").GetText(); // 抓取產生的dashboard的標題值是否如預期 if (sDashboardNodeName[i - 1] != sProducedDashboardName) { bTestResult = false; EventLog.AddLog("Output type ERROR!!"); EventLog.AddLog("Produced dashboard name is: " + sProducedDashboardName); EventLog.AddLog("Correct name should be: " + sDashboardNodeName[i - 1]); } PrintScreen(sDashboardNodeName[i - 1] + "_Test", sTestLogFolder); api.Close(); api.SwitchToWinHandle(main); /* * //Step5: catch debug message and judgment * string sDebugMessageDate = api.ByCss("#debug-content > div:nth-child(1) > span.debug-message-date").GetText(); * string sDebugMessageName = api.ByCss("#debug-content > div > span.debug-message-name").GetText(); * string sDebugMessageTopic = api.ByCss("#debug-content > div > span.debug-message-topic").GetText(); * string sDebugMessagePayload = api.ByCss("#debug-content > div > span.debug-message-payload").GetText(); * * EventLog.AddLog(sDashboardNodeName[i - 1] + " Dashboard test"); * EventLog.AddLog("-------------Debug Message--------------"); * EventLog.AddLog(sDebugMessageDate + " " + sDebugMessageName); * EventLog.AddLog(sDebugMessageTopic); * EventLog.AddLog(sDebugMessagePayload); * EventLog.AddLog("----------------------------------------"); * string[] sType = sDebugMessageTopic.Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries); // 切割文字抓取回傳type * * if (sType[1] != sOutputType[i - 1]) * { * bTestResult = false; * EventLog.AddLog("Output type ERROR!!"); * EventLog.AddLog("Correct type is: " + sOutputType[i - 1]); * } * * if (sDebugMessagePayload != sOutputValue[i - 1]) * { * bTestResult = false; * EventLog.AddLog("Output value ERROR!!"); * EventLog.AddLog("Correct value is: " + sOutputValue[i - 1]); * } * * //Step6: clear debug message * api.ByXpath("//a[@id='debug-tab-clear']/i").Click(); // clear debug message */ //Step7: delete test sheet api.ByXpath("//div[2]/ul/li[2]/a").DoubleClick(); //點擊Sheet2 Thread.Sleep(1000); api.ByXpath("//button[@type='button']").Click(); //刪除Sheet2 Thread.Sleep(1000); api.ByXpath("(//button[@type='button'])[4]").Click(); //確認刪除Sheet2 Thread.Sleep(1000); api.ByXpath("//a[@id='btn-deploy']/span").Click(); // deploy PrintStep(sDashboardNodeName[i - 1] + " Test"); if (sNodeRED_Sample.Length > 700) { Thread.Sleep(5000); } } return(bTestResult); }