public static void Test() { //////////////////////////////////////////////////////////////comment StartWinium(); /* * DesiredCapabilities dc = new DesiredCapabilities(); * dc.SetCapability("app", SessionManager); * dc.SetCapability("args", @" HX01 /USERNAME=admin /PASSWORD=root123"); * dc.SetCapability("launchDelay", "3000"); * * Console.WriteLine("Start DBP"); * * driver = new RemoteWebDriver(new Uri("http://*****:*****@"C:\\temp\\VTServer.cmd"; /////////////////////////////////////////////////////////////// string command, parameters, line = " "; IWebElement Window, SysListView32 = null; Match match, cell, MatchSysTreeView32; string row = ""; try { Console.WriteLine("Read CMDFile file"); using (StreamReader sr = new StreamReader(CMDFile)) { while (true) { if (File.Exists(CMDFile)) { try { line = sr.ReadLine(); } catch { Thread.Sleep(100); break; } Console.WriteLine(line); if (line != null) { match = ParseString(line); command = match.Groups["command"].Value.ToString(); parameters = match.Groups["wparam"].Value.ToString(); if (command == "") { command = ParseWrite(line).Groups["command"].Value.ToString(); } } else { break; } switch (command) { case "BEGINDATABASE": Console.WriteLine("!!!BEGINDATABASE"); initDictionary = true; break; case "ENDDATABASE": initDictionary = false; using (File.Create(STSFile)) { } Console.WriteLine("VO: Load database"); //[DATABASE] sr.Close(); //uncomment Thread.Sleep(100); File.Delete(CMDFile); //uncomment break; //return; case "ADDSTRING": Console.WriteLine("!!!ADDSTRING"); if (initDictionary) { if (!Dic.ContainsKey(match.Groups["wparam"].Value.ToString())) { Dic.Add(match.Groups["wparam"].Value.ToString(), match.Groups["lparam"].Value.ToString().Trim('"').Replace("\\x0a", "\r\n").Replace("\\x95", "•").Replace("\\x92", "’")); } } break; case "SYNC": Console.WriteLine("!!!SYNC"); WriteToSTS("SERVER: SYNC"); sr.Close(); Thread.Sleep(100); File.Delete(CMDFile); return; case "RESET": Console.WriteLine("!!!RESET"); WriteToSTS("INFO: Resetting session " + parameters); WriteToSTS("SERVER: EOF"); sr.Close(); File.Delete(CMDFile); break; case "WRITE": driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3)); Console.WriteLine("!!!WRITE"); ParseWriteCommand(line); Window = driver.FindElement(By.XPath("/*[contains(@ControlType,'ControlType.Window') and (contains(@Name,'" + parameters + " - " + Program.GETSTRING("IDS_DLG_MITEL_DB_PROGRAMMING") + "'))]")); //hx01 change to parameters string previuskey = "", previusvalue = ""; foreach (var y in WriteCommandDictionary) { if (previusvalue != y.Value.ToString() && previusvalue != "") { previusvalue = y.Value.ToString(); break; } else { previusvalue = y.Value.ToString(); previuskey = y.Key.ToString(); } } string path = ""; foreach (KeyValuePair <string, string> item in WriteCommandDictionary) //add verify path on top window { Console.WriteLine(item.Key); switch (item.Value) { case "SubView": Console.WriteLine("SubView"); //CommonProc.WindowsHandle(parameters); IWebElement SysTreeView32 = Window.FindElement(By.ClassName("SysTreeView32")); Console.WriteLine("Current: " + item.Key.ToString()); path = path + "\\" + GETSTRING(item.Key); //IList<IWebElement> ToolbarButtons = GETListOfPath(); if (!GETListOfPath(Window, GETSTRING(item.Key))) { if (item.Key.ToString() == previuskey) { SysTreeView32.FindElement(By.Name(GETSTRING(item.Key))).Click(); WriteToSTS(path); } else { new Actions(driver).DoubleClick(SysTreeView32.FindElement(By.Name(GETSTRING(item.Key)))).Perform(); if (GETListOfDialogs().Count > 0) { CommonProc.WindowsHandle(parameters); new Actions(driver).DoubleClick(SysTreeView32.FindElement(By.Name(GETSTRING(item.Key)))).Perform(); } } } break; case "Row": Window.Click(); SysListView32 = Window.FindElement(By.ClassName("SysListView32")); Console.WriteLine("Row"); IList <IWebElement> rows = SysListView32.FindElements(By.Name(GETSTRING(item.Key))); Thread.Sleep(500); foreach (IWebElement y in rows) { if (y.GetAttribute("LocalizedControlType").ToString() == "text") { row = y.GetAttribute("BoundingRectangle").ToString(); } else { Console.WriteLine("No such elements"); } } row = ParseCoordinates(row).Groups[2].ToString(); break; case "Cell": Console.WriteLine("Cell"); SysListView32 = Window.FindElement(By.ClassName("SysListView32")); Console.WriteLine(GETSTRING(item.Key)); Window.Click(); IWebElement col = SysListView32.FindElement(By.Name(GETSTRING(item.Key))); cell = ParseCoordinates(col.GetAttribute("BoundingRectangle").ToString()); MatchSysTreeView32 = ParseCoordinates(SysListView32.GetAttribute("BoundingRectangle").ToString()); new Actions(driver).MoveToElement(SysListView32, ((Convert.ToInt32(cell.Groups[1].ToString()) - Convert.ToInt32(MatchSysTreeView32.Groups[1].ToString())) + Convert.ToInt32(cell.Groups[3].ToString()) / 2), ((Convert.ToInt32(row) - Convert.ToInt32(MatchSysTreeView32.Groups[2].ToString())) + Convert.ToInt32(cell.Groups[4].ToString()) / 2)).Click().Perform(); Thread.Sleep(1000); IWebElement res = driver.SwitchTo().ActiveElement(); Console.WriteLine(res.GetAttribute("Name")); WriteToSTS(res.GetAttribute("Name")); Thread.Sleep(100); WriteToSTS("SERVER: EOF"); sr.Close(); File.Delete(CMDFile); break; default: Console.WriteLine("Write -> default"); break; } } WriteCommandDictionary.Clear(); sr.Close(); File.Delete(CMDFile); //umcomment break; case "CREATESESSION": Console.WriteLine("!!!CREATESESSION"); if (!SessionsDictionary.ContainsKey(match.Groups["wparam"].Value.ToString())) { ; } { SessionsDictionary.Add(match.Groups["wparam"].Value.ToString(), match.Groups["lparam"].Value.ToString().Trim('"')); } sr.Close(); WriteToSTS("SERVER: INFO: Configuring session" + match.Groups["wparam"].Value.ToString() + "HASVP key to 1"); Thread.Sleep(100); File.Delete(CMDFile); break; case "STARTSESSION": Console.WriteLine("!!!STARTSESSION"); match = ParseSession(match.Groups["lparam"].Value.ToString()); CommonProc.LaunchDBP(match.Groups["username"].Value.ToString(), match.Groups["password"].Value.ToString(), parameters); sr.Close(); File.Delete(CMDFile); //umcomment Thread.Sleep(100); break; case "STOPSESSION": Console.WriteLine("!!!STOPSESSION"); driver.FindElementById("Close").Click(); sr.Close(); File.Delete(CMDFile); //umcomment break; case "SETSESSION": Console.WriteLine("!!!SETSESSION"); //driver.FindElement(By.Name(parameters + " - " + GETSTRING("IDS_DLG_MITEL_DB_PROGRAMMING"))).Click(); //switch to window??? break; case "ECHO": Console.WriteLine("!!!ECHO"); switch (parameters) { case "Synchronize": Console.WriteLine("Echo -> Synchronize"); WriteToSTS("Synchronize"); WriteToSTS("SERVER: EOF"); Console.WriteLine("writeSTS"); sr.Close(); File.Delete(CMDFile); //umcomment Console.WriteLine("File delete"); break; default: Console.WriteLine("Write -> default"); break; } break; } } } sr.Close(); } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } Thread.Sleep(1000); }