public static void BeforeTestRun()
 {
     Driver          = driver;
     DriverActions   = driverActions;
     SeleniumActions = seleniumActions;
     SeleniumWaits   = seleniumWaits;
     SeleniumVerify  = seleniumVerify;
     Report          = report;
     Report.InitializeReport();
 }
Exemple #2
0
 /// <summary>
 /// Verifies message on browser alert.
 /// </summary>
 /// <param name="msg"> message that has to be verified.</param>
 public void VerifyBrowserAlertMsg(string msg, WaitType waitType)
 {
     try
     {
         SeleniumWaits   seleniumWaits   = new SeleniumWaits();
         SeleniumActions seleniumActions = new SeleniumActions();
         seleniumWaits.WaitForAlertToBePresent(waitType);
         string alertMsg = seleniumActions.GetAlertText();
         Assert.AreEqual(alertMsg, msg);
         seleniumActions.AcceptAlert();
     }
     catch (Exception e)
     {
         CustomExceptionHandler.CustomException(e, "Could not find browser level alert message because of an Exception: ");
     }
 }
Exemple #3
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");
 }