public String AddImage() { NavigateToAssetTypeSettings(); btnEditAssetTypeSettings.Click(); Thread.Sleep(3000); IWebElement element = btnAddImage; Actions actions = new Actions(PropertiesCollection.driver); actions.MoveToElement(element).Perform(); actions.ClickAndHold().Release().Perform(); string currentDir = System.IO.Directory.GetCurrentDirectory(); var configFile = currentDir.Replace("bin\\Debug", "figther aircraft.jpg"); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", configFile); AutoItX.ControlClick("Open", "", "Button1"); Thread.Sleep(1500); btnSave.Click(); Thread.Sleep(5000); String isImageAdded = txtImage.Text; return(isImageAdded); }
private void EnterTextBox(IntPtr mainWindow, IntPtr textBox, string value) { ClickToFocus(mainWindow, textBox); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.ControlSetText(mainWindow, textBox, value); AutoItX.Sleep(GetRandomDelay(1000)); }
private async void button1_Click(object sender, EventArgs e) { btnCheck.Enabled = false; AutoItX.WinActivate("Comcast"); for (int i = 1; i <= CountFile; i++) { Process pr = new Process(); pr.StartInfo.FileName = "CheckLiveComcast.exe"; pr.Start(); await Task.Delay(1000); AutoItX.WinActivate("Comcast"); AutoItX.ControlSetText("Comcast", "", "[NAME:tbPath]", i.ToString()); await Task.Delay(1000); AutoItX.ControlClick("Comcast", "", "[NAME:btnStart]"); AutoItX.WinSetTitle("Comcast", "", i.ToString()); if (i % 5 == 0 || i == CountFile) { await Task.Delay(20000); killAPP(); } await Task.Delay(1000); } }
static void Login(string account, string password) { string title = "中信证券金融终端"; int handle = AutoItX.WinWait(title, "", 10); if (handle == 0) { throw new InvalidOperationException("failed to find login window"); } IntPtr hwnd = AutoItX.WinGetHandle(title, ""); AutoItX.WinActivate(hwnd); IntPtr hwndAccount = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:SafeEdit1]"); IntPtr hwndPassword = AutoItX.ControlGetHandle(hwnd, "[CLASSNN:SafeEdit2]"); AutoItX.ControlSetText(hwnd, hwndAccount, account); AutoItX.ControlSetText(hwnd, hwndPassword, password); AutoItX.Sleep(2000); // wait 2s AutoItX.Send("{ENTER}"); }
private bool AuthenticateShield(string code) { if (Program.Busy) { return(false); } try { Program.Busy = true; string targetWindowClass = "[CLASS:#32770]"; string targetWindowText = "SHIELD is requesting to connect"; if (AutoItX.WinWait(targetWindowClass, targetWindowText, 1) == 0) { Program.Log("Warning: Auth window does not exist"); return(false); } AutoItX.ControlSetText(targetWindowClass, "", "[CLASS:Edit; INSTANCE:1]", code); AutoItX.ControlClick(targetWindowClass, "", "[CLASS:Button; INSTANCE:1]"); Program.Log("Auth code sent"); return(true); } catch (Exception ex) { Program.Log($"Authentication error: {ex.Message}"); return(false); } finally { Program.Busy = false; } }
/// <summary> /// Upload file as attachment /// </summary> /// <param name="filePath"></param> public void UploadFileAsAttachment(string filePath) { // string filePath = "\"C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg\" \"C:\\Users\\Public\\Pictures\\Sample Pictures\\Hydrangeas.jpg\""; AutoItX.WinWait("[CLASS:#32770]", "", 5); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", filePath); CommonMethods.PlayWait(3000); AutoItX.ControlClick("Open", "", "Button1"); }
private void EnterTextBox(IntPtr mainWindow, IntPtr textBox, string value) { if (AutoItX.ControlFocus(mainWindow, textBox) == AutoItXSuccess) { Thread.Sleep(GetRandomDelay(100)); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.ControlSetText(mainWindow, textBox, value); Thread.Sleep(GetRandomDelay(100)); } }
static void Main(string[] args) { IWebDriver driver = new InternetExplorerDriver(); driver.Navigate().GoToUrl("http://localhost/Home/StephenSecrets"); Thread.Sleep(500); //if required AutoItX.WinWaitActive("Windows Security"); AutoItX.ControlSetText("Windows Security", "", "Edit1", "TestUser"); AutoItX.ControlSetText("Windows Security", "", "Edit2", "Password_test"); AutoItX.Send("{ENTER}"); }
public static void InputHotline(string hotline) { try { AutoItX.ControlSetText(jabberPhoneTitle, "", btn_Search, hotline); Thread.Sleep(300); } catch (NotFoundException ex) { Console.WriteLine("Element does NOT exist : " + btn_Search); Console.WriteLine("Class AutoItXCiscoJabber | Method InputHotline | Exception desc : " + ex.Message); } }
public static void uploadFileUsingAutoIT(string fileName) { FileUploadPath = Path.Combine(solutionParentDirectory, fileName); Console.WriteLine("File upload path: " + FileUploadPath); // Upload file //AutoIt autoIt = new AutoIt(); AutoItX.WinWait("Open"); AutoItX.WinActivate("Open"); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", FileUploadPath); AutoItX.ControlClick("Open", "", "Button1"); }
private void LoginUsingUserCredentials() { WaitForWindow(loginWindowTitle); //Check all elements are visible in this particular window CheckControlVisibility(loginWindowTitle, usernameTextbox); CheckControlVisibility(loginWindowTitle, passwordTextbox); CheckControlVisibility(loginWindowTitle, okButton); CheckforGroupSelector(loginWindowTitle, groupDropdown); AutoItX.ControlSetText(loginWindowTitle, "", usernameTextbox, userName); AutoItX.ControlSetText(loginWindowTitle, "", passwordTextbox, passWord); AutoItX.ControlClick(loginWindowTitle, "", okButton); }
protected bool SetValue(string clazz, int instance, string value) { if (!Running) { return(false); } IntPtr hwnd = GetHandle(clazz, instance); if (hwnd == IntPtr.Zero) { return(false); } return(AutoItX.ControlSetText(process.MainWindowHandle, hwnd, value) == 1); }
public void HandleFileUploadWindow(string filepath) { try { string windowTitle = GetBrowserName() == "internet explorer" ? "Choose File to Upload" : "Open"; AutoItX.WinWait(windowTitle, "File &name:", 10); AutoItX.ControlSetText(windowTitle, "", "[CLASS:Edit; INSTANCE:1]", filepath); AutoItX.ControlClick(windowTitle, "", "[CLASS:Button; INSTANCE:1]"); AutoItX.WinWaitClose(windowTitle, "File &name:", 10); } catch (Exception ex) { throw new Exception(ex.Message); } }
public int ControlSetText(string title, string text, string control, string controlText) { return(AutoItX.ControlSetText(title, text, control, controlText)); }
internal void Share_Skill() { Console.WriteLine("Start of shareSkill Method"); //extent Reports // Base.test = Base.extent.StartTest("Login Test"); //Click on ShareSkill Share_skill.Click(); Thread.Sleep(2000); //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); Thread.Sleep(1000); //Enter Title Title.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Thread.Sleep(1000); //Enter Description Description.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Thread.Sleep(1000); //Click on Category Category.Click(); //Enter Category var selectElement = new SelectElement(Category); selectElement.SelectByText(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Category")); Thread.Sleep(2000); //Click on Sub Category SubCategory.Click(); Thread.Sleep(3000); //Enter Sub Category var selectElementSub = new SelectElement(SubCategory); selectElementSub.SelectByText(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Sub Category")); Thread.Sleep(1000); //Click on tags Tags.Click(); //Enter a tag Tags.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); //Select a Service Type ServiceType.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Service Type")); //Select Location Type locationType.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Location Type")); //Click on Avaliable days StartDate.Click(); Thread.Sleep(1000); //Select Available days StartDate.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Date")); //Click on Sunday Checkbox Checkbox.Click(); Thread.Sleep(1000); //Select Start Time StartTime.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Start Time")); //Select Skill Trade skillTrades.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade")); //Select Skill-Exchange SkillExchange.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Skill Exchange")); Thread.Sleep(2000); //Click on plus icon of Work Samples Work_Samples.Click(); Thread.Sleep(3000); //Call AutoIt to choose a file AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", @"D:\kavya\AutoIt"); AutoItX.ControlClick("Open", "", "Button1"); //Select Active Active.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Active")); //Click on Save Save.Click(); }
private static void FillUpTransferForm(IntPtr inputMainPanel) { var toAccountNumber = "6214837694277025"; var toAccountName = "吕文斌"; //var fromAccountNumber = ""; //var fromAccountName = ""; var transactionReferenceId = "12345678912"; var transactionReference = "test Remarks"; var amount = "1"; //Click Transger if (AutoItX.WinActivate(_mainForm) != 1) { return; } WaitForTransferPage(); var inputMainPanelPosition = AutoItX.ControlGetPos(_mainForm, inputMainPanel); var elemementPositionX = _windowsPosition.X + inputMainPanelPosition.X; var elemementPositionY = _windowsPosition.Y + inputMainPanelPosition.Y; //Account Name AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); var txttoAccount = AutoItX.ControlGetHandle(_mainForm, "[CLASS:Edit; INSTANCE:1]"); AutoItX.ControlSetText(_mainForm, txttoAccount, toAccountName); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 35); Thread.Sleep(GetRandomDelay(1000)); //Account Number AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 75); AutoItX.Send(toAccountNumber); Thread.Sleep(GetRandomDelay(1000)); //Bank AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 120); Thread.Sleep(GetRandomDelay(1000)); //Amount AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 230); AutoItX.Send(amount); Thread.Sleep(GetRandomDelay(1000)); //transaction Remarks AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 285); AutoItX.Send(transactionReference); Thread.Sleep(GetRandomDelay(1000)); //transaction ID AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 335); AutoItX.Send(transactionReferenceId); Thread.Sleep(GetRandomDelay(1000)); AutoItX.WinActivate(_mainForm); AutoItX.AutoItSetOption("SendKeyDelay", GetRandomDelay(100)); AutoItX.MouseClick("LEFT", elemementPositionX + 200, elemementPositionY + 380); Thread.Sleep(GetRandomDelay(1000)); if (ConfirmationMessageFindByClassName("TPbBaseMsgForm", new Tuple <int, int>(285, 180))) { Console.WriteLine("Error FillUpTransferForm"); } }
/// <summary> /// Sends text to file name control of browser open file GUI dialog window and /// presses {Enter} key. Supports single and multiple (from the same folder) /// file(s) upload. Checks whether the dialog was closed afterwards. /// </summary> /// <param name="paths">File(s) with full path</param> public static void Upload(params string[] paths) { if (paths == null || paths.Length == 0 || string.IsNullOrEmpty(paths[0])) { throw new ArgumentException( @"Got null or empty parameter(s). Nothing to upload.", nameof(paths)); } // is it multiple files upload? var isMultipleFilesUpload = paths.Length > 1; // waits for dialog window appearance if (AutoItX.WinWait(WindowTitle, string.Empty, 5) == 0) { throw new AggregateException($@"AutoItX: '{WindowTitle}' dialog window not found"); } // get handles of dialog window, OK button, and File Name input controls _windowHandle = AutoItX.WinGetHandle(WindowTitle); _okControlHandle = AutoItX.ControlGetHandle(_windowHandle, OkControlName); _fileNameControlHandle = AutoItX.ControlGetHandle(_windowHandle, FileNameControlName); if ((int)_windowHandle <= 0 || (int)_okControlHandle <= 0) { throw new AggregateException("AutoItX: Cannot get window or/and control handle(s)"); } // activate dialog window (just in case) AutoItX.WinActivate(_windowHandle); // set uploaded files folder as current folder in case of multiple files selection var dir = Path.GetDirectoryName(paths[0])?.Replace(@"\\", @"\"); if (isMultipleFilesUpload && !string.IsNullOrEmpty(dir)) { // change path // mode: 1 -> no control symbols processing, send text "as is" AutoItX.ControlSend( _windowHandle, AutoItX.ControlGetHandle(_windowHandle, FileNameControlName), dir, mode: 1); // press OK button AutoItX.ControlClick(_windowHandle, _okControlHandle); Thread.Sleep(1000); } // create input string for file name control var path1 = string.Empty; foreach (var path in paths) { path1 += (isMultipleFilesUpload ? "\"" + Path.GetFileName(path) + "\" " : path) .Replace(@"\\", @"\"); // check if dialog is still active and activate it if needed if (AutoItX.WinActive(_windowHandle) != 0) { continue; } if (AutoItX.WinActivate(_windowHandle) == 0) { throw new AggregateException( $@"AutoItX: Cannot activate '{WindowTitle}' dialog window. " + "Is it closed, overlapped or desktop is locked?"); } } // due to upper/lower case AutoIt input typos, following workaround is implemented: // input path to File Name control and verify it afterwards; if wrong, input it // over and over until succeed or timed out var sw = new Stopwatch(); sw.Start(); while (AutoItX.ControlGetText(_windowHandle, _fileNameControlHandle) != path1 && sw.Elapsed < TimeSpan.FromSeconds(60)) { AutoItX.ControlSetText(_windowHandle, _fileNameControlHandle, string.Empty); AutoItX.ControlSend(_windowHandle, _fileNameControlHandle, path1, mode: 1); } sw.Stop(); // if input is timed out, throw exception if (sw.Elapsed >= TimeSpan.FromSeconds(60)) { throw new AggregateException($@"AutoItX: Failed to input path '{path1}'"); } // check if dialog is still active and activate it if not if (AutoItX.WinActive(_windowHandle) == 0) { if (AutoItX.WinActivate(_windowHandle) == 0) { throw new AggregateException( $@"AutoItX: Cannot activate '{WindowTitle}' GUI dialog window. " + "Is it closed, overlapped or desktop is locked?"); } } // press OK button AutoItX.ControlClick(_windowHandle, _okControlHandle); // check if the dialog is closed var success = AutoItX.WinWaitClose(_windowHandle, 1); if (success > 0) { return; } // throw exception if dialog is not closed throw new AggregateException( $@"AutoItX: Failed to close '{WindowTitle}' GUI dialog window. Was this " + "window closed manually, desktop locked, or 'File not found' error " + "displayed?"); }
public async Task Convert(Progress <ProgressReportModel> progress) { Microsoft.Office.Interop.Excel.Application MyExcel = new Microsoft.Office.Interop.Excel.Application(); #region Environment // 殺掉所有的EXCEL foreach (Process p in Process.GetProcessesByName("EXCEL")) { p.Kill(); } // 營造環境 // 各類資料維護 // 計價標準維護 (這就是我們的標的) if (AutoItX.WinExists("計價標準檔維護") == 1) //如果直接存在就直接叫用 { AutoItX.WinActivate("計價標準檔維護"); } else { if (AutoItX.WinExists("各類資料維護") == 1) { AutoItX.WinActivate("各類資料維護"); } else { Thesis.LogIN(); // 從"杏雲雲端醫療服務"叫用"各類資料維護" // 打開"處方清單", 找不到control,只好用mouse去按 AutoItX.WinActivate("杏雲雲端醫療服務"); // 先maximize AutoItX.WinSetState("杏雲雲端醫療服務", "", 3); //0 close; 1 @SW_RESTORE; 2 @SW_MINIMIZE; 3 @SW_MAXIMIZE AutoItX.MouseClick("LEFT", AutoItX.WinGetPos("杏雲雲端醫療服務").X + 200, AutoItX.WinGetPos("杏雲雲端醫療服務").Y + 175); AutoItX.Sleep(500); AutoItX.ControlClick("杏雲雲端醫療服務", "", "[NAME:btnDBaseMaint]"); } // 從"各類資料維護"叫用"計價標準檔維護" AutoItX.Sleep(10000); AutoItX.ControlSetText("各類資料維護", "", "[NAME:txbQuery]", "計價標準檔維護"); // AutoItX.ControlSend("各類資料維護", "", "[NAME:txbQuery]", "計價標準檔維護") AutoItX.ControlClick("各類資料維護", "", "[NAME:btnQuery]"); AutoItX.MouseClick("LEFT", AutoItX.WinGetPos("各類資料維護").X + 100, AutoItX.WinGetPos("各類資料維護").Y + 135, 2); log.Info("Click inquiry."); //AutoItX.Sleep(2000); //AutoItX.WinActivate("計價標準檔維護"); } log.Info("Start to Click."); do { // 20200517 一直按到行為止 // 20190610 模仿昨天成功的經驗 // 打開EXCEL檔 AutoItX.Send("{Alt}"); AutoItX.Send("{Down}"); AutoItX.Send("{Down}"); AutoItX.Send("{Down}"); AutoItX.Send("{Down}"); AutoItX.Send("{Down}"); AutoItX.Send("{Down}"); // 20200319 修改程式,再往下一格 AutoItX.Send("{Down}"); AutoItX.Send("{Enter}"); AutoItX.Sleep(10000); } while (Process.GetProcessesByName("EXCEL").Length == 0); log.Info("Excel exists now."); MyExcel = (Microsoft.Office.Interop.Excel.Application)Marshal.GetActiveObject("Excel.Application"); do { AutoItX.Sleep(100); } while (!MyExcel.Visible); log.Info("Excel appears now."); #endregion Environment #region Saving XLSX files // ==================================================================================================================================== // 製作自動檔名 string temp_filepath = @"C:\vpn\odr"; // 20190609 因為不小心多一個空格, 搞了好久除錯, 很辛苦啊 // System.Runtime.InteropServices.COMException '發生例外狀況於 HRESULT: 0x800A03EC' // 存放目錄,不存在就要建立一個 if (!System.IO.Directory.Exists(temp_filepath)) { System.IO.Directory.CreateDirectory(temp_filepath); } // 自動產生名字 string temp_file = $"\\odr_{DateTime.Now.Year}{(DateTime.Now.Month + 100).ToString().Substring(1)}"; temp_file += $"{(DateTime.Now.Day + 100).ToString().Substring(1)}_{DateTime.Now.TimeOfDay}"; temp_file = temp_file.Replace(":", "").Replace(".", ""); temp_filepath += $"{temp_file}.xlsx"; // wb.SaveAs(temp_filepath, Excel.XlFileFormat.xlCSV, vbNull, vbNull, False, False, Excel.XlSaveAsAccessMode.xlNoChange, vbNull, vbNull, vbNull, vbNull, vbNull) Microsoft.Office.Interop.Excel.Workbook wb = MyExcel.ActiveWorkbook; wb.SaveAs(temp_filepath, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook); Microsoft.Office.Interop.Excel.Worksheet ws = wb.ActiveSheet; #endregion Saving XLSX files // 丟出的是一個object [,] ODRconvert odr = new ODRconvert(ws.UsedRange.Value2); await odr.Transform(progress); #region Ending // 殺掉所有的EXCEL foreach (Process p in Process.GetProcessesByName("EXCEL")) { p.Kill(); } AutoItX.WinClose("計價標準檔維護"); AutoItX.WinClose("各類資料維護"); #endregion Ending }
internal void EnterShareSkill() { //Populate the excel data GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPathShareSkill, "ShareSkill"); //Waiting for Profile page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.LinkText("Share Skill"), 10); //Click on Share Skill button ShareSkillButton.Click(); //Waiting for Share Skill page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.Name("title"), 10); //Enter Title Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title") + TimeStamp); //Enter Description Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Select Category from DropDown CategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Select SubCategory from DropDown SubCategoryDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Enter Tags Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + Keys.Enter); //Select ServiceType from Option switch ((GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType"))) { case "Hourly basis service": //Select Hourly basis service from options ServiceTypeOptions[0].Click(); break; case "One-off service": //Select One-off service from options ServiceTypeOptions[1].Click(); break; } //Select LocationType from Option switch ((GlobalDefinitions.ExcelLib.ReadData(2, "LocationType"))) { case "On-site": //Select On-site from location options LocationTypeOption[0].Click(); break; case "Online": //Select Online from location options LocationTypeOption[1].Click(); break; } //Enter StartDate from DropDown StartDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Startdate")); //Enter EndDate from DropDown EndDateDropDown.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Enddate")); //Select Days and enter Start and End time if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Sun") { //Select Sunday Days[0].Click(); //Enter StartTime from DropDown StartTimeDropDown[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[0].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Mon") { //Select Monday Days[1].Click(); //Enter StartTime from DropDown StartTimeDropDown[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[1].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Tue") { //Select Tuesday Days[2].Click(); //Enter StartTime from DropDown StartTimeDropDown[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[2].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Wed") { //Select Wednesday Days[3].Click(); //Enter StartTime from DropDown StartTimeDropDown[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[3].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Thu") { //Select Thursday Days[4].Click(); //Enter StartTime from DropDown StartTimeDropDown[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[4].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Fri") { //Select Friday Days[5].Click(); //Enter StartTime from DropDown StartTimeDropDown[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[5].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "Selectday")) == "Sat") { //Select Saturday Days[6].Click(); //Enter StartTime from DropDown StartTimeDropDown[7].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")); //Enter EndTime from DropDown EndTimeDropDown[6].SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")); } //Select Skill Trade from options if ((GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")) == "Skill-Exchange") { //Select Skill-exchange from available options SkillTradeOption[0].Click(); //Enter SkillExchange SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + Keys.Enter); } else if ((GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")) == "Credit") { //Select Credit from available options SkillTradeOption[1].Click(); //Enter Credit Amount CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); } //Select ActiveOption switch ((GlobalDefinitions.ExcelLib.ReadData(2, "Active"))) { case "Active": //Select Active status ActiveOption[0].Click(); break; case "Hidden": //Select Hidden status ActiveOption[1].Click(); break; } //Click on work sample file add icon FileAdd.Click(); //Add work sample file using AutoIT AutoItX.WinWait("[CLASS:#32770]", "", 30); Thread.Sleep(3000); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", @"C:\Study\IndustryConnect\git\ProjectMarsTestAutomationHybridFramework\MarsFramework\testFile.txt"); Thread.Sleep(3000); AutoItX.ControlClick("Open", "", "Button1"); //Click on Save button Save.Click(); //Waiting for Manage Listing page to load GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//table[1]/tbody[1]"), 10); }
internal void EnterShareSkill(string title, string description, string category, string subCategory, string tags, string serviceType, string locationType, string startDate, string endDate, string day, string startTime, string endTime, string skillTradeOption, string skillExchangeTag, string creditAmount, string active) { //Input Title Title.SendKeys(title); //Input Description Description.SendKeys(description); //Select Category new SelectElement(CategoryDropDown).SelectByText(category); //Select Sub-Category new SelectElement(SubCategoryDropDown).SelectByText(subCategory); //Add tag Tags.SendKeys(tags); Tags.SendKeys(Keys.Enter); //Select ServiceType ServiceTypeOptions.FindElement(By.XPath($"//label[text()='{serviceType}']//preceding-sibling::input")).Click(); //Select LocationType LocationTypeOptions.FindElement(By.XPath($"//label[text()='{locationType}']//preceding-sibling::input")).Click(); //Enter Startdate StartDateDropDown.SendKeys(startDate); //Enter Enddate EndDateDropDown.SendKeys(endDate); //Select Days Days.FindElement(By.XPath($"//label[text()='{day}']//preceding-sibling::input")).Click(); //Enter Starttime StartTime.SendKeys(startTime); //Enter Endtime EndTime.SendKeys(endTime); //Select Skilltrade option SkillTradeOptions.FindElement(By.XPath($"//label[text()='{skillTradeOption}']//preceding-sibling::input")).Click(); //Config Skilltrade according to options switch (skillTradeOption) { case "Skill-exchange": SkillExchange.SendKeys(skillExchangeTag); SkillExchange.SendKeys(Keys.Enter); break; case "Credit": CreditAmount.SendKeys(creditAmount); break; } //Upload Work Sample PlusIcon.Click(); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", WorkSamplePath); AutoItX.ControlClick("Open", "", "Button1"); //Select Active Option ActiveOptions.FindElement(By.XPath($"//label[text()='{active}']//preceding-sibling::input")).Click(); }
public int ControlSetText(string controlText, string control = "") { return(AutoItX.ControlSetText(thiswindowHandle, ControlGetHandle(control), controlText)); }
internal void EditShareSkill(string title, string description, string category, string subCategory, string tags, string serviceType, string locationType, string startDate, string endDate, string day, string startTime, string endTime, string skillTradeOption, string skillExchangeTag, string creditAmount, string active) { //Input Title Title.Clear(); Title.SendKeys(title); //Input Description Description.Clear(); Description.SendKeys(description); //Select Category new SelectElement(CategoryDropDown).SelectByText(category); //Select Sub-Category new SelectElement(SubCategoryDropDown).SelectByText(subCategory); //Add tag //Clear the existed tags first foreach (var removeTag in RemoveTags) { removeTag.Click(); } Tags.SendKeys(tags); Tags.SendKeys(Keys.Enter); //Select ServiceType ServiceTypeOptions.FindElement(By.XPath($"//label[text()='{serviceType}']//preceding-sibling::input")).Click(); //Select LocationType LocationTypeOptions.FindElement(By.XPath($"//label[text()='{locationType}']//preceding-sibling::input")).Click(); Thread.Sleep(3000); //Enter Startdate StartDateDropDown.SendKeys(startDate); Thread.Sleep(3000); //Enter Enddate EndDateDropDown.SendKeys(endDate); //Deselect if some days have already been selected foreach (var dayCheckbox in DaysCheckboxes) { if (dayCheckbox.Selected) { dayCheckbox.Click(); } } //Select Days Days.FindElement(By.XPath($"//label[text()='{day}']//preceding-sibling::input")).Click(); //Enter Starttime StartTime.SendKeys(startTime); //Enter Endtime EndTime.SendKeys(endTime); //Select Skilltrade option SkillTradeOptions.FindElement(By.XPath($"//label[text()='{skillTradeOption}']//preceding-sibling::input")).Click(); //Config Skilltrade according to options switch (skillTradeOption) { case "Skill-exchange": SkillExchange.SendKeys(skillExchangeTag); SkillExchange.SendKeys(Keys.Enter); break; case "Credit": CreditAmount.SendKeys(creditAmount); break; } //Clear the work sample foreach (var removeSample in RemoveSampleIcons) { removeSample.Click(); } //Upload Work Sample PlusIcon.Click(); AutoItX.WinWaitActive("Open"); AutoItX.ControlFocus("Open", "", "Edit1"); AutoItX.ControlSetText("Open", "", "Edit1", WorkSamplePath); AutoItX.ControlClick("Open", "", "Button1"); //Select Active Option ActiveOptions.FindElement(By.XPath($"//label[text()='{active}']//preceding-sibling::input")).Click(); }