예제 #1
0
        private void SubmitDetails(bool valid, ContactUsViewModel toSend)
        {
            IWebElement eleForm = browserSpecificDriver.FindElement(By.Id("aspnetForm"));

            if (eleForm == null || (eleForm != null && eleForm.TagName.ToLower() != "form"))
            {
                Assert.Fail(string.Format("Unable to locate Contact Us form: {0}", "aspnetForm"));
            }

            IWebElement eleName    = eleForm.FindElement(By.Id("ctl00_MainContent_NameBox"));
            IWebElement eleMessage = eleForm.FindElement(By.Id("ctl00_MainContent_MessageBox"));
            IWebElement eleEmail   = eleForm.FindElement(By.Id("ctl00_MainContent_EmailBox"));
            IWebElement eleSend    = eleForm.FindElement(By.Id("ctl00_MainContent_SendButton"));

            if (eleName != null && eleEmail != null & eleMessage != null && eleSend != null)
            {
                eleName.SendKeys(toSend.Name);
                eleEmail.SendKeys(toSend.Email);
                eleMessage.SendKeys(toSend.Message);

                // Added wait for JS validation to kick in as, the page submits despite invalid email address.
                Thread.Sleep(500);

                IWebElement eleInvalidEmailSpan = eleForm.FindElement(By.Id("ctl00_MainContent_revEmailAddress"));
                string      styleValue          = eleInvalidEmailSpan.GetAttribute("style");
                if (valid && styleValue.ToLower().Contains("visibility: visible"))
                {
                    Assert.Fail("Javascript Validation for invalid email failed.");
                }

                eleSend.Click();
            }
            else
            {
                Assert.Fail(string.Format("One or more elements missing from the form: {0}", "aspnetForm"));
            }
        }
 public void OnSubmitting_ContactUs_ShouldSubmitWithCorrectValues()
 {
     ContactUsViewModel toSend = new ContactUsViewModel() { Name = "j.Bloggs 6", Email = "*****@*****.**", Message = "please contact me I want to find out more" };
     contactUsTestTemplate.SubmitValidDetails(toSend);
 }
 public void OnSubmitting_ContactUs_ShouldFailForInvalidEmailValue()
 {
     ContactUsViewModel toSend = new ContactUsViewModel() { Name = "J Name", Email = "j.Bloggsqaworks.com", Message = "a message" };
     contactUsTestTemplate.SubmitInvalidDetails(toSend);
 }
예제 #4
0
 public void SubmitValidDetails(ContactUsViewModel toSend)
 {
     SubmitDetails(true, toSend);
 }
예제 #5
0
 public void SubmitInvalidDetails(ContactUsViewModel toSend)
 {
     SubmitDetails(false, toSend);
 }