예제 #1
0
        /// <summary>
        /// Counts number of wraps in collection
        /// </summary>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int NumOfWraps()
        {
            var elements = WebAdapter.FindElements(By.Id("lin_wrap"));
            var retval   = elements.Count;

            return(retval);
        }
예제 #2
0
        /// <summary>
        /// Returns random wrap in collection.
        /// </summary>
        /// <param name="wtIdContraint">
        /// Constrain the randomness to NOT return this wrap
        /// </param>
        /// <returns>
        /// The <see cref="IWrap"/>.
        /// </returns>
        public IWrap GetRandomWrap(string wtIdContraint = null)
        {
            var wrapElements  = WebAdapter.FindElements(By.Id("lin_wrap"));
            var numberOfWraps = wrapElements.Count;
            var random        = new Random();
            var wrapToChoose  = random.Next(1, numberOfWraps + 1);
            var xpath         = $"(//a[@id='lin_wrap'])[{wrapToChoose}]";
            var element       = WebAdapter.FindElement(By.XPath(xpath));
            var linWrapText   = element.Text;

            if (!string.IsNullOrEmpty(wtIdContraint) &&
                numberOfWraps > 1 &&
                linWrapText.Equals(wtIdContraint, StringComparison.CurrentCultureIgnoreCase))
            {
                wrapToChoose = wrapToChoose == numberOfWraps ? 1 : wrapToChoose + 1;
                xpath        = $"(//a[@id='lin_wrap'])[{wrapToChoose}]";
                element      = WebAdapter.FindElement(By.XPath(xpath));
            }

            StfLogger.LogInfo($"We choose wrap number {wrapToChoose} (of {numberOfWraps}) - {linWrapText}");
            element.Click();

            var retVal = StfContainer.Get <IWrap>();

            return(retVal);
        }
예제 #3
0
        /// <summary>
        /// Find a wrap in this collection that
        /// is either on holiday or not depending on argument
        /// </summary>
        /// <param name="argument">
        /// true is on holiday, false is not on holiday
        /// </param>
        /// <returns>a wrap that meets the criteria or null if no match</returns>
        private IWrap FindWrapByOnHoliday(bool argument)
        {
            var retVal = default(IWrap);

            var wrapElements = WebAdapter.FindElements(By.Id("lin_wrap"));

            if (wrapElements == null)
            {
                return(null);
            }

            // Loop through all the items in the collection until
            // find one whose OnHoliday status matches the argument
            var numberOfWraps = wrapElements.Count;

            for (var i = 1; i <= numberOfWraps; i++)
            {
                var xpath       = $"(//a[@id='lin_wrap'])[{i}]";
                var element     = WebAdapter.FindElement(By.XPath(xpath));
                var linWrapText = element.Text;
                var wtApi       = Get <IWtApi>();
                var wrapInfo    = wtApi.WrapInfoByTrackId(linWrapText);

                if (wrapInfo.OnHoliday == argument)
                {
                    element.Click();
                    retVal = StfContainer.Get <IWrap>();
                    break;
                }
            }

            return(retVal);
        }
