Esempio n. 1
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;
            }
        }
        /// <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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
        /// <summary>
        /// The select made of wrap.
        /// </summary>
        /// <param name="wrapName">
        /// The wrap name. If null, then pick a random one in the list
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool SelectMadeOfWrap(string wrapName = null)
        {
            var wrapToChose = wrapName;
            var selectElem  = WebAdapter.FindElement(By.Id("selConvertSuggestions"));

            if (selectElem == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(wrapToChose))
            {
                // Okay no name given - we will pick a random one...
                var options         = selectElem.FindElements(By.XPath("./option"));
                var numberOfOptions = options.Count;

                if (numberOfOptions < 1)
                {
                    return(false);
                }

                var numberToChoose = new Random().Next(2, numberOfOptions);

                wrapToChose = options[numberToChoose].Text.Trim();
            }

            var retVal = WebAdapter.SelectElementSetText(By.Id("selConvertSuggestions"), wrapToChose);

            return(retVal);
        }
Esempio n. 6
0
        /// <summary>
        /// The actual image related to users profile
        /// </summary>
        /// <returns>
        /// NULL if no image related, otherwise the SRC path
        /// </returns>
        public string ActualImage()
        {
            var image  = WebAdapter.FindElement(By.Id("img_profile"));
            var retVal = image?.GetAttribute("src");

            return(retVal);
        }
Esempio n. 7
0
        /// <summary>
        /// Upload an profile image
        /// </summary>
        /// <param name="clientSideFilePath">
        /// The client Side File Path.
        /// </param>
        /// <returns>
        /// Inidcation of success
        /// </returns>
        public bool UploadProfileImage(string clientSideFilePath)
        {
            // Visit upload page
            WebAdapter.ButtonClickById("nav_upload_profile");

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

            var submitButton = WebAdapter.FindElement(By.Id("but_doupload"));

            if (submitButton == null)
            {
                StfLogger.LogError("Couldn't find the upload button");

                return(false);
            }

            submitButton.Click();

            // Back to me again
            var navBack = WebAdapter.FindElement(By.Id("but_back"));

            navBack.Click();

            return(true);
        }
Esempio 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);
        }
        /// <summary>
        /// The page check. Are we on the AddCarrier page or not
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool AfterSavePageCheck()
        {
            // TODO: Retrier: Wait 3 seconds for this to GO away.. Not check if it is there
            System.Threading.Thread.Sleep(2000);

            var elem   = WebAdapter.FindElement(By.XPath("//h1[text()='Add carrier']"), 3);
            var retVal = elem == null;

            return(retVal);
        }
        /// <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);
        }
        /// <summary>
        /// The text-feedback to user
        /// </summary>
        /// <param name="infoType">
        /// The info Type.
        /// </param>
        /// <returns>
        /// True if text-feedback found
        /// </returns>
        public bool InfoText(string infoType)
        {
            try
            {
                var svar   = WebAdapter.FindElement(By.Id(infoType));
                var retVal = svar != null;

                return(retVal);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        /// <summary>
        /// The sign up.
        /// </summary>
        /// <param name="newUserName">
        /// The new user name.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool SignUp(string newUserName, string password)
        {
            WebAdapter.ButtonClickById("nav_login");
            WebAdapter.TextboxSetTextById("input_newuser", newUserName);
            WebAdapter.TextboxSetTextById("input_newPW", password);
            WebAdapter.TextboxSetTextById("input_email", newUserName + "@mitsite.org");
            WebAdapter.CheckBoxSetValueById("check_cond", true);
            WebAdapter.ButtonClickById("OpretProfilKnap");

            // when debugging, we probably want to get to the signed up user
            StfLogger.LogKeyValue("SignUpUserName", newUserName, "SignUpUserName");
            StfLogger.LogKeyValue("SignUpPassword", password, "SignUpPassword");

            // Check If still on LOGIN page <h1>Login</h1> - if so then the signup failed
            var loginHeader = WebAdapter.FindElement(By.XPath("//h1[text='Login']"), 2);
            var retVal      = loginHeader == null || CheckSignUpValidationMessages();

            ChooseEnglish();

            return(retVal);
        }