예제 #1
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);
        }
예제 #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>
        /// Finds users collection
        /// </summary>
        /// <returns>
        /// NULL if user has no wraps in collection
        /// </returns>
        public ICollection GetCollection()
        {
            WebAdapter.ButtonClickById("nav_collection");

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

            return(retVal);
        }
        /// <summary>
        /// The explorer.
        /// </summary>
        /// <returns>
        /// The <see cref="IExplore"/>.
        /// </returns>
        public IExplore Explore()
        {
            var clicked = WebAdapter.ButtonClickById("nav_explore");
            var retVal  = clicked
                       ? StfContainer.Get <IExplore>()
                       : null;

            return(retVal);
        }
        /// <summary>
        /// The news.
        /// </summary>
        /// <returns>
        /// The <see cref="INews"/>.
        /// </returns>
        public INews News()
        {
            var clicked = WebAdapter.ButtonClickById("nav_home");
            var retVal  = clicked
                       ? StfContainer.Get <INews>()
                       : null;

            return(retVal);
        }
예제 #6
0
        /// <summary>
        /// The collection.
        /// </summary>
        /// <returns>
        /// The <see cref="ICollection"/>.
        /// </returns>
        public ICollection Collection()
        {
            var but = WebAdapter.FindElement(By.Id("## MISSING ##"));

            but.Click();

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

            return(retVal);
        }
예제 #7
0
        /// <summary>
        /// The learn more.
        /// </summary>
        /// <returns>
        /// The <see cref="ILearnMore"/>.
        /// </returns>
        public ILearnMore LearnMore()
        {
            // Press learn more
            var but = WebAdapter.FindElement(By.Id("LearnMore"));

            but.Click();

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

            return(retVal);
        }
        /// <summary>
        /// The get to model.
        /// </summary>
        /// <param name="modelId">
        /// The model id.
        /// </param>
        /// <returns>
        /// The <see cref="IModel"/>.
        /// </returns>
        public IModel GetToModel(string modelId)
        {
            var baseUrl    = WtConfiguration.Url;
            var modelIdUrl = $"{baseUrl}Catalog/model/{modelId}";

            WebAdapter.OpenUrl(modelIdUrl);

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

            return(retVal);
        }
예제 #9
0
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            // register my needed types
            StfContainer.RegisterType <ILearnMore, LearnMore>();

            // get what I need - a WebAdapter:-)
            WebAdapter = StfContainer.Get <IWebAdapter>();

            WebAdapter.OpenUrl("http://democorpweb.azurewebsites.net/");

            return(true);
        }
        /// <summary>
        /// The get to wrap.
        /// </summary>
        /// <param name="wrapId">
        /// The wrap id.
        /// </param>
        /// <returns>
        /// The <see cref="IWrap"/>.
        /// </returns>
        public IWrap GetToWrap(string wrapId)
        {
            var baseUrl   = WtConfiguration.Url;
            var wrapIdUrl = $"{baseUrl}Collection/wrap/{wrapId}";
            var openUrl   = WebAdapter.OpenUrl(wrapIdUrl);

            if (!openUrl)
            {
                StfLogger.LogError($"Couldn't open the url [{wrapIdUrl}]");
                return(null);
            }

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

            return(retVal);
        }
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            var registerMyNeededTypes = new RegisterMyNeededTypes(this);

            registerMyNeededTypes.Register();
            WtConfiguration = SetConfig <WtConfiguration>();

            // get what I need - a WebAdapter:-)
            WebAdapter = StfContainer.Get <IWebAdapter>();

            WebAdapter.OpenUrl(WtConfiguration.Url);

            var currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            StfLogger.LogKeyValue("Current Directory", currentDomainBaseDirectory, "Current Directory");
            return(true);
        }
예제 #12
0
        /// <summary>
        /// The init.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Init()
        {
            // register my needed types
            StfContainer.RegisterType <ICollection, Collection>();
            StfContainer.RegisterType <IMe, Me.Me>();
            StfContainer.RegisterType <IExplorer, Explorer>();
            StfContainer.RegisterType <IFaq, Faq.Faq>();

            // get what I need - a WebAdapter:-)
            WebAdapter = StfContainer.Get <IWebAdapter>();
            WebAdapter.OpenUrl("http://WrapTrack.org/");

            var currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            StfLogger.LogKeyValue("Current Directory", currentDomainBaseDirectory, "Current Directory");
            Login("ida88", "lk8dsafpUqwe");

            return(true);
        }
예제 #13
0
        /// <summary>
        /// Get the web adapter configuration
        /// </summary>
        /// <returns>
        /// Instance of web adapter configuration
        /// </returns>
        private WebAdapterConfiguration GetConfiguration()
        {
            WebAdapterConfiguration retVal;

            try
            {
                var stfConfiguration = StfContainer.Get <StfConfiguration>();

                retVal = new WebAdapterConfiguration();

                stfConfiguration.LoadUserConfiguration(retVal);
            }
            catch (Exception ex)
            {
                StfLogger.LogInternal($"Couldn't GetConfiguration - got error [{ex.Message}]");
                retVal = null;
            }

            return(retVal);
        }
        /// <summary>
        /// The me.
        /// </summary>
        /// <returns>
        /// The <see cref="IMeProfile"/>.
        /// </returns>
        public IMeProfile Me()
        {
            // press the top menu tab
            var buttonClicked = WebAdapter.ButtonClickById("nav_me");

            if (!buttonClicked)
            {
                return(null);
            }

            // when number of wraps is high, the rendering might take some time...
            // TODO: Implement using Selenium Waiter
            WebAdapter.WaitForComplete(5);

            // press the second level top menu tab - called "profile"
            buttonClicked = WebAdapter.ButtonClickById("nav_profile");

            var retVal = buttonClicked
                ? StfContainer.Get <IMeProfile>()
                : null;

            return(retVal);
        }