Beispiel #1
0
        private string GetUniqueId(WebElementWrapper webElement, By by)
        {
            string id = webElement.GetAttribute("id");

            Report.Write("Got the attribute: 'id' = '" + id + "' of this element by: '" + by.ToString() + "'.");
            int    from     = id.IndexOf("_ctl") + "_ctl".Length;
            int    to       = id.LastIndexOf("_");
            string index    = id.Substring(from, to - from);
            string uniqueId = "ctl" + index;

            return(uniqueId);
        }
Beispiel #2
0
        /// <summary>
        /// Inside each row for CompletionStatistic grid, there is the Location link.
        /// This function return the location link value.
        /// tr.td.a href="TrackTestResults.aspx?id=19504&key=789&section=False..."
        /// </summary>
        /// <param name="rowElement"></param>
        /// <returns></returns>
        private string GetLinkRefValue(WebElementWrapper rowElement, By by)
        {
            IWebElement       linkElement        = rowElement.FindElement(by);
            WebElementWrapper linkElementWrapper = new WebElementWrapper(by);

            linkElementWrapper.WrappedElement    = linkElement;
            linkElementWrapper.FakeAttributeHref = "TrackTestResults.aspx?id=19504&key=789&section=False";

            string linkReference = linkElementWrapper.GetAttribute("href");

            Report.Write("Got link reference: " + linkReference);
            return(linkReference);
        }
        private bool IsEnabled(WebElementWrapper element)
        {
            bool isEnabled = true;

            //use wait until exists because Dev uses 2 different 'a' tags for each link, and they toggle which is enabled
            element.WaitUntilExists(3);
            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                element.FakeAttributeClass = FakeText;
            }
            if (element.GetAttribute("class").Trim().ToLower().Contains("aspNetDisabled".ToLower()))
            {
                return(false);
            }
            return(isEnabled);
        }
Beispiel #4
0
        private string GetUniqueId(WebElementWrapper webElement, By by)
        {
            IWebElement       statusColumn        = webElement.FindElement(by);
            WebElementWrapper statusColumnWrapper = new WebElementWrapper(by);

            statusColumnWrapper.WrappedElement  = statusColumn;
            statusColumnWrapper.FakeAttributeId = "ctl00_MainContent_TrackTestDetail_DataCollectionGridView1_gridInstitutionView_ctl03_ctl01_HyperLinkDataCollectionReport";

            string id = statusColumnWrapper.GetAttribute("id");

            Report.Write("Got the attribute: 'id' = '" + id + "' of this element by: '" + by.ToString() + "'.");
            int    from     = id.IndexOf("_ctl") + "_ctl".Length;
            int    to       = id.LastIndexOf("_");
            string index    = id.Substring(from, to - from);
            string uniqueId = "ctl" + index;

            Report.Write("uniqueId is " + uniqueId); // ctl03_ctl01
            return(uniqueId);
        }