예제 #4
0
        /// <summary>
        /// The get news entry carrier evaulation
        /// </summary>
        /// <param name="modelName">
        /// The model name
        /// </param>
        /// <param name="criteria">
        /// The criteria
        /// </param>
        /// <returns>
        /// The <see cref="INewsEntryCarrierEvaluation"/>.
        /// </returns>
        public INewsEntryCarrierEvaluation GetNewsEntryCarrierEvaluation(string modelName, string criteria)
        {
            var elements = WebAdapter.FindElements(By.Id("anmeldelse_bedoemmelse"));

            // TODO: Could be we should call the API so this becomes a bit more event driven:-)
            WebAdapter.WaitForComplete(30);
            StfLogger.LogDebug("no. carrier evaluations :" + elements.Count);

            if (elements.Count != 1)
            {
                StfLogger.LogError($"only support 1 carrier evaluation - found {elements.Count} elements");
                return(null);
            }

            var element = elements.First();

            if (element == null)
            {
                StfLogger.LogError("elements.first() returned a null element");
                return(null);
            }

            var newsEntryCarrierEvaluation = Get <INewsEntryCarrierEvaluation>();

            if (newsEntryCarrierEvaluation == null)
            {
                StfLogger.LogError("Could not get newsEntryCarrierEvaluation from Get<INewsEntryCarrierEvaluation>");
                return(null);
            }

            newsEntryCarrierEvaluation.Text = element.Text;

            if (!newsEntryCarrierEvaluation.HeaderText.Contains(WrapTrackWebShell.CurrentLoggedInUser))
            {
                StfLogger.LogDebug("Returning null as !newsEntryCarrierEvaluation.HeaderText.Contains(WrapTrackWebShell.CurrentLoggedInUser)");
                return(null);
            }

            if (!newsEntryCarrierEvaluation.WrapText.Contains(modelName))
            {
                StfLogger.LogDebug("Returning null as !newsEntryCarrierEvaluation.WrapText.Contains(modelId)");
                return(null);
            }

            if (!newsEntryCarrierEvaluation.CriteriaText.Equals(criteria))
            {
                StfLogger.LogDebug("Returning null as !newsEntryCarrierEvaluation.CriteriaText.Equals(criteria)");
                return(null);
            }

            return(newsEntryCarrierEvaluation);
        }
예제 #5
0
        /// <summary>
        /// The get news entry carrier review.
        /// </summary>
        /// <param name="modelName">
        /// The model name
        /// </param>
        /// <param name="reviewText">
        /// The text for the review
        /// </param>
        /// <returns>
        /// The <see cref="INewsEntryCarrierReview"/>.
        /// </returns>
        public INewsEntryCarrierReview GetNewsEntryCarrierReview(string modelName, string reviewText)
        {
            var elements = WebAdapter.FindElements(By.Id("anmeldelse_vurdering"));

            WebAdapter.WaitForComplete(30);

            StfLogger.LogDebug("no. carrier review stories :" + elements.Count);
            if (elements.Count != 1)
            {
                StfLogger.LogError("only support 1 carrier review");
                return(null);
            }

            var element = elements.First();

            if (element == null)
            {
                StfLogger.LogError("elements.first() returned a null element");
                return(null);
            }

            var newsEntryCarrierReview = Get <INewsEntryCarrierReview>();

            if (newsEntryCarrierReview == null)
            {
                StfLogger.LogError("Could not get newsEntryCarrierReview from Get<INewsEntryCarrierReview>");
                return(null);
            }

            newsEntryCarrierReview.Text = element.Text;

            if (!newsEntryCarrierReview.HeaderText.Contains(WrapTrackWebShell.CurrentLoggedInUser))
            {
                StfLogger.LogDebug("Returning null as !newsEntryCarrierReview.HeaderText.Contains(WrapTrackWebShell.CurrentLoggedInUser)");
                return(null);
            }

            if (!newsEntryCarrierReview.WrapText.Contains(modelName))
            {
                StfLogger.LogDebug("Returning null as !newsEntryCarrierReview.WrapText.Contains(modelId)");
                return(null);
            }

            if (!newsEntryCarrierReview.ReviewText.Equals(reviewText))
            {
                StfLogger.LogDebug("Returning null as !newsEntryCarrierReview.ReviewText.Equals(reviewText)");
                return(null);
            }

            return(newsEntryCarrierReview);
        }
예제 #6
0
        /// <summary>
        /// The remove ONE wrap image.
        /// </summary>
        /// <param name="imageIndex">
        /// The index of the image to delete - if 1 then the image listed in the top
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool RemoveWrapImage(int imageIndex = 1)
        {
            var buttons = WebAdapter.FindElements(By.Id("but_delete"));

            if (buttons == null || buttons.Count == 0)
            {
                return(false);
            }

            var buttonToClick = buttons.First();

            buttonToClick.Click();

            // We have to wait a bit to get WT in sync
            WebAdapter.WaitForComplete(3);

            return(true);
        }
