Ejemplo n.º 1
0
        public static void Citeaza(String text)
        {
            var citeaza = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$MessageListView$ctrl0$QuoteLoginView$QuoteMessageButton");

            citeaza.Click();
            AddComment(text);
        }
Ejemplo n.º 2
0
        public static void LogIn(string emailadress, string password)
        {
            try
            {
                SeleniumSetMethod.ElementPresent(txtEmailAdress);
                SeleniumSetMethod.ElementEnabled(txtEmailAdress);
                SeleniumSetMethod.ElementEmpty(txtEmailAdress);
                txtEmailAdress.Clear();
                SeleniumSetMethod.EnterText(txtEmailAdress, emailadress);

                SeleniumSetMethod.ElementPresent(txtPassword);
                SeleniumSetMethod.ElementEnabled(txtPassword);
                SeleniumSetMethod.ElementEmpty(txtPassword);
                txtPassword.Clear();
                SeleniumSetMethod.EnterText(txtPassword, password);

                SeleniumSetMethod.ElementPresent(btnSignIn);
                SeleniumSetMethod.ElementEnabled(btnSignIn);
                SeleniumSetMethod.Submits(btnSignIn);

                string urlSearch = WebDriver.driver.Url;
                SeleniumSetMethod.WaitForPageToLoad(WebDriver.driver, 35);
                SeleniumGetMethods.PageLoaded(urlSearch, "account");
                Console.WriteLine("Login successful!");
            }
            catch (Exception e)
            {
                Console.WriteLine("LogIn failed: {0}", e);
            }
        }
        public static void CartPage()
        {
            SeleniumSetMethods.StepStart("Loads web page (https://www.saucedemo.com/cart.html).", "1");
            SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "cart");
            Console.WriteLine("Menu button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonMenu);
            Console.WriteLine("Cart button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonCart);
            string text = SeleniumGetMethods.GetText(textcart);

            SeleniumGetMethods.VerifyText(text, "1");
            Console.WriteLine("Main text:");
            text = SeleniumGetMethods.GetText(textMain);
            SeleniumGetMethods.VerifyText(text, "Your Cart");
            Console.WriteLine("'QTY' text:");
            text = SeleniumGetMethods.GetText(textQuantity);
            SeleniumGetMethods.VerifyText(text, "QTY");
            Console.WriteLine("'DESCRIPTION' text:");
            text = SeleniumGetMethods.GetText(textDescription);
            SeleniumGetMethods.VerifyText(text, "DESCRIPTION");
            SeleniumGetMethods.VerifyProduct(cartproductcontainer, "1\nSauce Labs Backpack\ncarry.allTheThings() with the sleek, streamlined Sly Pack that melds uncompromising style with unequaled laptop and tablet protection.\n29.99REMOVE");
            Console.WriteLine("'CONTINUE SHOPPING' button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonContinue);
            Console.WriteLine("'CHECKOUT' button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonCheckout);
            Console.WriteLine("Twitter button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonTwitter);
            Console.WriteLine("Fcebook button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonFacebook);
            Console.WriteLine("LinkedIn button:");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonLinkedIn);
            text = SeleniumGetMethods.GetText(textBottom);
            SeleniumGetMethods.VerifyText(text, "© 2021 Sauce Labs. All Rights Reserved. Terms of Service | Privacy Policy");

            SeleniumSetMethods.StepStart("Clicks Menu button.", "2");
            SeleniumSetMethods.Clicks(buttonMenu);
            var wait = new WebDriverWait(WebDriver.driver, TimeSpan.FromSeconds(2));

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='menu_button_container']/div/div[3]/div[2]/div")));
            Console.WriteLine("Button 'X':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
            Console.WriteLine("Button 'All Items':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonAllItems);
            Console.WriteLine("Button 'About':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonAbout);
            Console.WriteLine("Button 'Logout':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonLogout);
            Console.WriteLine("Button 'Reset App State':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(buttonResetAppState);

            SeleniumSetMethods.StepStart("Clicks button 'X' ", "3");
            SeleniumSetMethods.Clicks(buttonX);
            Thread.Sleep(2000);
            SeleniumSetMethods.ElementHidden(buttonX);

            SeleniumSetMethods.StepStart("Clicks 'CHECKOUT' button.", "4");
            SeleniumSetMethods.Clicks(buttonCheckout);
            SeleniumSetMethods.WaitForPageToLoad(WebDriver.driver, 35);
            SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "checkout-step-one");
        }
        public static void SearchProduct(string search)
        {
            Console.WriteLine("Textbox 'Search':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(txtSearch);

            SeleniumSetMethods.StepStart("Clears textbox 'Search'.", "3");
            SeleniumSetMethods.Clears(txtSearch);
            SeleniumSetMethods.ElementEmpty(txtSearch);

            SeleniumSetMethods.StepStart("Enters text 'Razer Laptop' in 'Search' textbox.", "4");
            SeleniumSetMethods.EnterText(txtSearch, search);
            string enteredtext = SeleniumGetMethods.GetValue(txtSearch);

            SeleniumGetMethods.VerifyText(enteredtext, search);
            Console.WriteLine("Button 'Search':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(btnSearch);

            SeleniumSetMethods.StepStart("Submits button 'Search'.", "5");
            SeleniumSetMethods.Submits(btnSearch);
            string urlSearch = WebDriver.driver.Url;

            SeleniumSetMethods.WaitForPageToLoad(WebDriver.driver, 35);
            SeleniumGetMethods.PageLoaded(urlSearch, "search");
            Console.WriteLine("Searched Links web shop for '{0}'!", search);
        }
Ejemplo n.º 5
0
        public static void SearchContent(String content)
        {
            var continutText = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$MessageDescriptionTB");

            continutText.SendKeys(content);
            var cautaButton = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$Button2");

            cautaButton.Click();
        }
Ejemplo n.º 6
0
        public static void SearchAutor(String autor)
        {
            var autorText = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$MessageUserTB");

            autorText.SendKeys(autor);
            var cautaButton = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$Button2");

            cautaButton.Click();
        }
Ejemplo n.º 7
0
        public static void DeleteComment(String comment)
        {
            var commentRootElem = SeleniumGetMethods.Parent(SeleniumGetMethods.GetWebElementInnerHTML(comment));
            var childs          = SeleniumGetMethods.GetChilds(commentRootElem);
            var editeButton     = SeleniumGetMethods.GetFirstChild(SeleniumGetMethods.GetFirstChild((IWebElement)childs[3]));
            var delete          = SeleniumGetMethods.GetNextSibling(editeButton);

            delete.Click();
        }
Ejemplo n.º 8
0
        public void GivenINavigateToCartPage()
        {
            SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "inventory");
            var wait = new WebDriverWait(WebDriver.driver, TimeSpan.FromSeconds(2));

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='shopping_cart_container']/a")));
            SeleniumSetMethods.Clicks(SaucedemoCartPageObjects.buttonCart);
            SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "cart");
        }
Ejemplo n.º 9
0
        public void ExecuteTest()
        {
            //Title
            SeleniumSetMethods.SelectDropDown(driver, "TitleId", "Mr.", "Id");
            //Initial
            SeleniumSetMethods.EnterText(driver, "Initial", "executeautomation", "Name");

            Console.WriteLine("The value from my Title is:" + SeleniumGetMethods.GetTextFromDDL(driver, "TitleId", "Id"));
            Console.WriteLine("The value from my Initial is:" + SeleniumGetMethods.GetText(driver, "Initial", "Name"));
        }
Ejemplo n.º 10
0
        public static void AddComment(String comment)
        {
            var textarea = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$AddMessageLoginView$MessageTB");

            textarea.Clear();
            textarea.SendKeys(comment);
            var addCommentButton = SeleniumGetMethods.GetWebElementByAttribut("value", "Adauga comentariu");

            addCommentButton.Click();
        }
Ejemplo n.º 11
0
        public void ThenTheLoginShouldFailWith(string p0)
        {
            this.Message = p0;
            var    wait        = new WebDriverWait(WebDriver.driver, TimeSpan.FromSeconds(2));
            string messagetext = SeleniumGetMethods.GetText(SaucedemoLogInPageObjects.textMessage);

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@id='login_button_container']/div/form/h3")));
            Assert.IsTrue(messagetext.Contains(Message));
            SeleniumGetMethods.VerifyText(messagetext, Message);
        }
Ejemplo n.º 12
0
        public void GivenILoggedIn()
        {
            WebDriver.driver.Navigate().GoToUrl("https://www.saucedemo.com/");
            SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "saucedemo");
            var wait = new WebDriverWait(WebDriver.driver, TimeSpan.FromSeconds(2));

            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("login-button")));
            SeleniumSetMethods.EnterText(SaucedemoLogInPageObjects.textboxUsername, "standard_user");
            SeleniumSetMethods.EnterText(SaucedemoLogInPageObjects.textboxPassword, "secret_sauce");
            SeleniumSetMethods.Submits(SaucedemoLogInPageObjects.buttonLOGIN);
        }
Ejemplo n.º 13
0
        public static void SelectBrand(string brand)
        {
            ICollection <IWebElement> elements = SeleniumGetMethods.GetElements(Properties.driver, "//div[@id='w3-w12']//span[1]", "xpath");

            foreach (IWebElement element in elements)
            {
                if (element.Text.ToLower().Trim().Equals(brand))
                {
                    element.Click();
                    return;
                }
            }
        }
Ejemplo n.º 14
0
        public void FirstTest()
        {
            //Checking the state of TextBoxes and Button
            SeleniumGetMethods.UserNameTextboxCheck("Username", PropertyType.Name);
            SeleniumGetMethods.PasswordTextboxCheck("Password", PropertyType.Name);
            SeleniumGetMethods.LoginButtonCheck("action", PropertyType.Name);

            //Click on button "Prijava"
            SeleniumSetMethods.Click("action", PropertyType.Name);

            //Getting alert message from the website
            Console.WriteLine("Alert message: " + SeleniumGetMethods.GetText("/html/body/div[1]/div/div/div/div/div/div/div/div", PropertyType.CssName) + "\n");
        }
Ejemplo n.º 15
0
        public static void GetRole(UserRole userRole)
        {
            const int SELECT_ROLE_INDEX_IN_DOM = 4;
            const int SAVE_BUTTON_INDEX_IN_DOM = 5;
            var       tr     = SeleniumGetMethods.Parent(SeleniumGetMethods.Parent(SeleniumGetMethods.GetWebElementInnerHTML(userRole.Username)));
            var       select = SeleniumGetMethods.GetFirstChild(SeleniumGetMethods.GetChild(SELECT_ROLE_INDEX_IN_DOM, tr));

            SeleniumSetMethods.SelectDropDown(select, userRole.Role);
            Sincronize.Wait(2000);
            var save = SeleniumGetMethods.GetFirstChild(SeleniumGetMethods.GetChild(SAVE_BUTTON_INDEX_IN_DOM, tr));

            save.Click();
        }
Ejemplo n.º 16
0
        public void ExtentSetup()
        {
            if (_extent == null)
            {
                var dir = SeleniumGetMethods.getTestDirectory() + "\\";
                //var fileName = this.GetType().ToString() +  ".html";
                var fileName     = "Reporter.html";
                var htmlReporter = new ExtentHtmlReporter(dir + fileName);

                _extent = new ExtentReports();
                _extent.AttachReporter(htmlReporter);
            }
        }
Ejemplo n.º 17
0
        public static void OrderByPriceAscendant()
        {
            SeleniumSetMethods.PerformMovement(Properties.driver, SeleniumGetMethods.GetElement(Properties.driver, "w7", "Id"));
            SeleniumSetMethods.Click(Properties.driver, "//*[@class='srp-sort__menu']/li[4]", "xpath");

            //printing first 5 results in console
            listproduct = SeleniumGetMethods.GetProductsFromList(Properties.driver, 5);

            foreach (Product element in listproduct)
            {
                PrintResults(element.GetTitle());
                PrintResults(element.GetPrice());
            }
        }
Ejemplo n.º 18
0
        public static void LogOff()
        {
            const string LOGOFF_BUTTON_TEXT = "Deconectare";
            var          logOffButton       = SeleniumGetMethods.GetWebElementById("LoginView1_HeadLoginStatus");

            if (!logOffButton.Text.Equals(LOGOFF_BUTTON_TEXT))
            {
                throw new Exception("User is not loged");
            }
            else
            {
                logOffButton.Click();
            }
        }
Ejemplo n.º 19
0
        public void ExecuteTest()
        {
            //Title
            SeleniumSetMethods.SelectDropDown("TitleId", "Mr.", PropertyType.Id);

            //Initial
            SeleniumSetMethods.EnterText("Initial", "executeautomation", PropertyType.Name);

            Console.WriteLine("The value from my Title is: " + SeleniumGetMethods.GetText("TitleId", PropertyType.Id));

            Console.WriteLine("The value from my Initial is: " + SeleniumGetMethods.GetText("Initial", PropertyType.Name));

            //Click
            SeleniumSetMethods.Click("Save", PropertyType.Name);
        }
Ejemplo n.º 20
0
        public static void SelectSize(string size)
        {
            ICollection <IWebElement> elements = SeleniumGetMethods.GetElements(Properties.driver, "//*[@id=\"w3\"]/li[1]/ul/li[2]/ul/li[1]/ul//span[1]", "xpath");

            foreach (IWebElement element in elements)
            {
                if (element.Text.ToLower().Trim().Equals(size))
                {
                    element.Click();
                    return;
                }
            }

            PrintResults("Number of Results: " + SeleniumGetMethods.GetText(Properties.driver, "srp-controls__count-heading", "Class"));
        }
Ejemplo n.º 21
0
 public static void AssertElementDisplayed(IWebElement element)
 {
     try
     {
         if (SeleniumGetMethods.GetElement(element))
         {
             Assert.That(element.Displayed);
             Reporter.AddTestInfo(ProjectUtilities.Utilities.GetCurrentMethod() + " => " + "Elemento encontrado: " + element.GetElementAttribute());
         }
     }
     catch (Exception ex)
     {
         Assert.Fail("{0} Element no displayed", ex);
     }
 }
Ejemplo n.º 22
0
        public void ExecuteTest_CustomControlMethods()
        {
            //navigate to demo site page
            webDriver.Navigate().GoToUrl("http://executeautomation.com/demosite/index.html?UserName=&Password=&Login=Login");

            Console.WriteLine("Opened Demo Site URL");

            //title
            SeleniumSetMethods.SelectDropDown(webDriver, "TitleId", "Mr.", "Id");

            //initial
            SeleniumSetMethods.EnterText(webDriver, "Initial", "M", "Name");

            //first name
            SeleniumSetMethods.EnterText(webDriver, "FirstName", "Michael", "Name");

            //middle name
            SeleniumSetMethods.EnterText(webDriver, "MiddleName", "Lee", "Name");

            //gender
            SeleniumSetMethods.Click(webDriver, "Female", "Name");

            //languages
            SeleniumSetMethods.Click(webDriver, "Hindi", "Name");

            //save button
            SeleniumSetMethods.Click(webDriver, "Save", "Name");

            Console.WriteLine("Executed Save Values");

            Thread.Sleep(1000);

            Console.WriteLine("Get New Values");

            //title
            Console.WriteLine("Title: " + SeleniumGetMethods.GetTextFromDDL(webDriver, "TitleId", "Name"));

            //initial
            Console.WriteLine("Initial: " + SeleniumGetMethods.GetText(webDriver, "Initial", "Name"));

            //first name
            Console.WriteLine("First Name: " + SeleniumGetMethods.GetText(webDriver, "FirstName", "Name"));

            //middle name
            Console.WriteLine("Middle Name: " + SeleniumGetMethods.GetText(webDriver, "MiddleName", "Name"));

            Console.WriteLine("Executed Get New Values");
        }
        public static void SelectPCs()
        {
            SeleniumSetMethods.StepStart("Loads web page (https://www.links.hr/hr/).", "1");
            SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "links");

            Console.WriteLine("Button 'Računala':");
            SeleniumSetMethods.ElementDisplayedAndEnabled(btnRačunala);

            SeleniumSetMethods.StepStart("Clicks button 'Računala'.", "2");
            SeleniumSetMethods.MoveToElement(btnRačunala, WebDriver.driver);
            SeleniumSetMethods.Clicks(btnRačunala);
            string urlSorted = WebDriver.driver.Url;

            SeleniumSetMethods.WaitForPageToLoad(WebDriver.driver, 35);
            SeleniumGetMethods.PageLoaded(urlSorted, "racunala");
        }
Ejemplo n.º 24
0
        public void FifthTest()
        {
            //Checking the state of TextBoxes and Button
            SeleniumGetMethods.UserNameTextboxCheck("Username", PropertyType.Name);
            SeleniumGetMethods.PasswordTextboxCheck("Password", PropertyType.Name);
            SeleniumGetMethods.LoginButtonCheck("action", PropertyType.Name);

            //Entering the correct Username
            SeleniumSetMethods.EnterText("Username", "tester12", PropertyType.Name);

            //Entering the correct Password
            SeleniumSetMethods.EnterText("Password", "Password1!", PropertyType.Name);

            //Click on button "Prijava"
            SeleniumSetMethods.Click("action", PropertyType.Name);
        }
Ejemplo n.º 25
0
        public void TestUserStory1()
        {
            try
            {
                const String INPUT_FILE = "SignUpTest.xml";
                SignUpUser   user       = XML.DeserializeObject <SignUpUser>(FileUtils.CreateInputPath(INPUT_FILE));

                PropertiesCollection.OpenURL(Constants.START_URL);
                Panel.Log_Click();
                SeleniumGetMethods.GetWebElementInnerHTML("Inregistrati-va").Click();
                Authentication.SignUp(user);
            }
            catch (Exception ex)
            {
                Logger.LogException("", ex);
                Assert.Fail(ex.Message);
            }
        }
Ejemplo n.º 26
0
        //For FireFox
        public static void WaitLoadElementByInnerHTML(String innerHTML, int seconds)
        {
            int time = 0;

            try
            {
                var element = SeleniumGetMethods.GetWebElementInnerHTML(innerHTML);
            }
            catch (NoSuchElementException ex)
            {
                time = time + 600;
                System.Threading.Thread.Sleep(100);
                if (time < seconds)
                {
                    WaitLoadElementByInnerHTML(innerHTML, seconds);
                }
            }
        }
Ejemplo n.º 27
0
        public static void SelectProduct()
        {
            try
            {
                SeleniumSetMethod.ElementPresent(btnGoToProduct);
                SeleniumSetMethod.ElementEnabled(btnGoToProduct);
                SeleniumSetMethod.Clicks(btnGoToProduct);

                string urlSelectedProduct = WebDriver.driver.Url;
                SeleniumSetMethod.WaitForPageToLoad(WebDriver.driver, 50);
                SeleniumGetMethods.PageLoaded(urlSelectedProduct, "product");
                Console.WriteLine("Viewing product successful!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Viewing product failed: {0}", e);
            }
        }
Ejemplo n.º 28
0
        public static void EditeComment(String originalComment, String newComment, bool append)
        {
            var commentRootElem = SeleniumGetMethods.Parent(SeleniumGetMethods.GetWebElementInnerHTML(originalComment));
            var childs          = SeleniumGetMethods.GetChilds(commentRootElem);
            var editeButton     = SeleniumGetMethods.GetFirstChild(SeleniumGetMethods.GetFirstChild((IWebElement)childs[3]));

            editeButton.Click();
            var textarea = SeleniumGetMethods.GetWebElementByName("ctl00$MainContent$AddMessageLoginView$EditMessageTB");

            if (!append)
            {
                textarea.Clear();
            }
            else
            {
            }
            textarea.SendKeys(newComment);
            var addCommentButton = SeleniumGetMethods.GetWebElementByAttribut("value", "Salveaza");

            addCommentButton.Click();
        }
Ejemplo n.º 29
0
        public static void GoToPayment()
        {
            try
            {
                SeleniumSetMethod.ElementPresent(chcbxIAgree);
                SeleniumSetMethod.ElementEnabled(chcbxIAgree);
                SeleniumSetMethod.CheckBox(chcbxIAgree);

                SeleniumSetMethod.ElementPresent(btnProccedToPayment);
                SeleniumSetMethod.ElementEnabled(btnProccedToPayment);
                SeleniumSetMethod.Clicks(btnProccedToPayment);

                string urlAdress = WebDriver.driver.Url;
                SeleniumSetMethod.WaitForPageToLoad(WebDriver.driver, 35);
                SeleniumGetMethods.PageLoaded(urlAdress, "shipping");
                Console.WriteLine("Procceded to payment successfully!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Adding Product quantity failed: {0}", e);
            }
        }
Ejemplo n.º 30
0
        public static void EnterProduct(string search)
        {
            try
            {
                SeleniumSetMethod.ElementPresent(txtSearch);
                SeleniumSetMethod.ElementEnabled(txtSearch);
                SeleniumSetMethod.ElementEmpty(txtSearch);
                SeleniumSetMethod.EnterText(txtSearch, search);

                SeleniumSetMethod.ElementPresent(btnSearch);
                SeleniumSetMethod.ElementEnabled(btnSearch);
                SeleniumSetMethod.Submits(btnSearch);

                string urlProducts = WebDriver.driver.Url;
                SeleniumSetMethod.WaitForPageToLoad(WebDriver.driver, 50);
                SeleniumGetMethods.PageLoaded(urlProducts, "shirt");
                Console.WriteLine("Search successful!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Search failed: {0}", e);
            }
        }