private void CreateDocumentForRecognize(bool isPDF = true, string docPath = "", int?fileNumber = 0) { method = MethodBase.GetCurrentMethod().Name; Print(method, "Started"); m.Click(By.Name("Add Document")); //add document button (+ icon) Print(method, "x: " + Cursor.Position.X + " y: " + Cursor.Position.Y); m.Click(By.Id("lblType")); Print(method, "x: " + Cursor.Position.X + " y: " + Cursor.Position.Y); action.MoveByOffset(20, -40).Click().MoveByOffset(20, 60).Click().Build().Perform(); Print(method, "x: " + Cursor.Position.X + " y: " + Cursor.Position.Y); //find the document to add in file explorer //configure docpath in app.config, takes arg of pdf or tif if (docPath.Length < 1) { docPath = ConfigurationManager.AppSettings.Get("AddDocumentStorage"); } m.SendKeys(By.Id("1001"), docPath); Print(method, "Go to \"" + docPath + "\""); m.Click(By.Name("Go to \"" + docPath + "\"")); var rand = new Random(); if (isPDF) { Winium.Elements.Desktop.ComboBox filesOfType = new Winium.Elements.Desktop.ComboBox(m.Locate(By.Name("Files of type:"))); filesOfType.SendKeys("p"); filesOfType.SendKeys(OpenQA.Selenium.Keys.Enter); Thread.Sleep(500); if (fileNumber == 0) { action.MoveToElement(m.Locate(By.Id(rand.Next(Directory.GetFiles(docPath, "*.pdf").Length).ToString()))).DoubleClick().Build().Perform(); } else { action.MoveToElement(m.Locate(By.Id(fileNumber.ToString()))).DoubleClick().Build().Perform(); } m.Click(By.Name("Open")); } else { if (fileNumber == 0) { action.MoveToElement(m.Locate(By.Id(rand.Next(Directory.GetFiles(docPath, "*.tif").Length).ToString()))).DoubleClick().Build().Perform(); } else { action.MoveToElement(m.Locate(By.Id(fileNumber.ToString()))).DoubleClick().Build().Perform(); } m.Click(By.Name("Open")); } Print(method, "save and quit"); m.Click(By.Id("btnSave")); m.Click(By.Id("btnClose")); Print(method, "Finished"); }
//find the document to add in file explorer //configure docpath in app.config, takes arg of pdf or tif private void FileExplorer(bool isPDF, string docPath, int?fileNumber) { if (docPath.Length < 1) { docPath = ConfigurationManager.AppSettings.Get("AddDocumentStorage"); } m.SendKeys(By.Id("1001"), docPath); Print("Go to \"" + docPath + "\"", method); m.Click(By.Name("Go to \"" + docPath + "\"")); var rand = new Random(); if (isPDF) { Winium.Elements.Desktop.ComboBox filesOfType = new Winium.Elements.Desktop.ComboBox(m.Locate(By.Name("Files of type:"))); filesOfType.SendKeys("p"); filesOfType.SendKeys(OpenQA.Selenium.Keys.Enter); Thread.Sleep(500); if (fileNumber == 0) { action.MoveToElement(m.Locate(By.Id(rand.Next(Directory.GetFiles(docPath, "*.pdf").Length).ToString()))).DoubleClick().Build().Perform(); } else { action.MoveToElement(m.Locate(By.Id(fileNumber.ToString()))).DoubleClick().Build().Perform(); } //m.Click(By.Name("Open")); } else { if (fileNumber == 0) { action.MoveToElement(m.Locate(By.Id(rand.Next(Directory.GetFiles(docPath, "*.tif").Length).ToString()))).DoubleClick().Build().Perform(); } else { action.MoveToElement(m.Locate(By.Id(fileNumber.ToString()))).DoubleClick().Build().Perform(); } //m.Click(By.Name("Open")); } Thread.Sleep(2000); }
public void CreateDocument(int?numOfDocs = 1, bool isPDF = true, string docPath = "", int?fileNumber = 0) { method = MethodBase.GetCurrentMethod().Name; Print(method, "Started"); Thread.Sleep(2000); //check if maximized window = m.Locate(By.Id("frmIntactMain")); if (m.IsElementPresent(By.Name("Maximize"), window)) { m.Click(By.Name("Maximize"), window); } for (int i = 0; i < numOfDocs; i++) { m.Click(By.Name("Add Document")); //add document button (+ icon) Print(method, "x: " + Cursor.Position.X + " y: " + Cursor.Position.Y); m.Click(By.Id("lblType")); Print(method, "x: " + Cursor.Position.X + " y: " + Cursor.Position.Y); action.MoveByOffset(20, -40).Click().MoveByOffset(20, 60).Click().Build().Perform(); Print(method, "x: " + Cursor.Position.X + " y: " + Cursor.Position.Y); //find the document to add in file explorer //configure docpath in app.config, takes arg of pdf or tif if (docPath.Length < 1) { docPath = ConfigurationManager.AppSettings.Get("AddDocumentStorage"); } m.SendKeys(By.Id("1001"), docPath); Print(method, "Go to \"" + docPath + "\""); m.Click(By.Name("Go to \"" + docPath + "\"")); var rand = new Random(); if (isPDF) { Winium.Elements.Desktop.ComboBox filesOfType = new Winium.Elements.Desktop.ComboBox(m.Locate(By.Name("Files of type:"))); filesOfType.SendKeys("p"); filesOfType.SendKeys(OpenQA.Selenium.Keys.Enter); Thread.Sleep(500); if (fileNumber == 0) { action.MoveToElement(m.Locate(By.Id(rand.Next(Directory.GetFiles(docPath, "*.pdf").Length).ToString()))).DoubleClick().Build().Perform(); } else { action.MoveToElement(m.Locate(By.Id(fileNumber.ToString()))).DoubleClick().Build().Perform(); } m.Click(By.Name("Open")); } else { if (fileNumber == 0) { action.MoveToElement(m.Locate(By.Id(rand.Next(Directory.GetFiles(docPath, "*.tif").Length).ToString()))).DoubleClick().Build().Perform(); } else { action.MoveToElement(m.Locate(By.Id(fileNumber.ToString()))).DoubleClick().Build().Perform(); } m.Click(By.Name("Open")); } Thread.Sleep(3000); //edit custom fields Print(method, "custom fields"); m.Click(By.Id("lblType")); action.MoveByOffset(150, 240).Click().SendKeys("1/1/2000"). MoveByOffset(0, 20).Click().SendKeys("7").MoveByOffset(0, 20).Click().SendKeys("string").Build().Perform(); //save and quit Print(method, "save and quit"); m.Click(By.Id("btnSave")); m.Click(By.Id("btnClose")); Print(method, "Finished"); } }