예제 #7
0
        /// <summary>
        /// The get news entry carrier story that contains the chapter text for the wrap.
        /// </summary>
        /// <param name="wrapId">
        /// The wrap id.
        /// </param>
        /// <param name="chapterText">
        /// The chapter text.
        /// </param>
        /// <returns>
        /// The <see cref="INewsEntryCarrierStory"/>.
        /// </returns>
        public INewsEntryCarrierStory GetNewsEntryCarrierStory(string wrapId, string chapterText)
        {
            var elements = WebAdapter.FindElements(By.Id("baereredskab_fortaelling"));

            if (elements.Count != 1)
            {
                StfLogger.LogError("only support 1 carrier story");
                return(null);
            }

            var element = elements.First();

            if (element == null)
            {
                StfLogger.LogError("elements.first() returned a null element");
                return(null);
            }

            var newsEntryCarrierStory = Get <INewsEntryCarrierStory>();

            if (newsEntryCarrierStory == null)
            {
                StfLogger.LogError("Could not newsEntryCarrierStory from Get<INewsEntryCarrierStory>");
                return(null);
            }

            newsEntryCarrierStory.Text = element.Text;

            // :TODO test also for currentloggedinser at start of header text. Waiting for issue #33. See next comment line
            // if (!newsEntryCarrierStory.HeaderText.Contains(WrapTrackWebShell.CurrentLoggedInUser)
            var baseHeaderTextForNewsStory = "has written a new chapter in the story";

            if (!newsEntryCarrierStory.HeaderText.Contains(baseHeaderTextForNewsStory)
                ||
                !newsEntryCarrierStory.WrapText.Contains(wrapId)
                ||
                !newsEntryCarrierStory.ChapterText.Equals(chapterText))
            {
                return(null);
            }

            return(newsEntryCarrierStory);
        }
예제 #8
0
        /// <summary>
        /// The get news entry carrier for sale.
        /// </summary>
        /// <param name="wrapId">
        /// The wrap id.
        /// </param>
        /// <param name="typeOfSale">
        /// The type Of Sale.
        /// </param>
        /// <returns>
        /// The <see cref="INewsEntryCarrierForSale"/>.
        /// </returns>
        public INewsEntryCarrierForSale GetNewsEntryCarrierForSale(string wrapId, string typeOfSale)
        {
            var elements = WebAdapter.FindElements(By.Id("baereredskab_paamarkedet"));

            if (elements.Count != 1)
            {
                StfLogger.LogError("only support 1 carrier story");
                return(null);
            }

            var element = elements.First();

            if (element == null)
            {
                StfLogger.LogError("elements.first() returned a null element");
                return(null);
            }

            var newsEntryCarrierForSale = Get <INewsEntryCarrierForSale>();

            if (newsEntryCarrierForSale == null)
            {
                StfLogger.LogError("Could not get newsEntryCarrierForSale from Get<INewsEntryCarrierForSale>");
                return(null);
            }

            newsEntryCarrierForSale.Text = element.Text;

            if (!newsEntryCarrierForSale.HeaderText.Contains(WrapTrackWebShell.CurrentLoggedInUser)
                ||
                !newsEntryCarrierForSale.WrapText.Contains(wrapId)
                ||
                !newsEntryCarrierForSale.StatusText.Equals(typeOfSale))
            {
                return(null);
            }

            return(newsEntryCarrierForSale);
        }
예제 #9
0
        /// <summary>
        /// The get list of wt ids.
        /// </summary>
        /// <returns>
        /// List of WtId as strings
        /// </returns>
        public List <string> GetListOfWtIds()
        {
            var retVal       = new List <string>();
            var wrapElements = WebAdapter.FindElements(By.Id("lin_wrap"));

            // Nothing for us - lets leave...
            if (wrapElements == null || !wrapElements.Any())
            {
                return(retVal);
            }

            foreach (var wrapElement in wrapElements)
            {
                var wtId = wrapElement.Text;

                if (!string.IsNullOrEmpty(wtId) && !retVal.Contains(wtId))
                {
                    retVal.Add(wtId);
                }
            }

            return(retVal);
        }