/// <summary> /// Uploads and translates supported documents /// </summary> /// <param name="fileList"></param> /// <param name="DocTranslate"></param> /// <returns></returns> private Stack <string> TranslateDocument(string[] fileList, DocumentTranslatePage DocTranslate) { Stack <string> failedDocuments = new Stack <string>(); foreach (string name in fileList) { if (!name.Contains("Thumbs")) { try { DocTranslate.inputDocUpload.SendKeys(name); var TheElement = WaitElement.WaitGivenSeconds(DocTranslate.btnTranslateFinderOrError, 70); if (TheElement.GetAttribute("class").Contains("infoMessageBox")) { failedDocuments.Push(name + ": " + TheElement.Text); continue; } DocTranslate.btnTranslate.Click(); var TheElement2 = WaitElement.WaitGivenSeconds(DocTranslate.btnDownloadFinderOrError, 70); if (TheElement2.GetAttribute("class").Contains("infoMessageBox")) { failedDocuments.Push(name + ": " + TheElement2.Text); continue; } DocTranslate.btnDownload.Click(); Thread.Sleep(3000); //pause while file is being downloaded } catch (WebDriverTimeoutException) { failedDocuments.Push(name + ": " + "Failed to translate in 70 seconds"); } DocTranslate.btnCancel.Click(); } } return(failedDocuments); }
public void TranslateSupportedFilesDefaultSystem() { DocumentTranslatePage docPageObj = new DocumentTranslatePage(); WaitElement.Wait(docPageObj.waitDocumentInput); Stack <string> failedDocuments = TranslateDocument(PresidencyProperties.filesDefault, docPageObj); if (failedDocuments.Count > 0) { Assert.Fail(string.Join(", \n", failedDocuments)); } }
public void CheckErrorUnsupportedFile() { DocumentTranslatePage docPageObj = new DocumentTranslatePage(); WaitElement.Wait(docPageObj.waitDocumentInput); docPageObj.inputDocUpload.SendKeys(TestData.fileUnsupported); WaitElement.Wait(docPageObj.waitError); if (docPageObj.msgError.Text.Contains("is not recognized")) { foreach (string format in PresidencyProperties.supportedFileFormats) { if (!docPageObj.msgError.Text.Contains(format)) { Assert.Fail("The list of supported files should contain " + format); } } } else { Assert.Fail("There was no error message or the message text was incorrect"); } }