コード例 #1
0
        /// <summary>
        /// Verified a specific Nth question is not Unanswered
        /// </summary>
        /// <param name="index">Index start at 0, 1, 2. 0th is 1st question</param>
        /// <returns>true or false</returns>
        public bool VerifyQuestionIsUnAnswered(int index)
        {
            UnAnsweredQuestionLinkWebElementList = UnAnsweredQuestionLinks.WaitForElements(3);

            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                List <IWebElement> dummyList = new List <IWebElement>();
                DummyWebElement    dummy     = new DummyWebElement();
                dummy.FakeAttributeAriaLabel = "Question " + Convert.ToString(index + 1);
                dummyList = new List <IWebElement> {
                    dummy
                };

                UnAnsweredQuestionLinkWebElementList = new ReadOnlyCollection <IWebElement>(dummyList);
            }

            foreach (var webElement in UnAnsweredQuestionLinkWebElementList)
            {
                //<a aria-label="Question 2 Unanswered" role="link" class=" unanswered" tabindex="0">Unanswered</a>
                string actualLabel = webElement.GetAttribute("aria-label");
                string expectLabel = "Question " + Convert.ToString(index + 1);
                if (actualLabel.Contains(expectLabel))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// get number of unanswered questions
        /// </summary>
        /// <returns>count</returns>
        public int GetNumberOfUnAnsweredQuestions()
        {
            UnAnsweredQuestionLinkWebElementList = UnAnsweredQuestionLinks.WaitForElements(3);
            int count = 0;

            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                UnAnsweredQuestionLinkWebElementList = GetDummyIdentifiers(NumberOfElementsToBeReturnedInTheDummyWebElementList);
            }
            //need to verify the text to work in all browsers (because of IE)
            foreach (var webElement in AnsweredQuestionLinkWebElementList)
            {
                string actual = webElement.Text;
                if (actual.Equals("Unanswered"))
                {
                    count++;
                }
            }
            //return UnAnsweredQuestionLinkWebElementList.Count;
            return(count);
        }
コード例 #3
0
        /// <summary>
        /// verify warning message
        /// </summary>
        public void VerifyWarningMessage()
        {
            UnAnsweredQuestionLinkWebElementList = UnAnsweredQuestionLinks.WaitForElements(3);
            var warning = TestResponseWarningMessage.Wait(2);

            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                UnAnsweredQuestionLinkWebElementList = GetDummyIdentifiers(NumberOfElementsToBeReturnedInTheDummyWebElementList);
                warning.Displayed = true;
                warning.Text      = "Warning: You have " + UnAnsweredQuestionLinkWebElementList.Count + " unanswered questions";
            }

            if (UnAnsweredQuestionLinkWebElementList.Any())
            {
                Assert.AreEqual(true, warning.Displayed, "The warning message is invisible, but should be visible.");

                var countOfUnansweredQuestions = UnAnsweredQuestionLinkWebElementList.Count;

                Assert.IsTrue(warning.Text.Contains(countOfUnansweredQuestions.ToString()),
                              string.Format("Actual number of UnAnswered questions is {0} which is not the same as the displayed number of unanswered questions in the warning message.",
                                            countOfUnansweredQuestions));
            }
        }
コード例 #4
0
        /// <summary>
        /// verify all questions are answered
        /// </summary>
        /// <returns>true or false</returns>
        public bool VerifyAllQuestionsAreAnswered()
        {
            bool allQuestionAnswered = true;//false;

            UnAnsweredQuestionLinkWebElementList = UnAnsweredQuestionLinks.WaitForElements(3);

            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                UnAnsweredQuestionLinkWebElementList = GetDummyIdentifiers(NumberOfElementsToBeReturnedInTheDummyWebElementList);
            }

            /*if (!UnAnsweredQuestionLinkWebElementList.Any())
             *  allQuestionAnswered = true;*/
            //need to verify the text to work in all browsers (because of IE)
            foreach (var webElement in UnAnsweredQuestionLinkWebElementList)
            {
                string actual = webElement.Text;
                if (!actual.Equals("Answered"))
                {
                    allQuestionAnswered = false;
                }
            }
            return(allQuestionAnswered);
        }