Exemplo 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;
            }
        }
Exemplo n.º 2
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);
        }
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
        /// <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.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// The review.
        /// </summary>
        /// <returns>
        /// The <see cref="IModelReview"/>.
        /// </returns>
        public IModelReview Review()
        {
            WebAdapter.ButtonClickById("butReview");

            var retVal = Get <IModelReview>();

            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);
        }
Exemplo n.º 9
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.º 10
0
        /// <summary>
        /// Gets the brands.
        /// </summary>
        /// <returns>
        /// The <see cref="IBrands"/>.
        /// </returns>
        public IBrands Brands()
        {
            //var gone = GoMenu("brands");
            WebAdapter.ButtonClickById("nav_explore");
            var gone   = WebAdapter.ButtonClickById("nav_brands");
            var retVal = gone
                       ? Get <IBrands>()
                       : default(IBrands);

            return(retVal);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the wrap.
        /// </summary>
        /// <returns>
        /// The <see cref="IWraps"/>.
        /// </returns>
        public IWraps Wraps()
        {
            //var gone = GoMenu("wraps");
            WebAdapter.ButtonClickById("nav_explore");
            var gone   = WebAdapter.ButtonClickById("nav_wraps");
            var retVal = gone
                       ? Get <IWraps>()
                       : default(IWraps);

            return(retVal);
        }
        /// <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.º 13
0
        /// <summary>
        /// Ask for the wrap (only possible for not-owner of wrap)
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool AskFor()
        {
            if (!WebAdapter.ButtonClickById("but_please"))
            {
                StfLogger.LogDebug("Couldn't press 'Request wrap'");
                return(false);
            }

            if (!WebAdapter.ButtonClickById("but-ReqWrapOK"))
            {
                StfLogger.LogDebug("Couldn't press 'Request wrap sec time'");
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
        /// <summary>
        /// The save.
        /// </summary>
        /// <returns>
        /// The <see cref="IBrand"/>.
        /// </returns>
        public IBrand Save()
        {
            // TODO Introduce a SetCheckBoxById("bekraeft", true);
            var checkBoxChecked = WebAdapter.ButtonClickById("bekraeft");

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

            var clicked = WebAdapter.ButtonClickById("save");
            var retVal  = clicked
                       ? Get <IBrand>()
                       : null;

            return(retVal);
        }
Exemplo n.º 15
0
        /// <summary>
        /// The add model.
        /// </summary>
        /// <param name="modelName">
        /// The model name.
        /// </param>
        /// <param name="pattern">
        /// The pattern.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool AddModel(string modelName, string pattern = null)
        {
            const string AddModelXpath = "//span/span[text()='Add model']";
            var          retVal        = WebAdapter.ButtonClickByXpath(AddModelXpath);

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

            // if pattern is null, then create model without pattern
            if (string.IsNullOrEmpty(pattern))
            {
                pattern = "--- without pattern ---";
            }

            const string PatternNameXpath = "//p[normalize-space()='Pattern']/../..//select";

            retVal = WebAdapter.SelectElementSetText(By.XPath(PatternNameXpath), pattern);

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

            const string ModelNameXpath = "//p[normalize-space()='Model']/../..//input";

            retVal = WebAdapter.TextboxSetTextByXpath(ModelNameXpath, modelName);

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

            retVal = WebAdapter.ButtonClickById("create");

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

            // Yeap done
            retVal = WebAdapter.ButtonClickById("modelDone");

            return(retVal);
        }
Exemplo n.º 16
0
        /// <summary>
        /// The delete model.
        /// </summary>
        /// <param name="modelNameToDelete">
        /// The model name to delete.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool DeleteModel(string modelNameToDelete)
        {
            // Press administration
            var retVal = WebAdapter.ButtonClickById("admin");

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

            // open the right pattern
            var xPath = $"//a[text()='{modelNameToDelete}']";

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

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

            // Press delete
            retVal = WebAdapter.ButtonClickById("deleteModel");

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

            // Yeap I'm sure
            retVal = WebAdapter.ButtonClickById("okDeleteModel");

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

            // Exit Admin mode
            retVal = WebAdapter.ButtonClickByXpath("//button[normalize-space()='Show']");

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

            return(true);
        }
Exemplo n.º 17
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.º 18
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.º 19
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);
        }
        /// <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);
        }
        /// <summary>
        /// The learn more.
        /// </summary>
        /// <returns>
        /// Indication of success
        /// </returns>
        /// <summary>
        /// The login.
        /// </summary>
        /// <param name="userName">
        /// The user name.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        public bool Login(string userName = null, string password = null)
        {
            // Handle defaults for username password
            userName = HandleDefault(userName, WtConfiguration.UserName);
            password = HandleDefault(password, WtConfiguration.Password);

            // Click tab page Login
            WebAdapter.ButtonClickById("nav_login");

            // fill in creds
            WebAdapter.TextboxSetTextById("input_username", userName);
            WebAdapter.TextboxSetTextById("input_pw", password);

            // Click tab page Login
            WebAdapter.ButtonClickById("nav_");

            // Remember the last logged in user
            CurrentLoggedInUser = userName;

            return(true);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
        /// <summary>
        /// The send away temporarily.
        /// </summary>
        /// <param name="sendAwayReason">
        /// The send away reason.
        /// </param>
        /// <param name="recipient">
        /// The recipient.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool SendAwayTemporarily(SendAwayReason sendAwayReason, string recipient)
        {
            string inputValue;

            // click the SendAwayTemp button
            WebAdapter.ButtonClickById("but_sendonholiday");

            switch (sendAwayReason)
            {
            case SendAwayReason.Holiday:
                inputValue = "ferie";
                break;

            case SendAwayReason.Tester:
                inputValue = "test";
                break;

            case SendAwayReason.Rent:
                inputValue = "udlejning";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(sendAwayReason), sendAwayReason, null);
            }

            var xPath = $"//input[@value='{inputValue}']";

            WebAdapter.ButtonClickByXpath(xPath);

            // now chose the recipient
            WebAdapter.TextboxSetTextById("inputBrugerSoeg_ferievikle", recipient, true);
            WebAdapter.ButtonClickById("but_chooseUser");

            // press ok
            var retVal = WebAdapter.ButtonClickById("but_ok1_vaelg");

            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);
        }