Beispiel #1
0
        /// <summary>
        /// Verifies wheather a PDF resource contain the specified text or not.
        /// </summary>
        /// <param name="textToVerify"> Text that has to verified.</param>
        /// <param name="pdfLink"> URL fo PDF resource (Optional). Takes current url if not specified. If you are passing this parameter then you need not pass {pdfFilePath}.</param>
        /// <param name="pdfFilePath">Absolute file path of pdf resource (Optional). If you are passing this parameter then you need not pass {pdfLink}.</param>
        /// <returns>True if text specified is present in the pdf document, false otherwise.</returns>
        public bool IsPdfContainsText(string textToVerify, string pdfLink = "", string pdfFilePath = "")
        {
            string filePath;

            try
            {
                SeleniumWaits seleniumWaits = new SeleniumWaits();
                seleniumWaits.WaitForPageLoad();

                if (string.IsNullOrEmpty(pdfFilePath))
                {
                    filePath = (new FileUtils()).DownloadFile(pdfLink);
                }
                else
                {
                    filePath = pdfFilePath;
                }

                PdfReader     reader = new PdfReader(filePath);
                StringBuilder text   = new StringBuilder();

                for (int i = 1; i <= reader.NumberOfPages; i++)
                {
                    text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
                }

                reader.Close();
                Console.WriteLine(text);
                return(text.ToString().Contains(textToVerify));
            }
            catch (Exception e)
            {
                CustomExceptionHandler.CustomException(e);
            }
            return(false);
        }
 public void ClickOnGoogleSearchButton()
 {
     SeleniumActions.Click(GoogleSearchButton);
     SeleniumWaits.WaitForPageLoad();
 }
 public void NavigateToGoogleHomePage()
 {
     Driver.Url = ConfigurationManager.AppSettings["AppUrl"];
     SeleniumWaits.WaitForPageLoad();
     SeleniumVerify.ExactPageTitle("Google");
 }