コード例 #1
0
        /// <summary>
        /// Verified a specific Nth question is Answered
        /// </summary>
        /// <param name="index">Index start at 0, 1, 2. 0th is 1st question</param>
        /// <returns>true or false</returns>
        public bool VerifyQuestionIsAnswered(int index)
        {
            //AnsweredQuestionLinks return all answered and unanswered
            //In order to find out if a question was answered, check to see if it was in UNanswered list
            //If it is not there, check to see the question exist AnsweredQuestionLinks
            //If it is found in AnsweredQuestionLinks, we know the question exist and it is not UNanswered.
            if (Driver.WrappedDriver.GetType() != typeof(DummyDriver)) //if not dummy
            {
                if (VerifyQuestionIsUnAnswered(index))
                {
                    return(false);
                }
            }

            ReadOnlyCollection <IWebElement> AllQuestionsLinkWebElementList = AnsweredQuestionLinks.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
                };

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

            foreach (var webElement in AllQuestionsLinkWebElementList)
            {
                //<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 answered questions
        /// </summary>
        /// <returns>count</returns>
        public int GetNumberOfAnsweredQuestions()
        {
            AnsweredQuestionLinkWebElementList = AnsweredQuestionLinks.WaitForElements(3);
            int count = 0;

            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                AnsweredQuestionLinkWebElementList = 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("Answered"))
                {
                    count++;
                }
            }
            //return AnsweredQuestionLinkWebElementList.Count;
            return(count);
        }
コード例 #3
0
        /// <summary>
        /// verify all questions are unanswered
        /// </summary>
        /// <returns>true or false</returns>
        public bool VerifyAllQuestionsAreUnAnswered()
        {
            bool allQuestionsAreUnAnswered = true;//false;

            AnsweredQuestionLinkWebElementList = AnsweredQuestionLinks.WaitForElements(3);

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

            /*if (!AnsweredQuestionLinkWebElementList.Any())
             *  allQuestionsAreUnAnswered = 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("Unanswered"))
                {
                    allQuestionsAreUnAnswered = false;
                }
            }
            return(allQuestionsAreUnAnswered);
        }