Exemplo n.º 1
0
        public void VerifyTabbingOrder(string topicToSelect1, string topicToSelect2, string topicToSelect3)
        {
            HeaderLogo.SendKeys(Keys.Tab);
            var feedbackLink = Driver.SwitchTo().ActiveElement();

            feedbackLink.SendKeys(Keys.Tab);
            var topic1 = Driver.SwitchTo().ActiveElement();

            Assert.IsTrue(topic1.Text.Contains(topicToSelect1));
            topic1.SendKeys(Keys.Enter);
            topic1 = Driver.SwitchTo().ActiveElement();
            topic1.SendKeys(Keys.Tab);
            var topic2 = Driver.SwitchTo().ActiveElement();

            Assert.IsTrue(topic2.Text.Contains(topicToSelect2));
            topic2.SendKeys(Keys.Enter);
            topic2 = Driver.SwitchTo().ActiveElement();
            topic2.SendKeys(Keys.Tab);
            var topic3 = Driver.SwitchTo().ActiveElement();

            Assert.IsTrue(topic3.Text.Contains(topicToSelect3));
            topic3.SendKeys(Keys.Enter);

            QuestionPage questionPage = new QuestionPage(Driver);

            questionPage.VerifyQuestionPageLoaded();
        }
Exemplo n.º 2
0
 public void VerifyLayoutPagePresent()
 {
     Assert.IsTrue(Header.Displayed);
     Assert.IsTrue(HeaderLogo.Displayed);
     Assert.AreEqual(_headerLogoTitle, HeaderLogo.GetAttribute("title"));
     Assert.IsTrue(Footer.Displayed);
 }
Exemplo n.º 3
0
        public void VerifyTabbingOrder(int age)
        {
            HeaderLogo.SendKeys(Keys.Tab);
            var feedbackLink = Driver.SwitchTo().ActiveElement();

            feedbackLink.SendKeys(Keys.Tab);
            var maleButton = Driver.SwitchTo().ActiveElement();

            maleButton.SendKeys(Keys.Space);
            maleButton.SendKeys(Keys.Tab);
            var transgenderReveal = Driver.SwitchTo().ActiveElement();

            transgenderReveal.SendKeys(Keys.Tab);
            var ageInput = Driver.SwitchTo().ActiveElement();

            ageInput.SendKeys(age.ToString());
            ageInput.SendKeys(Keys.Tab);
            var nextButton = Driver.SwitchTo().ActiveElement();

            nextButton.SendKeys(Keys.Enter);

            var searchPage = new SearchPage(Driver);

            searchPage.VerifyHeader();
        }
        public async Task <IActionResult> Create([Bind("MainUpload,MainPhoto,Id,SecondUpload,SecondPhoto")] HeaderLogo headerLogo)
        {
            if (headerLogo.MainUpload == null)
            {
                ModelState.AddModelError("MainUpload", "The Photo field is required.");
            }
            else
            {
                if (headerLogo.MainUpload.ContentType != "image/jpeg" && headerLogo.MainUpload.ContentType != "image/png" && headerLogo.MainUpload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("MainUpload", "You can only download png, jpg or gif file");
                }
                if (headerLogo.MainUpload.Length > 1048576)
                {
                    ModelState.AddModelError("MainUpload", "The file size can be a maximum of 1 MB");
                }
            }

            if (headerLogo.SecondUpload == null)
            {
                ModelState.AddModelError("SecondUpload", "The Photo field is required.");
            }
            else
            {
                if (headerLogo.SecondUpload.ContentType != "image/jpeg" && headerLogo.SecondUpload.ContentType != "image/png" && headerLogo.SecondUpload.ContentType != "image/gif")
                {
                    ModelState.AddModelError("SecondUpload", "You can only download png, jpg or gif file");
                }
                if (headerLogo.SecondUpload.Length > 1048576)
                {
                    ModelState.AddModelError("SecondUpload", "The file size can be a maximum of 1 MB");
                }
            }

            if (ModelState.IsValid)
            {
                var fileName = _fileManager.Upload(headerLogo.MainUpload);
                headerLogo.MainPhoto = fileName;

                var secondFaleName = _fileManager.Upload(headerLogo.SecondUpload);
                headerLogo.SecondPhoto = secondFaleName;

                _context.HeaderLogos.Add(headerLogo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(headerLogo));
        }
Exemplo n.º 5
0
        public void VerifyTabbingOrder(string searchTerm)
        {
            HeaderLogo.SendKeys(Keys.Tab);
            var feedbackLink = Driver.SwitchTo().ActiveElement();

            feedbackLink.SendKeys(Keys.Tab);
            var searchTxtBox = Driver.SwitchTo().ActiveElement();

            searchTxtBox.SendKeys(searchTerm);
            searchTxtBox.SendKeys(Keys.Tab);
            var nextButtonElement = Driver.SwitchTo().ActiveElement();

            nextButtonElement.SendKeys(Keys.Enter);
            //Page Loads Results, so the elements have been recreated
            //on the new page, so we must get it again.
            HeaderLogo.SendKeys(Keys.Tab);
            var feedbackLink2 = Driver.SwitchTo().ActiveElement();

            feedbackLink2.SendKeys(Keys.Tab);
            var firstSearchResultLink = Driver.SwitchTo().ActiveElement();

            Assert.AreEqual(searchTerm.ToLower(), firstSearchResultLink.Text.ToLower());
        }
        public async Task <IActionResult> Edit(int?id, [Bind("MainUpload,MainPhoto,Id,SecondUpload,SecondPhoto")] HeaderLogo headerLogo)
        {
            if (id != headerLogo.Id)
            {
                return(NotFound());
            }

            if (headerLogo.SecondUpload == null)
            {
                ModelState.AddModelError("SecondUpload", "The Photo field is required.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (headerLogo.MainUpload != null)
                    {
                        if (headerLogo.MainUpload.ContentType != "image/jpeg" && headerLogo.MainUpload.ContentType != "image/png" && headerLogo.MainUpload.ContentType != "image/gif")
                        {
                            ModelState.AddModelError("MainUpload", "You can only download png, jpg or gif file");
                            return(View(headerLogo));
                        }

                        if (headerLogo.MainUpload.Length > 1048576)
                        {
                            ModelState.AddModelError("MainUpload", "The file size can be a maximum of 1 MB");
                            return(View(headerLogo));
                        }

                        var oldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", headerLogo.MainPhoto);
                        _fileManager.Delete(oldFile);

                        var fileName = _fileManager.Upload(headerLogo.MainUpload, "wwwroot/uploads");
                        headerLogo.MainPhoto = fileName;
                    }

                    if (headerLogo.SecondUpload != null)
                    {
                        if (headerLogo.SecondUpload.ContentType != "image/jpeg" && headerLogo.SecondUpload.ContentType != "image/png" && headerLogo.SecondUpload.ContentType != "image/gif")
                        {
                            ModelState.AddModelError("SecondUpload", "You can only download png, jpg or gif file");
                            return(View(headerLogo));
                        }

                        if (headerLogo.SecondUpload.Length > 1048576)
                        {
                            ModelState.AddModelError("SecondUpload", "The file size can be a maximum of 1 MB");
                            return(View(headerLogo));
                        }

                        var secondOldFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", headerLogo.SecondPhoto);
                        _fileManager.Delete(secondOldFile);

                        var secondFileName = _fileManager.Upload(headerLogo.SecondUpload, "wwwroot/uploads");
                        headerLogo.SecondPhoto = secondFileName;
                    }

                    _context.Update(headerLogo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HeaderLogoExsist(headerLogo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(headerLogo));
        }