/// <summary> /// sets the question stem list. /// </summary> public void SetQuestionStemList() { QuestionStemList = new List <QuestionLineItem>(); QuestionGrid.Wait(3); QuestionContentWebElementList = QuestionContentRows.WaitForElements(5); if (Driver.WrappedDriver.GetType() == typeof(DummyDriver)) { DummyWebElement dummy1 = new DummyWebElement(); dummy1.Text = "banana"; DummyWebElement dummy2 = new DummyWebElement(); dummy2.Text = "carrot"; DummyWebElement dummy3 = new DummyWebElement(); dummy3.Text = "eggplant"; List <IWebElement> list = new List <IWebElement> { dummy1, dummy2, dummy3 }; QuestionContentWebElementList = new ReadOnlyCollection <IWebElement>(list); } int index = 0; foreach (var webElement in QuestionContentWebElementList) { string question = webElement.Text.Trim(); Report.Write("QuestionLineItem index: '" + index + "'; question: '" + question); var questionLineItem = new QuestionLineItem(index, question); QuestionStemList.Add(questionLineItem); index++; } }
/// <summary> /// sets the question stem list. /// </summary> /// <param name="questionStem">list of question stems</param> public void SetQuestionStemList(List <string> questionStem) { QuestionStemList = new List <QuestionLineItem>(); QuestionGrid.Wait(3); QuestionContentWebElementList = QuestionContentRows.WaitForElements(5); if (Driver.WrappedDriver.GetType() == typeof(DummyDriver)) { DummyWebElement dummy1 = new DummyWebElement(); dummy1.Text = "banana"; DummyWebElement dummy2 = new DummyWebElement(); dummy2.Text = "carrot"; DummyWebElement dummy3 = new DummyWebElement(); dummy3.Text = "eggplant"; List <IWebElement> list = new List <IWebElement> { dummy1, dummy2, dummy3 }; QuestionContentWebElementList = new ReadOnlyCollection <IWebElement>(list); } foreach (var webElement in QuestionContentWebElementList) { string question = webElement.Text.Trim(); if (questionStem.Contains(question)) { int index = 1 + questionStem.IndexOf(question); Report.Write("QuestionLineItem index: '" + index + "'; question: '" + question); var questionLineItem = new QuestionLineItem(index, question); QuestionStemList.Add(questionLineItem); } else { throw new Exception("Expected to find the question: '" + question + "', but it does not exist in the question parts."); } } }