private void Wait(string appTitle, string panelId, string selectionMessage) { bool isStarted = false; while (!isStarted) { Thread.Sleep(1000); var processes = Process.GetProcesses(); foreach (var prServiceInstallExist in processes) { if (prServiceInstallExist.MainWindowTitle == appTitle) ///*|| prServiceInstallExist.MainWindowTitle == "Continuous Monitoring Insight Setup" { _robot.ControlFocus(appTitle, "", panelId); if (_robot.ControlGetText(appTitle, "", panelId) == selectionMessage || _robot.ControlGetText(appTitle, "", panelId).Contains(selectionMessage)) { isStarted = true; Thread.Sleep(1000); break; } } } } }
public Boolean UploadFiles() { IList <IWebElement> subList = rdriver.FindElements(By.XPath("//ul[@class='mc-tertiary-list secondary-action-menu']//li")); int length = subList.Count; for (int i = 0; i <= length; i++) { string actionMenu = rdriver.FindElement(By.XPath("//div[@id='pagelet-2']//li[1]")).Text; if (actionMenu == "Upload files") { rdriver.FindElement(By.XPath("//div[@id='pagelet-2']//li[1]")).Click(); break; } } //Selecting the file from the desktop path Thread.Sleep(5000); auto.WinActivate("Open"); auto.ControlFocus("Open", "", "Edit1"); string path = ConfigurationManager.AppSettings["Path"]; auto.ControlSetText("Open", "", "Edit1", path); auto.ControlClick("Open", "", "Button1"); Thread.Sleep(2000); auto.ControlFocus("Open", "", "DirectUIHWND2"); SendKeys.SendWait("^(a)"); Thread.Sleep(2000); string[] fileList = Directory.GetFiles(path); List <string> fileNameList = new List <string>(); for (int i = 0; i < fileList.Length; i++) { fileNameList.Add(Path.GetFileName(fileList[i])); } string[] fileNameArray = fileNameList.ToArray(); auto.ControlClick("Open", "", "Button1"); Thread.Sleep(20000); IList <IWebElement> totalFiles = rdriver.FindElements(By.XPath("//tbody[@class='mc-table-body mc-table-body-culled']//tr")); int filesCount = totalFiles.Count; // Console.WriteLine(filesCount); for (int j = 1; j <= filesCount; j++) { string fileName = rdriver.FindElement(By.XPath("//tr[" + (j) + "]//td[2]")).Text; Console.WriteLine(fileName); if (!fileNameArray.Contains(fileName)) { return(false); } } return(true); }
public void OpenImageFromLocalFileSystem() { //Navigates the browser to given URL driver.Navigate().GoToUrl("https://images.google.com/"); string fullFilePath = @"C:\AutomationImages\Actual.jpg"; Console.WriteLine("Open File: " + fullFilePath); IWebElement searchByImageButton = driver.FindElement(By.XPath("//span[@id='qbi']")); searchByImageButton.Click(); IWebElement searchByImageWindow = driver.FindElement(By.XPath("//div[@id='qbp']")); IWebElement tabUploadImage = searchByImageWindow.FindElement(By.XPath("//div[@Class='qbtbha sl']")); tabUploadImage.Click(); IWebElement btnChoosefile = searchByImageWindow.FindElement(By.XPath("//input[@id='qbfile']")); btnChoosefile.Click(); System.Threading.Thread.Sleep(2000); AutoItX3 autoIT = new AutoItX3(); autoIT.WinWait("Open"); autoIT.WinActivate("Open"); autoIT.ControlFocus("Open", "", "[CLASS:Edit]"); autoIT.ControlSetText("Open", "", "[CLASS:Edit]", fullFilePath); //autoIT.Send(@"Actual.jpg"); autoIT.ControlClick("Open", "", "[CLASS:Button; Text: Open]"); }
public static void UploadFile(string FilePath) { AutoItX3 AutoIT = new AutoItX3(); AutoIT.WinWaitActive("Open", "", 1500); AutoIT.ControlFocus("Open", "", "Edit1"); AutoIT.ControlSetText("Open", "", "Edit1", FilePath); AutoIT.ControlClick("Open", "", "Button1"); }
public bool ButtonClick(string appTitle, string text, string panelId, string btnControl, string selectionMessage) { try { _robot.WinActivate(appTitle); if (_robot.ControlGetText(appTitle, text, panelId) == selectionMessage || _robot.ControlGetText(appTitle, text, panelId).Contains(selectionMessage)) { _robot.ControlFocus(appTitle, text, btnControl); _robot.Send("{ENTER}"); Sleep(500); } return(true); } catch (Exception) { return(false); } }
internal void Uploadfile() { WorkSample.Click(); AutoItX3 autoIt = new AutoItX3(); autoIt.WinWait("Open", "File Upload", 1); autoIt.WinActivate("Open", "File Upload"); autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Text.txt"); //Workaround: Copy WorkSample.txt file from root folder to Desktop //autoIt.Send("C:\\Users\\OEM\\Desktop\\WorkSample.txt"); autoIt.Send("{ENTER}"); }
public static void AddAutoReplyVoice(string video) { PortalChromeDriver.ClickElementPerXpath(FollowedAutoReplyElement.tabvoice); PortalChromeDriver.ClickElementPerXpath(FollowedAutoReplyElement.autoreply_content); Thread.Sleep(2 * 1000); AutoItX3 au3 = new AutoItX3(); PortalChromeDriver.Wait(TimeSpan.FromSeconds(10)); au3.ControlFocus("Open", "", "Edit1"); au3.ControlSetText("Open", "", "Edit1", @"D:\Test case\Test case\测试素材\Test AMR\" + video); PortalChromeDriver.Wait(TimeSpan.FromSeconds(2)); au3.ControlClick("Open", "", "Button1"); PortalChromeDriver.Wait(TimeSpan.FromSeconds(5)); PortalChromeDriver.ClickElementPerXpath(FollowedAutoReplyElement.Bottom_Save); }
public static void AddAutoReplyImage(string image) { PortalChromeDriver.ClickElementPerXpath(FollowedAutoReplyElement.tabimage); PortalChromeDriver.ClickElementPerXpath(FollowedAutoReplyElement.autoreply_content); AutoItX3 au3 = new AutoItX3(); PortalChromeDriver.Wait(TimeSpan.FromSeconds(10)); au3.ControlFocus("Open", "", "Edit1"); au3.ControlSetText("Open", "", "Edit1", @"C:\Users\v-haxun\Desktop\Image\" + image); PortalChromeDriver.Wait(TimeSpan.FromSeconds(2)); au3.ControlClick("Open", "", "Button1"); PortalChromeDriver.Wait(TimeSpan.FromSeconds(5)); PortalChromeDriver.ClickElementPerXpath(FollowedAutoReplyElement.Bottom_Save); //Thread.Sleep(2 * 1000); }
public static void SendImage() { try { PortalChromeDriver.GetElementByXpath(HIPortalPageUIElement.addimg_hidden_input).Click(); AutoItX3 au3 = new AutoItX3(); PortalChromeDriver.Wait(TimeSpan.FromSeconds(10)); au3.ControlFocus("Open", "", "Edit1"); au3.ControlSetText("Open", "", "Edit1", @"C:\Users\v-haxun\Desktop\Test.png"); PortalChromeDriver.Wait(TimeSpan.FromSeconds(2)); au3.ControlClick("Open", "", "Button1"); PortalChromeDriver.Wait(TimeSpan.FromSeconds(5)); } catch (Exception e) { } }
/// <summary> /// Open a file from local system /// </summary> /// <param name="fullFilePath">Full path of the file (along with extension)</param> public static void OpenFile(string fullFilePath) { Console.WriteLine("Open File: " + fullFilePath); WndImagePro wndImagePro = new WndImagePro(); wndImagePro.SetFocus(); Keyboard.SendKeys("O", ModifierKeys.Control); System.Threading.Thread.Sleep(2000); AutoItX3 autoIT = new AutoItX3(); autoIT.WinWait("Open"); autoIT.WinActivate("Open"); autoIT.ControlFocus("Open", "", "[CLASS:Edit]"); autoIT.ControlSetText("Open", "", "[CLASS:Edit]", fullFilePath); //autoIT.Send(@"Actual.jpg"); // autoIT.ControlClick("Open", "", "[CLASS:Button; Text: Open]"); Keyboard.SendKeys("O", ModifierKeys.Alt); }
static void UploadLanesTemplate() { try { WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10)); IWebElement element = wait.ValidateControl("uploadBtn"); element.Click(); Thread.Sleep(1000); AutoItX3 autoIt = new AutoItX3(); autoIt.ControlFocus("Open", "", "Edit1"); Thread.Sleep(1000); autoIt.ControlSetText("Open", "", "Edit1", requestTemplatePath + fileName); Thread.Sleep(1000); autoIt.ControlClick("Open", "", "Button1"); } catch (Exception ex) { throw ex; } }
public static void AddMenu_Image() { try { PortalChromeDriver.ClickElementPerXpath(MenuElement.Send_Message); PortalChromeDriver.ClickElementPerXpath(MenuElement.tabImage); PortalChromeDriver.ClickElementPerXpath(MenuElement.ImageChoose); AutoItX3 au3 = new AutoItX3(); PortalChromeDriver.Wait(TimeSpan.FromSeconds(10)); au3.ControlFocus("Open", "", "Edit1"); au3.ControlSetText("Open", "", "Edit1", @"C:\Users\v-haxun\Desktop\Image\efwe.jpg"); PortalChromeDriver.Wait(TimeSpan.FromSeconds(2)); au3.ControlClick("Open", "", "Button1"); PortalChromeDriver.Wait(TimeSpan.FromSeconds(5)); } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// Upload image on server /// </summary> /// <param name="imagePath">Path to the file</param> /// <param name="millisecondsUploadTimeout">Amount of time will wait for upload file before failing a request</param> public void UploadImageFile(string imagePath, int millisecondsUploadTimeout) { btnChooseFiles.WaitUntilVisible(2000); int oldCountUploadedFiles = divUploadedFiles.FindElements(By.ClassName("file-name")).Count; btnChooseFiles.Click(); AutoItX3 autoIt = new AutoItX3(); if (autoIt.WinWait(TitleOpenFileDialog) == 0) { throw new NullReferenceException("OpenFileDialog can not be found."); } autoIt.ControlFocus(TitleOpenFileDialog, "", "Edit1"); autoIt.Sleep(500); autoIt.ControlSetText(TitleOpenFileDialog, "", "Edit1", imagePath); autoIt.ControlClick(TitleOpenFileDialog, "", "Button1"); int newCountUploadedFiles = 0; for (int i = 0; (i < millisecondsUploadTimeout) && (newCountUploadedFiles <= oldCountUploadedFiles); i += 500) { System.Threading.Thread.Sleep(500); newCountUploadedFiles = divUploadedFiles.FindElements(By.ClassName("file-name")).Count; } string info = "Upload: " + DateTime.Now.ToString() + " - " + Path.GetFileName(imagePath) + "\n"; if (oldCountUploadedFiles == newCountUploadedFiles) { throw new ErrorUploadImagesException("Error loading: " + info); } txtAdditionalRemarks.SendKeys(info); btnSave.Click(); }
public void Upload_File() { var Autoit = new AutoItX3(); const string widowTitle = "[Class:#32770]"; //上传窗口的类名:Class:#327700 Autoit.WinWait(widowTitle, "文件上传", 1); //暂停执行脚本,直到上传对话框出现 Autoit.WinActivate(widowTitle, "文件上传"); //激活上传窗口 Autoit.ControlFocus(widowTitle, "文件上传", "[CLASS:Edit; INSTANCE:1]"); //控制焦点在输入框上 //Autoit.ControlSetText(widowTitle, "", "[CLASS:Edit; INSTANCE:1]", "D:\\temp\\Desert.jpg"); //这行代码是另一个输入路径的方法 Autoit.Send(@"D:\azaas.jpg"); //输入文件路径 Autoit.Sleep(1000); Autoit.Send("{ENTER}"); // //try // //{ //Autoit.ControlClick(widowTitle, "文件上传", "[CLASS:Button; INSTANCE:1]"); //点击Open //Autoit.Sleep(1000); // //} // //catch (Exception ) // //{ // // Console.WriteLine("open按钮没有点击"); // //} }
public void upLoad() { //Thread.Sleep(3000); //driver.FindElement(By.CssSelector("a.menuBtn_upload")).Click(); //driver.FindElement(By.CssSelector("#a-pw_add > span.icontxt")).Click(); //Thread.Sleep(1000); //Thread x = new Thread(new ThreadStart(Upload_File)); //x.Start(); //Thread.Sleep(1000); //driver.FindElement(By.CssSelector("table.table-pw_next a.btn_upload")).Click(); //Thread.Sleep(2000); ////如果进度元素不是显示100,那么继续上传 //if (driver.FindElement(By.XPath("//[@id='efaf3e61-c983-4dc3-9622-436d51d5a88c']/sapn[3]")).Text.Contains()!=100) //{ //} //下载 Thread.Sleep(1000); //driver.FindElement(By.XPath("//ul[@id='commandList']/li/table/tbody/tr/td/div/span")).Click(); ////driver.FindElement(By.CssSelector("div.fileCommand span.MixiTai_Checkbox")).Click(); ////driver.FindElement(By.XPath("//ul[@id='commandList']/li[1]/table/tbody/tr/td[2]/div/table/tbody/tr[2]/td/span")).Click(); //driver.FindElement(By.XPath("(//input[@value='Open'])")).Click(); ////driver.FindElement(By.CssSelector("a.option_Open")).Click(); //Thread.Sleep(100); ////driver.FindElement(By.CssSelector("div.fileCommand span.MixiTai_Checkbox")).Click(); //driver.FindElement(By.XPath("//ul[@id='commandList']/li/table/tbody/tr/td/div/span")).Click(); //Thread.Sleep(100); //driver.FindElement(By.XPath("(//input[@value='Open'])")).Click(); ////driver.FindElement(By.CssSelector("a.menuBtn_return > span.icontxt")).Click(); //driver.FindElement(By.XPath("//ul[@id='commandList']/li[2]/table/tbody/tr/td[2]/div/table/tbody/tr[2]/td/span")).Click(); //driver.FindElement(By.XPath("(//input[@value='Open'])[2]")).Click(); //driver.FindElement(By.CssSelector("a.menuBtn_downLoad > span.icontxt")).Click(); //driver.FindElement(By.CssSelector("a.menuBtn_downLoad > span.icontxt")).Click(); //driver.FindElement(By.XPath("//div[@id='FilesView']/div[3]/a/span")).Click(); var openFolderTableElement = driver.FindElement( By.CssSelector("table[data-name='Angkor']")); var mouseOverAction = new OpenQA.Selenium.Interactions.Actions(driver); mouseOverAction.MoveToElement(openFolderTableElement); //notice: Actions必须要执行perform mouseOverAction.Perform(); openFolderTableElement.FindElement(By.CssSelector("div.menuBtn a.option_Open")).Click(); Thread.Sleep(1000); var openFileTableElement = driver.FindElement( By.CssSelector("table[data-name='AppCertKitArmSetup.exe']")); var mouseOverAction1 = new OpenQA.Selenium.Interactions.Actions(driver); mouseOverAction1.MoveToElement(openFileTableElement); //notice: Actions必须要执行perform mouseOverAction1.Perform(); openFileTableElement.FindElement(By.CssSelector("div.menuBtn a.option_Open")).Click(); //driver.FindElement(By.LinkText("Download File")).Click(); driver.FindElement(By.CssSelector("a.menuBtn_downLoad")).Click(); Thread.Sleep(1000); var auto = new AutoItX3(); //auto.Send("{BROWSE}"); //Thread.Sleep(1000); //auto.Send("{TAB}"); //auto.Send("{TAB}"); //auto.Send("{ENTER}"); Thread.Sleep(1000); const string widowTitle = "[Class:#32770]"; auto.ControlFocus(widowTitle, "Choose Download Folder:", "[CLASS:Edit; INSTANCE:1]"); auto.Send(@"C:"); auto.ControlClick(widowTitle, "Choose Download Folder", "[CLASS:Button; INSTANCE:1]"); auto.Send("{ENTER}"); Thread.Sleep(5000); //driver.FindElement(By.LinkText("退出")).Click(); }
public void DoUpload(string Filepath) { driver.Navigate().GoToUrl(baseURL + "/v/upload"); try { Thread.Sleep(1000); if (driver.FindElement(By.ClassName("uploadHot")) != null) { loginflag = true; } } catch { } while (!loginflag) { try { Thread.Sleep(1000); driver.FindElement(By.Id("user_name_login")).Clear(); driver.FindElement(By.Id("user_name_login")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("passwd_login")).Clear(); driver.FindElement(By.Id("passwd_login")).SendKeys("613866"); break; } catch (Exception ex) { Console.WriteLine("当前捕捉失败,继续扫描,错误消息为" + ex.Message); } } if (!loginflag) { Console.WriteLine("登陆完成后请敲回车:enter"); Console.ReadLine(); driver.Navigate().GoToUrl(baseURL + "/v/upload"); } IWebElement approve = driver.FindElement(By.ClassName("uploadHot")); new Thread(() => { //while (true) //{ try { //if (fileupflag) break; Thread.Sleep(1000); var Autoit = new AutoItX3(); const string widowTitle = "[Class:#32770]"; Autoit.WinWait(widowTitle, "", 1); Autoit.WinActivate(widowTitle); Autoit.ControlFocus("[Class:#32770]", "", "[CLASS:Edit; INSTANCE:1]"); Autoit.Send(Filepath); Autoit.Sleep(100); Autoit.ControlClick("[Class:#32770]", "Open(O)", "Cancel"); Autoit.Sleep(100); Autoit.Send("!O"); Autoit.Send("{ENTER}", 0); //Thread.CurrentThread.Abort(); } catch (Exception ex) { Console.WriteLine("当前捕捉失败,继续扫描,错误消息为" + ex.Message); } //} //System.Diagnostics.ProcessStartInfo ImgstartInfo = new System.Diagnostics.ProcessStartInfo("fileup.exe"); //ImgstartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //System.Diagnostics.Process.Start(ImgstartInfo); } ).Start(); approve.Click(); fileupflag = true; Thread.Sleep(2000); driver.FindElement(By.Name("memo")).Clear(); driver.FindElement(By.Name("memo")).SendKeys("qqq"); driver.FindElement(By.CssSelector("div.meta-cate.upOriginal > span")).Click(); Thread.Sleep(1000); driver.FindElement(By.LinkText("其他")).Click(); Thread.Sleep(1000); driver.FindElement(By.CssSelector("input.input-mini.meta-tags")).Clear(); driver.FindElement(By.CssSelector("input.input-mini.meta-tags")).SendKeys("qq"); Thread.Sleep(2000); driver.FindElement(By.CssSelector("span.form_btn_text")).Click(); Thread.Sleep(2000); }
public void controlfocus(string title) { //auto.WinSetOnTop(title, "", 1); auto.ControlFocus(title, "", ""); }
public void EnterShareSkill() { GlobalDefinitions.Wait(); ShareSkillButton.Click(); //Checking the right page Assert.AreEqual("ServiceListing", GlobalDefinitions.driver.Title); Base.test = Base.extent.StartTest("On Share Skill page"); //Populate the Excel Sheet Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); //Enter TITLE Title.SendKeys(ExcelLib.ReadData(2, "Title")); //Check Length of Title GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(2, "Title"), "Title"); //Enter Description Description.SendKeys(ExcelLib.ReadData(2, "Description")); GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(2, "Description"), "Description"); //Select Category form dropdown CategoryDropDown.SendKeys(ExcelLib.ReadData(2, "Category")); SubCategoryDropDown.SendKeys(ExcelLib.ReadData(2, "SubCategory")); //Enter tag TxtTags.SendKeys(ExcelLib.ReadData(2, "Tags")); TxtTags.SendKeys(Keys.Enter); //Select service Type IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']")); ServiceTypeOptions.Click(); //Select Location Type IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[1]//div[1]//input[1]")); LocationTypeOption.Click(); //Enter start Date and End date StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate")); EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate")); // Loop for no. of days available,Start time and End time for (int i = 2; i < 9; i++) { for (int j = 2; j < 9; j++) { IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input")); IWebElement EndTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input")); if (i == 2 && j == 2) { GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click(); StartTime.SendKeys("0230PM"); StartTime.SendKeys(Keys.Tab); EndTime.SendKeys("3052PM"); } if (i == 3 && j == 3) { GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click(); StartTime.SendKeys("0530PM"); EndTime.SendKeys("0856PM"); } } } // Select Skill Trade IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]")); //Checking if the radio is selected or not if (!SkillTradeOption.Selected) { SkillTradeOption.Click(); } Boolean status = GlobalDefinitions.driver.FindElement(By.XPath("//input[@type='radio']")).Selected; //To Check Radiobutton is selected or not if (status) { Console.WriteLine("RadioButton is checked"); } else { Console.WriteLine("RadioButton is unchecked"); } //Enter SkillExchange SkillExchange.SendKeys(ExcelLib.ReadData(2, "Skill-Exchange")); SkillExchange.SendKeys(Keys.Enter); //Upload File Using Auto IT WorkSample.Click(); AutoItX3 autoIt = new AutoItX3(); autoIt.WinWait("Open", "File Upload", 1); autoIt.WinActivate("Open", "File Upload"); autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt"); autoIt.Sleep(1000); autoIt.Send("{ENTER}"); // autoIt.Sleep(1000); //Select Active Type IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']")); ActiveOption.Click(); GlobalDefinitions.Wait(); Save.Click(); GlobalDefinitions.Wait(); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills Added Successfully"); //Assert.AreEqual("ServiceListing", GlobalDefinitions.driver.Title); //Assert on category / title / Service Type after adding the skill and displayed on Manage Listing Page string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//td[contains(text(),'Programming & Tech')]")).Text; Console.WriteLine(searchInput1); Assert.AreEqual(searchInput1, ExcelLib.ReadData(2, "Category")); string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//table[@class='ui striped table']//tbody//tr[1]//td[3]")).Text; Console.WriteLine(searchInput2); Assert.AreEqual(searchInput2, ExcelLib.ReadData(2, "Title").TrimEnd()); //string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//table[@class='ui striped table']//tbody//tr[1]//td[5]")).Text; //Assert.AreEqual(searchInput3, ExcelLib.ReadData(2, "ServiceType")); }
// Create a new Property internal void CreateProperty() { Global.ExcelLib.PopulateInCollection(Config.PropertyManagementResource.ExcelPath, "Property"); //Explicit Wait Thread.Sleep(1000); //Click on Owners tab Owners.Click(); //Click Properties option Properties.Click(); //Click on Add New Property button AddPropertybtn.Click(); Thread.Sleep(500); // ************PropertyDetails*************** //Enter Property Name PropertyName.SendKeys(Global.ExcelLib.ReadData(2, "PropertyName")); Thread.Sleep(500); //Click on Property type dropdown PropertyTypeDropdown.Click(); //Select the value from property type dropdown PropertyTypedropdownvalue.Click(); //Enter Description Description.SendKeys(Global.ExcelLib.ReadData(2, "Description")); //Enter Street Number StreetNo.SendKeys(Global.ExcelLib.ReadData(2, "StreetNumber")); //Enter Street Name StreetName.SendKeys(Global.ExcelLib.ReadData(2, "StreetName")); //Enter Suburb Suburb.SendKeys(Global.ExcelLib.ReadData(2, "Suburb")); //Enter City City.SendKeys(Global.ExcelLib.ReadData(2, "City")); //Enter Postcode Postcode.SendKeys(Global.ExcelLib.ReadData(2, "PostCode")); //Enter Region Region.SendKeys(Global.ExcelLib.ReadData(2, "Region")); //Enter Target Rent TargetRent.SendKeys(Global.ExcelLib.ReadData(2, "TargetRent")); Thread.Sleep(1000); //Click on Rent drop down //RentTypeDropdown.Click(); //Select value from Rent dropdown // RentTypeDropdownvalue.Click(); //Enter Land Area LandArea.SendKeys(Global.ExcelLib.ReadData(2, "LandArea")); //Enter Floor Area FloorArea.SendKeys(Global.ExcelLib.ReadData(2, "FloorArea")); //Enter Bedroom Bedrooms.SendKeys(Global.ExcelLib.ReadData(2, "BedRooms")); //Enter Bathroom Bathrooms.SendKeys(Global.ExcelLib.ReadData(2, "BathRooms")); //Enter CarParks Carparks.SendKeys(Global.ExcelLib.ReadData(2, "CarParks")); Thread.Sleep(1000); //Enter Year built YearBuilt.SendKeys(Global.ExcelLib.ReadData(2, "YearBuilt")); // File Upload Approach1: Send Keys /* * FileUploadbtn.SendKeys(@"C:\Users\Shahabuddin\Desktop\Rumana\testiamge.jpg"); * Thread.Sleep(1000); * photo.Click(); */ // File Upload Approach2: AutoIt- Handles windows that do not belong to browser photo.Click(); FileUploadbtn.Click(); AutoItX3 AutoIt = new AutoItX3(); AutoIt.ControlFocus("Open", "", "Edit1"); Thread.Sleep(2000); AutoIt.ControlSetText("Open", "", "Edit1", @"C:\Users\Shahabuddin\Desktop\Rumana\house2_image.jpg"); Thread.Sleep(1000); AutoIt.ControlClick("Open", "", "Button1"); //Click on Next button NextbtnProptertyDetails.Click(); // ************Financialdetails*************** //Enter Purchase Price purchaseprice.SendKeys(Global.ExcelLib.ReadData(2, "PurchasePrice")); //Enter Mortgage Mortgage.SendKeys(Global.ExcelLib.ReadData(2, "Mortgage")); //HomeValue HomeValue.SendKeys(Global.ExcelLib.ReadData(2, "HomeValue")); //Click on Home Value Type drop down HomeValueType.Click(); //Select Home Value type HomeValueTypeSelection.Click(); //Click on Add Repayment button AddRePayment.Click(); //Enter Amount RePaymentAmount.SendKeys(Global.ExcelLib.ReadData(2, "RepaymentAmount")); //Enter RepaymentStartDate RePaymentStartdate.Clear(); RePaymentStartdate.SendKeys("26/05/2018"); Thread.Sleep(500); //Enter RepaymentEndDate RePaymentEnddate.Clear(); RePaymentEnddate.SendKeys("29/06/2018"); Thread.Sleep(500); //Click on Add Expense link AddExpense.Click(); //Enter Expense Amount ExpenseAmount.SendKeys(Global.ExcelLib.ReadData(2, "ExpenseAmount")); // Enter Expense Description ExpenseDescription.SendKeys(Global.ExcelLib.ReadData(2, "ExpenseDescription")); //Enter date for ExpenseDate //ExpenseDateCalender.Clear(); ExpenseDateCalender.SendKeys("30/06/2018"); Thread.Sleep(500); //Click on Next button NextbtnFinanceDetails.Click(); // ************Tenantdetails*************** //Enter TenantEmail TenantEmail.SendKeys(Global.ExcelLib.ReadData(2, "TenantEmail")); //Click on IsmainTenant IsMainTenant.Click(); //Select IsmainTenant IsMainTenantSelectYes.Click(); //Enter Tenant FirstName TenantFirstName.SendKeys(Global.ExcelLib.ReadData(2, "TenantFirstName")); //Enter Tenant LastName TenantLastName.SendKeys(Global.ExcelLib.ReadData(2, "TenantLastName")); //Enter Tenant StartDate TenantStartDate.Clear(); TenantStartDate.SendKeys("20/06/2018"); //Enter Tenant EndDate TenantEndDate.Clear(); TenantEndDate.SendKeys("30/09/2018"); //Enter TenantRentAmount TenantRentAmount.SendKeys(Global.ExcelLib.ReadData(2, "TenantRentAmount")); Thread.Sleep(1000); //Click on PaymentfrequencyDropdown //PaymentFrequencydropdown.Click(); //Select Monthly from PaymentFrequencyDropdown //PaymentFrequencydropdownMonth.Click(); //TenantPaymentStartdate TenantPaymentStartdate.Clear(); TenantPaymentStartdate.SendKeys("10/07/2018"); Thread.Sleep(1000); //Click on PaymentDueDay drop down //PaymentDueDayDropdown.Click(); //Select PaymentDueDay value //PaymentDueDayDropdownvalue.Click(); //Click on AddNewLiabilityLink AddNewLiability.Click(); //Click on LiabilityNameDropDown // LiabilityNameDropdown.Click(); //Select Liability Name Dropdown value //LiabilityNameDropdownInsurance.Click(); //Enter LiabilityAmount //LiabilityAmount.SendKeys(Global.ExcelLib.ReadData(2,"LiabilityAmount")); try { Assert.IsTrue(SavePropertyButton.Displayed); } catch (Exception e) { Console.Write(e); } //Click on Save button SavePropertyButton.Click(); //Add Property Verification //Click on Owners tab Owners.Click(); //Click Properties option Properties.Click(); string msg1 = Global.GlobalDefinition.driver.FindElement(By.XPath("//*[@id='main-content']/section/div[1]/div/div[3]/div/div[1]/div/div/div[2]/div[1]/div[1]/a/h3")).Text; string Actmsg = Global.ExcelLib.ReadData(2, "CreatePropertyVerification"); Thread.Sleep(2000); if (msg1 == Actmsg) { Global.Base.test.Log(LogStatus.Pass, "Test Passed, Record has been created successfully"); Global.SaveScreenShotClass.SaveScreenshot(Global.GlobalDefinition.driver, "PropertyListAdded"); } else { Global.Base.test.Log(LogStatus.Pass, "Test Failed, Record has not created"); } }
internal void EnterShareSkill() { //Calling wait method GenericWait.ElementExists(GlobalDefinitions.driver, "Name", "title", 8); //Entering the "Title" Title.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); //Validating Title GlobalDefinitions.TextDataFieldValidation("Title", GlobalDefinitions.ExcelLib.ReadData(2, "Title"), Title.GetAttribute("value")); //Entering the "Description" Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); //Validating Description GlobalDefinitions.TextDataFieldValidation("Description", GlobalDefinitions.ExcelLib.ReadData(2, "Description"), Description.Text); //Selecting Category HelperCallingMethods.SelectingDropdown(CategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Validating Category selection GlobalDefinitions.DropDownDataValidation("Category", CategoryDropDown, GlobalDefinitions.ExcelLib.ReadData(2, "Category")); //Selecting Sub-Category HelperCallingMethods.SelectingDropdown(SubCategoryDropDown, "SelectByText", GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Validating Sub-Category selection GlobalDefinitions.DropDownDataValidation("SubCategory", SubCategoryDropDown, GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); //Entering Tag Tags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags") + "\n"); //GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//span[@class='ReactTags__tag']"), 5); GenericWait.ElementIsVisible(GlobalDefinitions.driver, "XPath", "//span[@class='ReactTags__tag']", 6); string EnteredTagTxt = TagReact.Text; //Validating entered Tag GlobalDefinitions.TextDataFieldValidation("Tags", GlobalDefinitions.ExcelLib.ReadData(2, "Tags"), EnteredTagTxt.Remove(EnteredTagTxt.Length - 1, 1)); // Select the Service type radio button HelperCallingMethods.SelectingRadiobutton("//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']", "serviceType", GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType")); //Validating Service Type Radiobutton selection GlobalDefinitions.RadiobuttonValidation("ServiceTypeRadioButtons", "//form/div[5]/div[@class='twelve wide column']/div/div[@class='field']", "serviceType", GlobalDefinitions.ExcelLib.ReadData(2, "ServiceType")); // Select the Location type radio button HelperCallingMethods.SelectingRadiobutton("//form/div[6]/div[@class='twelve wide column']/div/div[@class = 'field']", "locationType", GlobalDefinitions.ExcelLib.ReadData(2, "LocationType")); //Validating Location Type Radiobutton selection GlobalDefinitions.RadiobuttonValidation("LocationTypeRadioButtons", "//form/div[6]/div[@class='twelve wide column']/div/div[@class = 'field']", "locationType", GlobalDefinitions.ExcelLib.ReadData(2, "LocationType")); //Selecting date and time HelperCallingMethods helperCallingMethods = new HelperCallingMethods(); helperCallingMethods.SelectingDateAndTime(); //Validating Start Date, End Date, Start Time,End Time GlobalDefinitions.TextDataFieldValidation("Start Date", DateTime.Today.ToString("dd/MM/yyyy"), DateTime.Parse(StartDateDropDown.GetAttribute("value")).ToString("dd/MM/yyyy")); GlobalDefinitions.TextDataFieldValidation("End Date", DateTime.Today.AddDays(14).ToString("dd/MM/yyyy"), DateTime.Parse(EndDateDropDown.GetAttribute("value")).ToString("dd/MM/yyyy")); GlobalDefinitions.TextDataFieldValidation("Start Time", GlobalDefinitions.ExcelLib.ReadData(2, "Starttime"), DateTime.Parse(StartTime.GetAttribute("value")).ToString("hh:mmtt")); GlobalDefinitions.TextDataFieldValidation("End Time", GlobalDefinitions.ExcelLib.ReadData(2, "Endtime"), DateTime.Parse(EndTime.GetAttribute("value")).ToString("hh:mmtt")); //Selecting SkillTrade or Credit radio button HelperCallingMethods.SelectingRadiobutton("//form/div[8]/div[@class='twelve wide column']/div/div[@class = 'field']", "skillTrades", GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade")); string SkillTradeValue = GlobalDefinitions.ExcelLib.ReadData(2, "SkillTrade"); //Enter Skill-Exchange or Credit if (SkillTradeValue == "Skill-exchange") { SkillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange") + "\n"); //Validating entered Skill exchange value GlobalDefinitions.TextDataFieldValidation("SkillExchange", GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange"), SkillExchangeTag.Text.Remove(SkillExchangeTag.Text.Length - 1, 1)); } else if (SkillTradeValue == "Credit") { CreditAmount.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); //Validating entered Credit value GlobalDefinitions.TextDataFieldValidation("Credit", GlobalDefinitions.ExcelLib.ReadData(2, "Credit"), CreditAmount.GetAttribute("value")); } //Uploading file for Work Sample WorkSamples.Click(); AutoItX3 autoIt = new AutoItX3(); autoIt.WinWait("Open", "File Upload", 1); autoIt.WinActivate("Open", "File Upload"); autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); autoIt.Sleep(1000); //autoIt.Send(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory()) + "\\FileUploadTest.txt")); autoIt.Send(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\FileUploadTest.txt")); autoIt.Sleep(1000); autoIt.Send("{ENTER}"); autoIt.Sleep(2000); string[] FileSplitText = WorkSampleFileName.Text.Split('.'); string FileSplitTextName = FileSplitText[0]; //Validating uploaded worksample GlobalDefinitions.TextDataFieldValidation("WorkSamples", FileSplitTextName.ToString(), GlobalDefinitions.ExcelLib.ReadData(2, "FileName").ToString()); //selecting Active radio button HelperCallingMethods.SelectingRadiobutton("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']", "isActive", GlobalDefinitions.ExcelLib.ReadData(2, "Active")); //Validating Active radio button selection GlobalDefinitions.RadiobuttonValidation("Active", "//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']", "isActive", GlobalDefinitions.ExcelLib.ReadData(2, "Active")); //Clicking Save button Save.Click(); string img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Share skill added"); }
public void SetEndUseCode(string windowTitle) { _Au3Lib.ControlFocus(windowTitle, "", "[NAME:cboEndUse]"); _Au3Lib.Send("2"); }
public void BookJob(int numberOfPhases) { _Au3Lib.Opt("WinTitleMatchMode", 2); //determines if Order Log is open. Terminates program if it isn't. string windowTitle = "Order Entry"; _Au3.CheckIfWindowExists(windowTitle); string currentJobName = _Au3Lib.ControlGetText(windowTitle, "", "[NAME:txtOrderName]"); _Au3.InputProjectInfo(windowTitle, currentJobName, numberOfPhases); _Au3Lib.ControlFocus(windowTitle, "", "[NAME:cboPriceType]"); string division = _Au3.GetDivision(); _Au3.GetPriceType(division); _Au3.SetEndUseCode(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveProject]", "left", 1); _Au3.DetermineControlVisibility("[NAME:PictureBoxHappy]", windowTitle); //Phasings/Buildings Screen (for Prebook) _Au3Lib.ControlClick(windowTitle, "", "[NAME:ProjectFeaturesTab]", "left", 1, 116, 12); _Au3.DetermineControlVisibility("[NAME:btnSaveBldgInfo]", windowTitle); _Au3Lib.WinActivate(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:FpSpread_Bldg]", "left", 1, 293, 52); //Adds 1,000 to each subsequent category, choosing the first value based on division (hard-coded at the moment) _Au3.InputBuildingInfoWeightDollars(division); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveBldgInfo]"); _Au3.DetermineControlVisibility("[NAME:picboxHappy_BldgInfo]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnPrebookFromBldg]"); _Au3.DetermineControlVisibility("[NAME:btnSaveMultiPhasesToDB]", windowTitle); _Au3.DisableEmail(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveMultiPhasesToDB]"); _Au3Lib.Sleep(1000); //transfer $$ and ## to Phases _Au3Lib.ControlClick(windowTitle, "", "[NAME:ProjectFeaturesTab]", "left", 116, 12); _Au3.DetermineControlVisibility("[NAME:btnSaveBldgInfo]", windowTitle); _Au3Lib.WinActivate(windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:FpPhaseTool]", "left", 1, 34, 27); if (numberOfPhases == 1) { _Au3Lib.Send("A{TAB}1{TAB}100{ENTER}"); _Au3Lib.Sleep(250); } else if (numberOfPhases == 2) { _Au3Lib.Send("A{TAB}1{TAB}70{ENTER}"); _Au3Lib.Sleep(250); _Au3Lib.Send("{DOWN}30+{TAB}1+{TAB}B{ENTER}"); _Au3Lib.Sleep(250); } _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveBldgInfo]"); _Au3.DetermineControlVisibility("[NAME:picboxHappy_BldgInfo]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnTsfrToPhases]"); _Au3.DetermineControlVisibility("[NAME:btnSaveMultiPhasesToDB]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveMultiPhasesToDB]"); //Project Dates Screen _Au3.DetermineControlVisibility("[NAME:btnSaveProjectDates2]", windowTitle); string[] arraycoordinates = _Au3.GetCoordinatesForProjectDates(division).Split(','); int[] coordinates = new int[arraycoordinates.Length]; //for (int i = 0; i < arraycoordinates.Length; i++) //{ // coordinates[i] = Integer.parseInt(arraycoordinates[i]); //} //$Coords = StringSplit(Call("GetCoords",$Division), ",") _Au3Lib.ControlClick(windowTitle, "", "[NAME:FpSpreadProjDates]", "LEFT", 1, 304, 366); DateTime currentDate = DateTime.Now; //string format = "m/d/yy"; string formattedDate = currentDate.ToShortDateString(); _Au3Lib.Send(formattedDate); _Au3Lib.Send("{ENTER}"); _Au3Lib.ControlClick(windowTitle, "", "[NAME:btnSaveProjectDates2]"); _Au3.DetermineControlVisibility("[NAME:picboxHappy_Dates]", windowTitle); //Making phases Active _Au3Lib.ControlClick(windowTitle, "", "[NAME:ProjectFeaturesTab]", "", 1, 118, 9); _Au3.DetermineControlVisibility("[NAME:btnSaveBldgInfo]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:TabControl4]", "", 1, 171, 12); _Au3.DetermineControlVisibility("[NAME:chkBookTonsDoll_ViewTons]", windowTitle); _Au3Lib.ControlClick(windowTitle, "", "[NAME:lvwSalesSummary]", "right", 1, 180, 70); _Au3Lib.Sleep(250); _Au3Lib.Send("{DOWN 4}"); _Au3Lib.Send("{ENTER}"); _Au3Lib.Sleep(3000); if (_RunSettings.NumberOfPhases == 2) { _Au3Lib.ControlClick(windowTitle, "", "[NAME:lvwSalesSummary]", "right", 1, 180, 138); _Au3Lib.Sleep(250); _Au3Lib.Send("{DOWN 4}"); _Au3Lib.Send("{ENTER}"); } }
public void Listings() { GlobalDefinitions.Wait(); ManageListingsLink.Click(); //Checking the right page Assert.AreEqual("ListingManagement", GlobalDefinitions.driver.Title); Base.test = Base.extent.StartTest("On Share Manage Listing page"); edit.Click(); //Populate the Excel Sheet Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "ShareSkill"); Title.SendKeys(ExcelLib.ReadData(3, "Title")); GenericMethods.CheckLength(4, 100, ExcelLib.ReadData(3, "Title"), "Title"); Description.SendKeys(ExcelLib.ReadData(3, "Description")); GenericMethods.CheckLength(4, 600, ExcelLib.ReadData(3, "Description"), "Description"); CategoryDropDown.SendKeys(ExcelLib.ReadData(3, "Category")); SubCategoryDropDown.SendKeys(ExcelLib.ReadData(3, "SubCategory")); TxtTags.SendKeys(ExcelLib.ReadData(3, "Tags")); TxtTags.SendKeys(Keys.Enter); IWebElement ServiceTypeOptions = GlobalDefinitions.driver.FindElement(By.XPath("//div[5]//div[2]//div[1]//div[2]//div[1]//input[1]")); ServiceTypeOptions.Click(); IWebElement LocationTypeOption = GlobalDefinitions.driver.FindElement(By.XPath("//div[6]//div[2]//div[1]//div[2]//div[1]//input[1]")); LocationTypeOption.Click(); StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Startdate")); EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "Enddate")); for (int i = 2; i < 9; i++) { for (int j = 2; j < 9; j++) { IWebElement StartTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input")); IWebElement EndTime = GlobalDefinitions.driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input")); if (i == 2 && j == 2) { GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(@class,'twelve wide column')]//div[2]//div[1]//div[1]//input[1]")).Click(); StartTime.SendKeys("0230PM"); StartTime.SendKeys(Keys.Tab); EndTime.SendKeys("3052PM"); } if (i == 3 && j == 3) { GlobalDefinitions.driver.FindElement(By.XPath("//div[3]//div[1]//div[1]//input[1]")).Click(); StartTime.SendKeys("0530PM"); EndTime.SendKeys("0856PM"); } } } IWebElement credit = GlobalDefinitions.driver.FindElement(By.XPath("//div[8]//div[2]//div[1]//div[2]//div[1]//input[1]")); if (!credit.Selected) { credit.Click(); CreditAmount.SendKeys("9"); } WorkSample.Click(); AutoItX3 autoIt = new AutoItX3(); autoIt.WinWait("Open", "File Upload", 1); autoIt.WinActivate("Open", "File Upload"); autoIt.ControlFocus("Open", "File Upload", "[CLASS:Edit; INSTANCE:1]"); autoIt.Send(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..")) + "\\Test.txt"); //autoIt autoIt.Send("{ENTER}"); autoIt.Sleep(1000); IWebElement ActiveOption = GlobalDefinitions.driver.FindElement(By.XPath("//form/div[10]/div[@class='twelve wide column']/div/div[@class = 'field']")); ActiveOption.Click(); GlobalDefinitions.Wait(); Save.Click(); GlobalDefinitions.Wait(); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Skills edited succesfully"); string searchInput1 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[2]")).Text; Assert.AreEqual(searchInput1, ExcelLib.ReadData(3, "Category")); string searchInput2 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[3]")).Text; Assert.AreEqual(searchInput2, ExcelLib.ReadData(3, "Title")); string searchInput3 = GlobalDefinitions.driver.FindElement(By.XPath("//tbody//tr[1]//td[5]")).Text; Assert.AreEqual(searchInput3, ExcelLib.ReadData(3, "ServiceType")); }
public static void AutoitHelper(string filePath) { //selenium 无法直接操作windows窗口,调用autoit来模拟用户操作 var Autoit = new AutoItX3(); const string widowTitle = "[Class:#32770]"; //上传窗口的类名:Class:#327700 Autoit.WinWait(widowTitle, "File Upload", 1); //暂停执行脚本,直到上传对话框出现 Autoit.WinActivate(widowTitle, "File Upload"); //激活上传窗口 Autoit.ControlFocus(widowTitle, "File Upload", "[CLASS:Edit; INSTANCE:1]"); //控制焦点在输入框上 //Autoit.ControlSetText(widowTitle, "", "[CLASS:Edit; INSTANCE:1]", "D:\\temp\\Desert.jpg"); //这行代码是另一个输入路径的方法 Autoit.Send(filePath); //输入文件路径 Microsoft Toolkit.exe Autoit.Sleep(1000); Autoit.Send("{ENTER}"); Thread.Sleep(500); }