Example #1
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);
        }
Example #2
0
        /// <summary>
        /// The logout.
        /// </summary>
        /// <param name="doCareAboutErrors">
        /// Mostly used in close down scenarios - there we just want to close down - not really caring about success or not
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Logout(bool doCareAboutErrors = true)
        {
            if (CurrentLoggedInUser == null)
            {
                return(true);
            }

            CurrentLoggedInUser = null;

            try
            {
                if (WebAdapter.Click(By.XPath("//img[@alt='avatar']")))
                {
                    if (WebAdapter.Click(By.XPath("//a[@href='/Account/LogOff']")))
                    {
                        return(true);
                    }
                }

                if (doCareAboutErrors)
                {
                    StfLogger.LogError("Got error while logging out");
                }
            }
            catch
            {
                // slurp
            }

            // if we cant click the logout button, then the return value is down to if we care or not:-)
            return(doCareAboutErrors);
        }
Example #3
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);
        }
Example #4
0
        /// <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, BtoWebConfiguration.UserName);
            password = HandleDefault(password, BtoWebConfiguration.Password);

            // CLick the login
            if (!WebAdapter.Click(By.XPath("//a[@href='/Account/Login']")))
            {
                StfLogger.LogError("Couldn't press login");
                return(false);
            }

            // fill in credentials
            WebAdapter.TextboxSetTextById("Email", userName);
            WebAdapter.TextboxSetTextById("password", password);

            // Click tab page Login
            WebAdapter.ButtonClickByXpath("//button[text()='Log in']");

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

            return(true);
        }
Example #5
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;
            }
        }
Example #6
0
        /// <summary>
        /// Gets or sets the all.
        /// </summary>
        /// <returns>
        /// The <see cref="IAllBrands"/>.
        /// </returns>
        public IAllBrands All()
        {
            var clicked = WebAdapter.ButtonClickByXpath("//a[normalize-space()='all']");
            var retVal  = clicked ? Get <IAllBrands>() : null;

            return(retVal);
        }
Example #7
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);
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
        }
Example #11
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);
        }
        /// <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>
        /// 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);
        }
        /// <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);
        }
        static void Main(string[] args)
        {
            IWeb       web        = null;
            WebAdapter webAdapter = new WebAdapter(web);

            webAdapter.Send();
        }
        public WebEasyTestFixtureHelperBase(string relativePathToWebApplication)
        {
            var testApplicationDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), relativePathToWebApplication);

            application = new TestApplication
            {
                IgnoreCase = true,
            };

            var doc = new XmlDocument();

            var additionalAttributes = new List <XmlAttribute>
            {
                CreateAttribute(doc, "PhysicalPath", testApplicationDir),
                CreateAttribute(doc, "URL", $"{testWebApplicationRootUrl}{GetUrlOptions()}"),
                CreateAttribute(doc, "SingleWebDev", true),
                CreateAttribute(doc, "DontRestartIIS", true),
                CreateAttribute(doc, "UseIISExpress", true),
            };

            application.AdditionalAttributes = additionalAttributes.ToArray();

            webAdapter = new WebAdapter();
            webAdapter.RunApplication(application, InMemoryDataStoreProvider.ConnectionString);
            adapter        = webAdapter.CreateCommandAdapter();
            commandAdapter = new TestCommandAdapter(adapter, application);
        }
Example #17
0
        /// <summary>
        /// The go menu.
        /// </summary>
        /// <param name="menuName">
        /// The menu name.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool GoMenu(string menuName)
        {
            var xpath  = $"//div[@class='submenu2']/a[text()='{menuName}']";
            var retVal = WebAdapter.ButtonClickByXpath(xpath);

            return(retVal);
        }
        /// <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);
        }
Example #19
0
        /// <summary>
        /// The select and open brand.
        /// </summary>
        /// <param name="brandName">
        /// The brand name.
        /// </param>
        /// <returns>
        /// The <see cref="IBrand"/>.
        /// </returns>
        public IBrand SelectAndOpenBrand(string brandName)
        {
            var xpath   = $"//p[normalize-space()='{brandName.Trim()}']/../div";
            var clicked = WebAdapter.ButtonClickByXpath(xpath);
            var retVal  = clicked ? Get <IBrand>() : null;

            return(retVal);
        }
Example #20
0
        /// <summary>
        /// Open a registered brand.
        /// </summary>
        /// <param name="brandName">
        /// The brand name.
        /// </param>
        /// <returns>
        /// The <see cref="IBrand"/>.
        /// </returns>
        public IBrand OpenRegisteredBrand(string brandName)
        {
            var xPath   = $"//a[text()='{brandName}']";
            var clicked = WebAdapter.Click(By.XPath(xPath));
            var retVal  = clicked ? Get <IBrand>() : default(IBrand);

            return(retVal);
        }
Example #21
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);
        }
Example #22
0
        /// <summary>
        /// The review.
        /// </summary>
        /// <returns>
        /// The <see cref="IModelReview"/>.
        /// </returns>
        public IModelReview Review()
        {
            WebAdapter.ButtonClickById("butReview");

            var retVal = Get <IModelReview>();

            return(retVal);
        }
Example #23
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);
        }
        /// <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);
        }
        /// <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 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);
        }
Example #29
0
 private void createAndStartThreads()
 {
     try
     {
         int threadCount = Convert.ToInt16(cmbThreadCount.Text);
         if (threadCount > users.Count)
         {
             threadCount = users.Count;
         }
         if (searchStrings.Count == 0)
         {
             MessageBox.Show("Enter search criterias.");
             return;
         }
         IList <IList <User> > listofUsers = new List <IList <User> >();
         for (int i = 0; i < threadCount; i++)
         {
             listofUsers.Add(new List <User>());
         }
         for (int i = 0; i < users.Count; i++)
         {
             listofUsers[i % threadCount].Add(users[i]);
         }
         IList <VideoExtractorAndCommenter> extractorAndCommenters = new List <VideoExtractorAndCommenter>();
         for (int i = 0; i < threadCount; i++)
         {
             IAdapter                   adapter                    = new WebAdapter(searchStrings[i % searchStrings.Count], 1);
             IYouTubeAccountPool        pool                       = new YouTubeAccountPool(listofUsers[i], (int)delayMinute.Value);
             ICommentRepository         commentRepository          = new CommentRepository();
             IVideoCommenter            videoCommenter             = new VideoCommenter(pool, commentRepository);
             VideoExtractorAndCommenter videoExtractorAndCommenter = new VideoExtractorAndCommenter(adapter, videoCommenter, (int)minViewCount.Value);
             extractorAndCommenters.Add(videoExtractorAndCommenter);
         }
         for (int i = threadCount; i < searchStrings.Count; i++)
         {
             extractorAndCommenters[i % threadCount].addSearchStringPhrase(searchStrings[i]);
         }
         foreach (VideoExtractorAndCommenter commenter in extractorAndCommenters)
         {
             threads.Add(new System.Threading.Thread(new System.Threading.ThreadStart(commenter.extractVideosAndInsertAComment))
             {
                 IsBackground = true
             });
         }
         for (int i = 0; i < threadCount; i++)
         {
             threads[i].Start();
         }
         //new System.Threading.Thread(new System.Threading.ThreadStart(this.test)).Start();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
        /// <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);
        }