Beispiel #5
0
        private void SetItemCentralResultList()
        {
            ItemCentralResultsList = new List <ItemCentralLineItem>();
            SearchResultsGrid.Wait(3);
            ItemCentralResultsWebElementList = SearchResultsRows.WaitForElements(5);
            if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
            {
                DummyWebElement dummy1 = new DummyWebElement();
                dummy1.FakeAttributeItemid    = "231270";
                dummy1.FakeAttributePassageid = "35605";
                DummyWebElement dummy2 = new DummyWebElement();
                dummy2.FakeAttributeItemid    = "231271";
                dummy2.FakeAttributePassageid = "35606";
                DummyWebElement dummy3 = new DummyWebElement();
                dummy3.FakeAttributeItemid    = "231272";
                dummy3.FakeAttributePassageid = "35607";
                DummyWebElement dummy4 = new DummyWebElement();
                dummy4.FakeAttributeItemid    = "231273";
                dummy4.FakeAttributePassageid = "35608";
                DummyWebElement dummy5 = new DummyWebElement();
                dummy5.FakeAttributeItemid    = "231274";
                dummy5.FakeAttributePassageid = "35609";
                DummyWebElement dummy6 = new DummyWebElement();
                dummy6.FakeAttributeItemid    = "231275";
                dummy6.FakeAttributePassageid = "35610";
                DummyWebElement dummy7 = new DummyWebElement();
                dummy7.FakeAttributeItemid    = "231276";
                dummy7.FakeAttributePassageid = "35611";
                DummyWebElement dummy8 = new DummyWebElement();
                dummy8.FakeAttributeItemid    = "231277";
                dummy8.FakeAttributePassageid = "35612";
                DummyWebElement dummy9 = new DummyWebElement();
                dummy9.FakeAttributeItemid    = "231278";
                dummy9.FakeAttributePassageid = "35613";
                DummyWebElement dummy10 = new DummyWebElement();
                dummy10.FakeAttributeItemid    = "231279";
                dummy10.FakeAttributePassageid = "35614";

                List <IWebElement> list = new List <IWebElement> {
                    dummy1, dummy2, dummy3, dummy4, dummy5, dummy6, dummy7, dummy8, dummy9, dummy10
                };
                ItemCentralResultsWebElementList = new ReadOnlyCollection <IWebElement>(list);
            }

            int index = 0;

            foreach (var webElement in ItemCentralResultsWebElementList)
            {
                int    itemid    = -1;
                int    passageid = -1;
                string uniqueId  = null;
                switch (ItemCentralType)
                {
                case ItemCentralType.Item:
                    itemid    = int.Parse(webElement.GetAttribute("itemid"));
                    ItemCheck = new WebElementWrapper(ByCheckItemLocator(itemid));
                    //ctl00_MainContent_ItemFinder1_ItemFinderResults1_gridResults_ctl03_chkItem
                    ItemCheck.FakeAttributeId = "ctl00_MainContent_ItemFinder1_" + ControlMiddle + "gridResults_ctl03_chkItem";
                    uniqueId = GetUniqueId(ItemCheck, ByCheckItemLocator(itemid));
                    break;

                case ItemCentralType.Passage:
                    itemid    = int.Parse(webElement.GetAttribute("passageid"));
                    ItemCheck = new WebElementWrapper(ByCheckItemLocator(itemid));
                    //ctl00_MainContent_ItemFinder1_PassageFinderResults1_gridResults_ctl03_chkPassage
                    ItemCheck.FakeAttributeId = "ctl00_MainContent_ItemFinder1_" + ControlMiddle + "gridResults_ctl03_chkItem";
                    uniqueId = GetUniqueId(ItemCheck, ByCheckItemLocator(itemid));
                    break;

                case ItemCentralType.Rubric:
                    By ByAlink = By.CssSelector("a[id*='ButtonDetails']");
                    WebElementWrapper aLinkElement = new WebElementWrapper(ByAlink);
                    if (Driver.GetType() == typeof(DummyDriver))
                    {
                        aLinkElement.FakeAttributeRubricid = "8560";
                        //ctl00_MainContent_RubricFinder1_RubricFinderResults1_gridResults_ctl03_ButtonDetails
                        aLinkElement.FakeAttributeId = "ctl00_MainContent_RubricFinder1_" + ControlMiddle + "gridResults_ctl03_ButtonDetails";
                    }
                    itemid   = int.Parse(aLinkElement.GetAttribute("rubric_id"));
                    uniqueId = GetUniqueId(aLinkElement, SearchResultsRows.By);
                    break;
                }
                Report.Write("ItemCentralLineItem by itemid: '" + itemid + "'; passageid: '{" + passageid + "'; index: '" + index + "'; uniqueId: '" + uniqueId);
                var lineItem = new ItemCentralLineItem(webElement, ItemCentralType, itemid, index, uniqueId);
                ItemCentralResultsList.Add(lineItem);
                index++;
            }
        }
Beispiel #6
0
 public virtual string GetValue()
 {
     return(element.GetAttribute("value"));
 }