private AutoItData getAutoItData() { AutoItData data = new AutoItData(); data.AutoItExecutableName = "AutoIt3.exe"; data.DeploymentDirectory = AppDomain.CurrentDomain.BaseDirectory; data.UploadImageScriptName = "UploadFile.au3"; data.UploadImageInIEScriptName = "UploadFileInIE.au3"; data.UploadImageInChromeScriptName = "UploadFileInChrome.au3"; return(data); }
/// <summary> /// Upload File using AutoIt (Old Framework Method adapted to New Framework) /// </summary> /// <param name="autoItData">AutoIt Data Object Instance</param> /// <param name="uploadButtonOrLink">Upload button or Link which when clicked gives the File Upload dialog</param> public void UploadFile(AutoItData autoItData, WebElementWrapper uploadButtonOrLink) { //var autoItExecutablePath = combinePathAndVerify(TestDeploymentDir, "AutoIt3.exe"); var autoItExecutablePath = CombinePathAndVerifyFileExists(autoItData.DeploymentDirectory, autoItData.AutoItExecutableName); var autoItScriptPath = ""; if (this.TestConfiguration.BrowserName == BrowserType.INTERNET_EXPLORER) { autoItScriptPath = CombinePathAndVerifyFileExists(autoItData.DeploymentDirectory, autoItData.UploadImageInIEScriptName); } else if (this.TestConfiguration.BrowserName == BrowserType.CHROME) { autoItScriptPath = CombinePathAndVerifyFileExists(autoItData.DeploymentDirectory, autoItData.UploadImageInChromeScriptName); } else { autoItScriptPath = CombinePathAndVerifyFileExists(autoItData.DeploymentDirectory, autoItData.UploadImageScriptName); } var pathofFileToBeUploaded = CombinePathAndVerifyFileExists(autoItData.DeploymentDirectory, autoItData.FileNameToBeUploaded); Action doBeforeUpload = () => { System.Threading.Thread.Sleep(1000); uploadButtonOrLink.Wait(1).Click(); }; var processStartInfo = new ProcessStartInfo() { FileName = autoItExecutablePath, WorkingDirectory = autoItData.DeploymentDirectory, Arguments = string.Format("{0} {1}", autoItScriptPath, pathofFileToBeUploaded) }; RunAutoItProcess(processStartInfo, doBeforeUpload, "Auto it upload file script failed to terminate within 30 seconds"); }
/// <summary> /// Uploads the required file inside the Editor /// </summary> /// <param name="editor">Instance of SeleniumUITests.Main.Library.Assess.Components.TeacherInstructionEditor</param> /// <param name="autoItData">Instance of the AutoIt Data Object</param> /// <param name="fileUploadTree">Dictionary containing the File Upload Details for the Scenario. Inner Dictionary Uses Question Content, Answer Content, Teacher or Student Explanation as Key. /// Inner Dictionary uses Image File Name to be uploaded as the Value. Outer Dictionary Uses True or False (boolean) as Key to indicate WithFileUpload or WithoutFileUpload.</param> /// <param name="fieldToUploadTheFileTo">string value of the Field on the form concerned to which the file needs to be uploaded</param> public void DoFileUpload(TeacherInstructionEditor editor, AutoItData autoItData, Dictionary <bool, Dictionary <string, string> > fileUploadTree, string fieldToUploadTheFileTo) { if (fileUploadTree != null && fileUploadTree.ContainsKey(true)) { var fileNameDictionary = new Dictionary <string, string>(); fileUploadTree.TryGetValue(true, out fileNameDictionary); if (fileNameDictionary != null && fileNameDictionary.ContainsKey(fieldToUploadTheFileTo)) { editor.Form.DoFileUpload = true; autoItData.FileNameToBeUploaded = fileNameDictionary[fieldToUploadTheFileTo]; editor.Data = autoItData; } else { editor.Form.DoFileUpload = false; } } else { editor.Form.DoFileUpload = false; } }