コード例 #1
0
        private void SetItemCentralResultList()
        {
            var dictionary = new Dictionary <int, string>();

            ItemsLinkedToPassageList = new List <ItemsLinkedToPassageLineItem>();
            bool isFound = true;

            try
            {
                ItemsLinkedToPassageWebElementList  = ItemsLinkedToPassageRows.WaitForElements(5);
                ItemsLinkedToPassageWebElementList2 = ItemsLinkedToPassageRows2.WaitForElements(5);
                if (Driver.GetType() == typeof(DummyDriver))
                {
                    DummyWebElement dummy1 = new DummyWebElement();
                    dummy1.FakeAttributeId     = "ctl00_MainContent_RepeaterTestItemsLinkedToPassage_ctl00_CheckBoxAddToTest";
                    dummy1.FakeAttributeDetail = "testItemDetail339338";
                    DummyWebElement dummy2 = new DummyWebElement();
                    dummy2.FakeAttributeId     = "ctl00_MainContent_RepeaterTestItemsLinkedToPassage_ctl01_CheckBoxAddToTest";
                    dummy2.FakeAttributeDetail = "testItemDetail339339";
                    List <IWebElement> list = new List <IWebElement> {
                        dummy1, dummy2
                    };
                    ItemsLinkedToPassageWebElementList  = new ReadOnlyCollection <IWebElement>(list);
                    ItemsLinkedToPassageWebElementList2 = new ReadOnlyCollection <IWebElement>(list);
                }
            }
            catch (Exception exception)
            {
                isFound = false;
            }

            if (isFound == true)
            {
                int index = 0;
                foreach (var webElement in ItemsLinkedToPassageWebElementList)
                {
                    string itemid = webElement.GetAttribute("_detail");
                    dictionary.Add(index, itemid);
                    index++;
                }

                index = 0;
                foreach (var webElement in ItemsLinkedToPassageWebElementList2)
                {
                    string idAttribute = webElement.GetAttribute("id");
                    Report.Write("Got the attribute: 'id' = '" + idAttribute + "' of this element by: '" + ByItemsLinkedToPassageRows2.ToString() + "'.");
                    int    from     = idAttribute.IndexOf("_ctl") + "_ctl".Length;
                    int    to       = idAttribute.LastIndexOf("_");
                    string ctl      = idAttribute.Substring(from, to - from);
                    string uniqueId = "ctl" + ctl;
                    string itemid   = dictionary[index];
                    Report.Write("ItemsLinkedToPassageLineItem by itemid: '" + itemid + "'; index: '" + index + "'; uniqueId: '" + uniqueId);
                    var lineItem = new ItemsLinkedToPassageLineItem(itemid, index, uniqueId);
                    ItemsLinkedToPassageList.Add(lineItem);
                    index++;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// verify items are linked to passage by question content
        /// </summary>
        /// <param name="partialQuestionContent">partial question content</param>
        public void VerifyItemsIsLinkedToPassageByQuestionContent(string partialQuestionContent)
        {
            ItemsLinkedToPassageLineItem itemFound = GetItemsLinkedToPassageList().FirstOrDefault(p => p.GetItemDetail().Contains(partialQuestionContent));

            Assert.IsNotNull(itemFound, "Cannot find item linked to passage by searching for partial question content");
        }