コード例 #1
0
 /// <summary>
 /// Click Action Wrapper Method
 /// </summary>
 /// <param name="element">IWebElement Object</param>
 /// <param name="report">TestReporting Object</param>
 /// <param name="elementName">Web Element Name</param>
 public static void Click(this IWebElement element, TestReporting report, string elementName)
 {
     if (element.Displayed && element.Enabled)
     {
         element.Click();
         report.SetStepStatusPass($"Clicked on the element [{elementName}].");
     }
     else
     {
         report.SetStepStatusError($"Element [{elementName}] is not displayed");
         throw new Exception($"Element [{elementName}] is not displayed");
     }
 }
コード例 #2
0
 /// <summary>
 /// Launch - GoToUrl Wrapper Method
 /// </summary>
 /// <param name="driver">IWebDriver Object</param>
 /// <param name="report">TestReporting Object</param>
 /// <param name="url">Web URL String</param>
 public static void LaunchUrl(this IWebDriver driver, TestReporting report, string url)
 {
     try
     {
         driver.Navigate().GoToUrl(url);
         report.SetStepStatusPass($"URL [{url}] launched successfully.");
     }
     catch (Exception e)
     {
         report.SetStepStatusError(e.Message);
         throw new Exception(e.Message);
     }
 }
コード例 #3
0
 /// <summary>
 /// SendKeys Action Wrapper Method
 /// </summary>
 /// <param name="element">IWebElement Object</param>
 /// <param name="report">TestReporting Object</param>
 /// <param name="value">Ttext Input Value String</param>
 /// <param name="elementName">Web Element Name</param>
 public static void SendKeys(this IWebElement element, TestReporting report, string value, string elementName)
 {
     try
     {
         element.SendKeys(value);
         report.SetStepStatusPass($"SendKeys value [{value}] to  element [{elementName}].");
     }
     catch (Exception e)
     {
         report.SetStepStatusError(e.Message);
         throw new Exception(e.Message);
     }
 }
コード例 #4
0
 /// <summary>
 /// Method to Validate the Sent Email's Attachment Name Text.
 /// </summary>
 /// <param name="driver">IWebDriver Object</param>
 /// <param name="report">TestReporting Class Object</param>
 /// <param name="attachmentFileName">Attachment File Name String</param>
 public static void ValidateAttachmentNameTextElement(this IWebDriver driver, TestReporting report, string attachmentFileName)
 {
     try
     {
         Assert.True(driver.FindElement(By.XPath("//*[text()='" + attachmentFileName + "']")).Displayed);
         report.SetStepStatusPass("Email's Attachment Name Element Validated as: " + attachmentFileName);
     }
     catch (Exception e)
     {
         report.SetStepStatusFail("Email's Attachment Name Element Validation Failed.");
         report.AddTestFailureScreenshot(SeleniumKeywordActions.ScreenCaptureAsBase64String(driver));
     }
 }
コード例 #5
0
 /// <summary>
 /// Method to Validate the Sent Email's Subject Line Text.
 /// </summary>
 /// <param name="driver">IWebDriver Object</param>
 /// <param name="report">TestReporting Class Object</param>
 /// <param name="subjectLineText">Subject Line Text String</param>
 public static void ValidateSubjectLineTextElement(this IWebDriver driver, TestReporting report, string subjectLineText)
 {
     try
     {
         Assert.True(driver.FindElement(By.XPath("//h2[contains(text(),'" + subjectLineText + "')]")).Displayed);
         report.SetStepStatusPass("Email's Subject Line Element Validated as: " + subjectLineText);
     }
     catch (Exception e)
     {
         report.SetStepStatusFail("Email's Subject Line Element Validation Failed.");
         report.AddTestFailureScreenshot(SeleniumKeywordActions.ScreenCaptureAsBase64String(driver));
     }
 }
コード例 #6
0
 /// <summary>
 /// Method to Validate the Sent Email's Label As 'Social'
 /// </summary>
 /// <param name="driver">IWebDriver Object</param>
 /// <param name="report">TestReporting Class Object</param>
 public static void ValidateSocialLabelElement(this IWebDriver driver, TestReporting report)
 {
     try
     {
         Assert.True(driver.FindElement(By.XPath("//*[@name='^smartlabel_social']")).Displayed);
         report.SetStepStatusPass("Email's label Validated as : 'Social'");
     }
     catch (Exception e)
     {
         report.SetStepStatusFail("Email's Label Validation Failed.");
         report.AddTestFailureScreenshot(SeleniumKeywordActions.ScreenCaptureAsBase64String(driver));
     }
 }
コード例 #7
0
        /// <summary>
        /// Clear Action Wrapper Method
        /// </summary>
        /// <param name="element">IWebElement Object</param>
        /// <param name="report">TestReporting Object</param>
        /// <param name="elementName">Web Element Name</param>
        public static void Clear(this IWebElement element, TestReporting report, string elementName)
        {
            element.Clear();

            if (element.Text.Equals(string.Empty))
            {
                report.SetStepStatusPass($"Cleared element [{elementName}] content.");
            }
            else
            {
                report.SetStepStatusError($"Element [{elementName}] content is not cleared. Element value is [{element.Text}]");
                throw new Exception($"Element [{elementName}] content is not cleared.");
            }
        }
コード例 #8
0
 /// <summary>
 /// Function to Verify Text Assertion
 /// </summary>
 /// <param name="report">TestReporting Object</param>
 /// <param name="expectedText">Expected Text String</param>
 /// <param name="actualText">Actual Text String</param>
 /// <param name="stepDescription">Test Step Description</param>
 public static void VerifyText(TestReporting report, string expectedText, string actualText, string stepDescription)
 {
     try
     {
         Assert.True(expectedText == actualText);
         report.SetStepStatusPass("Assertion Passed for Condition : " + stepDescription
                                  + "<br>Expected Text: " + expectedText + "<br>"
                                  + "Actual Text:" + actualText);
     }
     catch (Exception e)
     {
         report.SetStepStatusFail("Assertion Failed for Condition : " + stepDescription
                                  + "<br>Expected Text: " + expectedText + "<br>"
                                  + "Actual Text:" + actualText);
     }
 }