/// <summary>
        /// The choose english.
        /// </summary>
        private void ChooseEnglish()
        {
            const string Xpath = @"//sprog_valg//img[@src=""http://wt.troldvaerk.org/grafik/flag/2.svg""]";

            WebAdapter.ButtonClickByXpath(Xpath);
            WebAdapter.WaitForComplete(1);
        }
        /// <summary>
        /// The check sign up validation messages.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool CheckSignUpValidationMessages()
        {
            var signUpValidationMessages = new List <string>
            {
                "Please read and approve the terms and conditions",
                "The username must be between four and 25 characters long. Only numbers, letters, and hyphen are accepted.",
                "The password must be at least five characters long.",
                "Please specify a valid e-mail address"
            };

            // we dont want to wait "long time" for each message, which we would if not initially wating 3 secs.. Now each can wait 1!
            WebAdapter.WaitForComplete(3);

            foreach (var signUpValidationMessage in signUpValidationMessages)
            {
                var xpath = $@"(//p[text()='{signUpValidationMessage}'])[1]";
                var validationMessageElement = WebAdapter.FindElement(By.XPath(xpath), 1);

                if (validationMessageElement == null)
                {
                    // found no error indication - All's well - so far...
                    continue;
                }

                StfLogger.LogError($"SignUp. There is validation error. Message : [{signUpValidationMessage}]");
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add pattern to the brand.
        /// </summary>
        /// <param name="patternName">
        /// The pattern name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool AddPattern(string patternName)
        {
            var retVal = WebAdapter.ButtonClickById("addPattern");

            if (!retVal)
            {
                return(false);
            }

            retVal = WebAdapter.TextboxSetTextById("inNameNewElement", patternName);

            if (!retVal)
            {
                return(false);
            }

            retVal = WebAdapter.ButtonClickById("create");

            if (!retVal)
            {
                return(false);
            }

            retVal = WebAdapter.ButtonClickById("Done");

            // gotta wait for the WT to process the add...
            WebAdapter.WaitForComplete(1);

            return(retVal);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public bool Add()
        {
            try
            {
                var addBtn = WebAdapter.ButtonClickById("butSaveReviewOneLang");

                WebAdapter.WaitForComplete(2);

                //toDo:  Button name, according to the test case it should be Add review in another.. now it is Add evaluation..
                var addBtnInAnotherLanguage = WebAdapter.FindElement(By.XPath(
                                                                         "//button[@id='butAddAnotherLang']/p/span/span[contains(text(),'Add evaluation in another language')]"));

                if (addBtnInAnotherLanguage == null)
                {
                    StfLogger.LogError("Couldn't find button Add review in another language");

                    return(false);
                }

                return(addBtn && addBtnInAnotherLanguage.Displayed);
            }
            catch (Exception ex)
            {
                StfLogger.LogError($"Something went wrong when added review. Error message : [{ex.Message}]");
                throw;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// The upload picture.
        /// </summary>
        /// <param name="localPathToImage">
        /// The local path to image.
        /// </param>
        /// <returns>
        /// Indication of success.
        /// </returns>
        public bool UploadPicture(string localPathToImage)
        {
            var buttonClickAdminPictures = WebAdapter.ButtonClickByXpath("(//button[@id='but_adm_pic'])[2]");

            if (!buttonClickAdminPictures)
            {
                return(false);
            }

            WebAdapter.WaitForComplete(3);

            // handle the File Upload Dialog
            var nativeDialogFileUpload = WebAdapter.NativeDialogFileUpload(By.Id("userfile"), localPathToImage);

            if (!nativeDialogFileUpload)
            {
                return(false);
            }

            WebAdapter.WaitForComplete(3);

            // Press upload the image
            var buttonClickUploadImage = WebAdapter.ButtonClickById("but_doupload");

            if (!buttonClickUploadImage)
            {
                return(false);
            }

            WebAdapter.WaitForComplete(3);

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// The set review property value.
        /// </summary>
        /// <param name="modelReviewProperty">
        /// The model review property.
        /// </param>
        /// <param name="modelReviewValues">
        /// The review value.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool SetReviewPropertyValue(ModelReviewProperties modelReviewProperty, ModelReviewValues modelReviewValues)
        {
            var criteriaText    = modelReviewProperty.GetDisplayName();
            var evaluationvalue = (int)modelReviewValues;
            var xPath           = "(//p/span[text()='" +
                                  criteriaText +
                                  "']/../../following::div/anmeldelse_bedoemmelse_punkt[" +
                                  evaluationvalue +
                                  "])[1]";

            StfLogger.LogDebug("criteria text xpath ", xPath);

            var retVal = WrapTrackWebShell.WebAdapter.Click(By.XPath(xPath));

            if (!retVal)
            {
                StfLogger.LogError($"Couldn't find the criteria {modelReviewProperty}");
                return(false);
            }

            WebAdapter.WaitForComplete(1);
            retVal = WebAdapter.Click(By.Id("butSaveReviewOneLang"));

            return(retVal);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Remove a wrap from collection
        /// </summary>
        /// <param name="deleteOption">
        /// There is more than one reason why the wrap should
        /// not be part of the user collecting more
        /// </param>
        /// <returns>
        /// True if sucsess else False
        /// </returns>
        public bool Remove(DeleteWrapOption deleteOption)
        {
            string optIdentId;
            string nextButtonId;

            if (!WebAdapter.ButtonClickById("but_remove"))
            {
                return(false);
            }

            switch (deleteOption)
            {
            case DeleteWrapOption.SoldToAnotherUser:
                optIdentId   = "opt1";
                nextButtonId = "but_cancel";
                break;

            case DeleteWrapOption.SoldToStranger:
                optIdentId   = "opt2";
                nextButtonId = "but_fortsaet2";
                break;

            case DeleteWrapOption.LostWrap:
                optIdentId   = "opt3";
                nextButtonId = "but_ok3";
                break;

            case DeleteWrapOption.BrokenWrap:
                optIdentId   = "opt4";
                nextButtonId = "but_ok4";
                break;

            case DeleteWrapOption.WasAnError:
                optIdentId   = "opt5";
                nextButtonId = "but_ok5";
                break;

            case DeleteWrapOption.ConvertedNonWrap:
                optIdentId   = "opt7";
                nextButtonId = "but_ok7";
                break;

            default:
                return(false);
            }

            // var myChoise = WebAdapter.FindElement(By.Name(optIdentId));
            WebAdapter.ButtonClickById(optIdentId);

            // wait for button to appear
            WebAdapter.WaitForComplete(1);

            var next = WebAdapter.ButtonClickById(nextButtonId);

            // if we managed to press Next, then we are good:-)
            return(next);
        }
Exemplo n.º 8
0
        /// <summary>
        /// The set text by id.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="brand">
        /// The brand.
        /// </param>
        private void SelectDropdownByIdAndText(string id, string brand)
        {
            // mostly for demo purposes - you can follow what happens
            WebAdapter.WaitForComplete(1);

            var elem = WebAdapter.FindElement(By.Id(id));

            elem.SendKeys(brand);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
        /// <summary>
        /// The save.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Save()
        {
            WebAdapter.WaitForComplete(10);

            var retVal = WebAdapter.ButtonClickById("but_add_wrap");

            if (!retVal)
            {
                return(false);
            }

            retVal = AfterSavePageCheck();

            return(retVal);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Add a wrap to users own collection
        /// </summary>
        /// <param name="brand">
        /// The brand fx 'Artipoppe'
        /// </param>
        /// <param name="pattern">
        /// The pattern - fx 'Argus'
        /// </param>
        /// <param name="model">
        /// The model - fx 'The Queen'
        /// </param>
        /// <param name="size">
        /// The size of the wrap - fx 6
        /// </param>
        /// <returns>
        /// false if not possible
        /// </returns>
        public string AddWrap(string brand = null, string pattern = null, string model = null, int size = 6)
        {
            var existingListOfWtIds = GetListOfWtIds();

            // TODO: Is now related to English language
            var typeCarrier = "woven wrap";

            WebAdapter.ButtonClickById("but_add_carrier");

            if (brand == null)
            {
                brand   = "Didymos";
                pattern = "Nino";
                model   = "Blau";
            }

            SelectDropdownByIdAndText("selTypeCarrier", typeCarrier);
            SelectDropdownByIdAndText("sel_brand", brand);
            SelectDropdownByIdAndText("sel_pattern", pattern);
            SelectDropdownByIdAndText("sel_model", model);
            SelectDropdownByIdAndText("selWrapSize", size.ToString());

            // Button says save - we wanna add And Exit
            if (!WebAdapter.ButtonClickById("but_add_wrap"))
            {
                return(null);
            }

            // TODO: the insert of the wrap might take some time...
            // TODO: Implement using Selenium Waiter
            WebAdapter.WaitForComplete(3);

            // gotta fix that after adding a wrap the wrap itself is shown
            // not the collection as it used to
            var me = WrapTrackWebShell.Me();

            me.GetCollection();

            var newListOfWtIds = GetListOfWtIds();
            var diffList       = newListOfWtIds.Except(existingListOfWtIds);
            var enumerable     = diffList as string[] ?? diffList.ToArray();

            // Return the wrap just added or null
            return(enumerable.Length == 1 ? enumerable.First() : null);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        /// <summary>
        /// The add carrier.
        /// </summary>
        /// <typeparam name="T">
        /// The interface for a carrier add
        /// </typeparam>
        /// <returns>
        /// An instance of t
        /// </returns>
        public T AddCarrier <T>()
        {
            WebAdapter.ButtonClickById("but_add_carrier");

            // Give WT time to load the page
            WebAdapter.WaitForComplete(2);

            var selectCarrierType = GetAddCarrierSelectTypeByInterface <T>();

            WebAdapter.SelectElementSetText(By.Id("selTypeCarrier"), selectCarrierType);

            // Selecting the Carrier Type makes the page reload
            WebAdapter.WaitForComplete(2);

            var retVal = Get <T>();

            return(retVal);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Pass on the wrap to user 'username' (only possible for owner of wrap)
        /// </summary>
        /// <param name="username">
        /// The username.
        /// </param>
        /// <param name="ownershipStart">
        /// The ownership Start.
        /// If not set, default date is used
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool PassOn(string username, string ownershipStart = null)
        {
            // click the Pass On Button in the menu
            if (!WebAdapter.ButtonClickByXpath("//button[@id='but_passon']"))
            {
                StfLogger.LogDebug("Couldn't press PassOn button");
                return(false);
            }

            if (!WebAdapter.TextboxSetTextById("inputBrugerSoeg", username, true))
            {
                StfLogger.LogDebug("Couldn't set brugerSoeg text");
                return(false);
            }

            // click the select user button
            if (!WebAdapter.ButtonClickById("but_selUser"))
            {
                StfLogger.LogDebug("Couldn't press SelectUser button");
                return(false);
            }

            // Choose a date for ownership-start
            if (ownershipStart != null)
            {
                WebAdapter.WaitForComplete(TimeSpan.FromSeconds(1));

                if (!WebAdapter.TextboxSetTextById("inp_datePassOn", ownershipStart))
                {
                    StfLogger.LogInfo("Date for ownership not changed");
                    return(false);
                }
            }

            // answer the R U sure
            if (!WebAdapter.ButtonClickById("but_goPassOn"))
            {
                StfLogger.LogDebug("Couldn't press R-U-Sure button");
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
        /// <inheritdoc />
        /// <summary>
        /// The upload pic.
        /// </summary>
        /// <param name="clientSideFilePath">
        /// The client Side File Path.
        /// </param>
        /// <param name="numUploads">
        /// The number of uploads of picture in clientSideFilePath is going to be performed.
        /// </param>
        /// <returns>
        /// The <see cref="T:System.Boolean" />.
        /// </returns>
        public bool UploadWrapImage(string clientSideFilePath, int numUploads = 1)
        {
            // click the button 'Administrate pictures'
            WebAdapter.ButtonClickById("but_adm_pic");

            for (var i = 1; i <= numUploads; i++)
            {
                WebAdapter.WaitForComplete(3);

                // handle the File Upload Dialog
                WebAdapter.NativeDialogFileUpload(By.Id("userfile"), clientSideFilePath);

                WebAdapter.WaitForComplete(3);

                // Press upload the image
                WebAdapter.ButtonClickById("but_doupload");
            }

            WebAdapter.WaitForComplete(3);

            return(true);
        }
        /// <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);
        }