示例#1
0
 public void PopulateAddNewPayeeForm(string PayeeName, string PayeeAddress, string PayeeAccount, string PayeeDetails)
 {
     SeleniumSetMethods.EnterText(txtPayeeName, PayeeName);
     SeleniumSetMethods.EnterText(txtPayeeAddress, PayeeAddress);
     SeleniumSetMethods.EnterText(txtPayeeAccount, PayeeAccount);
     SeleniumSetMethods.EnterText(txtPayeeDetails, PayeeDetails);
 }
示例#2
0
 public void FillTransferMoneyAndMakePayment(string FromAcc, string ToAcc, string Amount, string Description)
 {
     SeleniumSetMethods.SelectDropDown(optFromAccount, FromAcc);
     SeleniumSetMethods.SelectDropDown(optToAccount, ToAcc);
     SeleniumSetMethods.EnterText(txtAmount, Amount);
     SeleniumSetMethods.EnterText(txtDescription, Description);
 }
        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);
        }
示例#4
0
        public void GivenIEnteredCorrectPassword(string p0)
        {
            this.CorrectPassword = p0;
            var wait = new WebDriverWait(WebDriver.driver, TimeSpan.FromSeconds(2));

            wait.Until(ExpectedConditions.ElementIsVisible(By.Name("password")));
            SeleniumSetMethods.EnterText(SaucedemoLogInPageObjects.textboxPassword, CorrectPassword);
        }
示例#5
0
        public void GivenIEnteredCorrectUsername(string p0)
        {
            this.CorrectUsername = p0;
            var wait = new WebDriverWait(WebDriver.driver, TimeSpan.FromSeconds(2));

            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("user-name")));
            SeleniumSetMethods.EnterText(SaucedemoLogInPageObjects.textboxUsername, CorrectUsername);
        }
示例#6
0
 public void PopulateFindTransactionsForm(string Description, string FromDates, string ToDates, string FromAmount, string ToAmount, string Type)
 {
     SeleniumSetMethods.EnterText(txtAaDescription, Description);
     SeleniumSetMethods.EnterText(txtAaFromDate, FromDates);
     SeleniumSetMethods.EnterText(txtAaToDate, ToDates);
     SeleniumSetMethods.EnterText(txtAaFromAmount, FromAmount);
     SeleniumSetMethods.EnterText(txtAaToAmount, ToAmount);
     SeleniumSetMethods.SelectDropDown(ddmAaType, Type);
 }
示例#7
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);
        }
示例#8
0
        public void PopulatePaymentToSavedPayees(string Payee, string Account, string Amount, string Date, string Description)
        {
            SeleniumSetMethods.SelectDropDown(ddmPayee, Payee);
            SeleniumSetMethods.SelectDropDown(ddmSpAccount, Account);
            SeleniumSetMethods.EnterText(txtSpAmount, Amount);
            SeleniumSetMethods.EnterText(txtSpDate, Date);
            AccountSummaryPage page = new AccountSummaryPage();

            page.txtSpAmount.Click();
            SeleniumSetMethods.EnterText(txtSpDescription, Description);
        }
示例#9
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);
        }
示例#10
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");
        }
示例#11
0
        public void ThirdTest()
        {
            //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 Password
            SeleniumSetMethods.EnterText("Password", "Password1!", 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");
        }
示例#12
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);
        }
        public static void LogIn(string correctusername, string correctpassword, string incorrectusername, string incorrectpassword)
        {
            try
            {
                SeleniumSetMethods.StepStart("Loads web page (https://www.saucedemo.com/).", "1");
                SeleniumGetMethods.PageLoaded(WebDriver.driver.Url, "saucedemo");
                Console.WriteLine("Text box 'Username':"******"Text box 'Password':"******"Button 'LOGIN':"******"\r", string.Empty);
                SeleniumGetMethods.VerifyText(Usernames, "Accepted usernames are:\nstandard_user\nlocked_out_user\nproblem_user\nperformance_glitch_user");


                string Password = SeleniumGetMethods.GetText(textPassword).Replace("\r", string.Empty);
                SeleniumGetMethods.VerifyText(Password, "Password for all users:\nsecret_sauce");

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "2");
                SeleniumSetMethods.Submits(buttonLOGIN);
                Console.WriteLine("Button 'X':");
                SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
                string message = SeleniumGetMethods.GetText(textMessage);
                SeleniumGetMethods.VerifyText(message, "Epic sadface: Username is required");

                SeleniumSetMethods.StepStart("Enters incorrect password.", "3");
                SeleniumSetMethods.EnterText(textboxPassword, incorrectpassword);
                string enteredtext = SeleniumGetMethods.GetValue(textboxPassword);
                SeleniumGetMethods.VerifyText(enteredtext, incorrectpassword);

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "4");
                SeleniumSetMethods.Submits(buttonLOGIN);
                Console.WriteLine("Button 'X':");
                SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
                message = SeleniumGetMethods.GetText(textMessage);
                SeleniumGetMethods.VerifyText(message, "Epic sadface: Username is required");

                SeleniumSetMethods.StepStart("Clears 'Password' textbox.", "5");
                SeleniumSetMethods.Clears(textboxPassword);
                SeleniumSetMethods.ElementEmpty(textboxPassword);

                SeleniumSetMethods.StepStart("Enters incorrect username.", "6");
                SeleniumSetMethods.EnterText(textboxUsername, incorrectusername);
                enteredtext = SeleniumGetMethods.GetValue(textboxUsername);
                SeleniumGetMethods.VerifyText(enteredtext, incorrectusername);

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "7");
                SeleniumSetMethods.Submits(buttonLOGIN);
                Console.WriteLine("Button 'X':");
                SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
                message = SeleniumGetMethods.GetText(textMessage);
                SeleniumGetMethods.VerifyText(message, "Epic sadface: Password is required");

                SeleniumSetMethods.StepStart("Clears 'Username' textbox.", "8");
                SeleniumSetMethods.Clears(textboxUsername);
                SeleniumSetMethods.ElementEmpty(textboxUsername);

                SeleniumSetMethods.StepStart("Enters incorrect username and password.", "9");
                SeleniumSetMethods.EnterText(textboxUsername, incorrectusername);
                SeleniumSetMethods.EnterText(textboxPassword, incorrectpassword);
                enteredtext = SeleniumGetMethods.GetValue(textboxUsername);
                SeleniumGetMethods.VerifyText(enteredtext, incorrectusername);
                enteredtext = SeleniumGetMethods.GetValue(textboxPassword);
                SeleniumGetMethods.VerifyText(enteredtext, incorrectpassword);

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "10");
                SeleniumSetMethods.Submits(buttonLOGIN);
                Console.WriteLine("Button 'X':");
                SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
                message = SeleniumGetMethods.GetText(textMessage);
                SeleniumGetMethods.VerifyText(message, "Epic sadface: Username and password do not match any user in this service");

                SeleniumSetMethods.StepStart("Clears 'Username' and ‘Password’ textboxes.", "11");
                SeleniumSetMethods.Clears(textboxUsername);
                SeleniumSetMethods.Clears(textboxPassword);
                SeleniumSetMethods.ElementEmpty(textboxUsername);
                SeleniumSetMethods.ElementEmpty(textboxPassword);

                SeleniumSetMethods.StepStart("Enters incorrect username and correct password.", "12");
                SeleniumSetMethods.EnterText(textboxUsername, incorrectusername);
                SeleniumSetMethods.EnterText(textboxPassword, correctpassword);
                enteredtext = SeleniumGetMethods.GetValue(textboxUsername);
                SeleniumGetMethods.VerifyText(enteredtext, incorrectusername);
                enteredtext = SeleniumGetMethods.GetValue(textboxPassword);
                SeleniumGetMethods.VerifyText(enteredtext, correctpassword);

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "13");
                SeleniumSetMethods.Submits(buttonLOGIN);
                Console.WriteLine("Button 'X':");
                SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
                message = SeleniumGetMethods.GetText(textMessage);
                SeleniumGetMethods.VerifyText(message, "Epic sadface: Username and password do not match any user in this service");

                SeleniumSetMethods.StepStart("Clears 'Username' and 'Password' textboxes.", "14");
                SeleniumSetMethods.Clears(textboxUsername);
                SeleniumSetMethods.Clears(textboxPassword);
                SeleniumSetMethods.ElementEmpty(textboxUsername);
                SeleniumSetMethods.ElementEmpty(textboxPassword);

                SeleniumSetMethods.StepStart("Enters correct username and incorrect password.", "15");
                SeleniumSetMethods.EnterText(textboxUsername, correctusername);
                SeleniumSetMethods.EnterText(textboxPassword, incorrectpassword);
                enteredtext = SeleniumGetMethods.GetValue(textboxUsername);
                SeleniumGetMethods.VerifyText(enteredtext, correctusername);
                enteredtext = SeleniumGetMethods.GetValue(textboxPassword);
                SeleniumGetMethods.VerifyText(enteredtext, incorrectpassword);

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "16");
                SeleniumSetMethods.Submits(buttonLOGIN);
                Console.WriteLine("Button 'X':");
                SeleniumSetMethods.ElementDisplayedAndEnabled(buttonX);
                message = SeleniumGetMethods.GetText(textMessage);
                SeleniumGetMethods.VerifyText(message, "Epic sadface: Username and password do not match any user in this service");

                SeleniumSetMethods.StepStart("Clears 'Username' and 'Password' textboxes.", "17");
                SeleniumSetMethods.Clears(textboxUsername);
                SeleniumSetMethods.Clears(textboxPassword);
                SeleniumSetMethods.ElementEmpty(textboxUsername);
                SeleniumSetMethods.ElementEmpty(textboxPassword);

                SeleniumSetMethods.StepStart("Enters correct username and correct password.", "18");
                SeleniumSetMethods.EnterText(textboxUsername, correctusername);
                SeleniumSetMethods.EnterText(textboxPassword, correctpassword);
                enteredtext = SeleniumGetMethods.GetValue(textboxUsername);
                SeleniumGetMethods.VerifyText(enteredtext, correctusername);
                enteredtext = SeleniumGetMethods.GetValue(textboxPassword);
                SeleniumGetMethods.VerifyText(enteredtext, correctpassword);

                SeleniumSetMethods.StepStart("Submits button 'LOGIN'.", "19");
                SeleniumSetMethods.Submits(buttonLOGIN);
                string urlInventory = WebDriver.driver.Url;
                SeleniumSetMethods.WaitForPageToLoad(WebDriver.driver, 35);
                SeleniumGetMethods.PageLoaded(urlInventory, "inventory");
                Console.WriteLine("Login successful!");
            }
            catch (Exception e)
            {
                throw new Exception(String.Format("Test failed! {0}", e.StackTrace));
            }
        }
示例#14
0
 public static void SearchProduct(string value)
 {
     SeleniumSetMethods.EnterText(Properties.driver, "gh-ac", value, "Id");
     SeleniumSetMethods.Click(Properties.driver, "gh-btn", "Id");
     SeleniumSetMethods.Wait(Properties.driver, "srp-river-results", "Id");
 }
示例#15
0
        public bool LaunchPurchase(DesiredShoe shoe)
        {
            ShippingInformation shipping = _shippingAndBillingService.GetShippingInformation();
            BillingInformation  billing  = _shippingAndBillingService.GetBillingInformation();
            IWebDriver          driver   = _webDriver;

            driver.Navigate().GoToUrl(shoe.URL);

            bool unreleased = false;

            while (!unreleased)
            {
                try
                {
                    driver.Navigate().GoToUrl(shoe.URL);

                    var notifyButton = driver.FindElement(By.CssSelector(".product-info .cta-btn"));
                    if (notifyButton.Text.Contains("Notify", StringComparison.OrdinalIgnoreCase))
                    {
                        unreleased = false;
                    }
                    //else
                    //{
                    //    driver.Quit();
                    //}
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    unreleased = true;
                }
                //if (notifyButton.Text.Contains("Notify", StringComparison.OrdinalIgnoreCase))
                //{
                //    unreleased = true;
                //}
                System.Threading.Thread.Sleep(shoe.RefreshInterval);
                Console.WriteLine("refreshed at " + DateTime.Now.ToString());
            }

            // Select Size
            SeleniumSetMethods.Click(driver, "label", FindBy.Class);
            System.Threading.Thread.Sleep(250); ////////////////////////////////

            // 10.5 on Chrome???
            // 11.5 on Firefox
            //SeleniumSetMethods.Click(driver, ".size:nth-child(12) > .size-grid-dropdown", FindBy.CssSelector);
            //SeleniumSetMethods.Click(driver, ".size:nth-child(17) > .size-grid-dropdown", FindBy.CssSelector);
            bool foundSize = false;

            for (int i = 1; i < 20; ++i)
            {
                if (SeleniumSetMethods.ClickAndVerifyText(driver,
                                                          ".size:nth-child(" + i.ToString() + ") > .size-grid-dropdown",
                                                          FindBy.CssSelector,
                                                          shoe.TargetSize))
                {
                    foundSize = true;
                    break;
                }
                //else
                //{
                //    //Console.WriteLine("attempted nth-child: " + i.ToString());
                //}
            }
            if (!foundSize)
            {
                //Console.WriteLine("Unable to find correct shoe size.");
                return(false);
            }
            System.Threading.Thread.Sleep(500); ////////////////////////////////

            // Add to cart
            SeleniumSetMethods.Click(driver, ".ncss-btn-black", FindBy.CssSelector);

            System.Threading.Thread.Sleep(500); ////////////////////////////////

            // Checkout
            SeleniumSetMethods.Click(driver, ".ncss-btn-black:nth-child(2)", FindBy.CssSelector);

            System.Threading.Thread.Sleep(500); ////////////////////////////////

            // Continue as guest
            SeleniumSetMethods.Click(driver, "qa-guest-checkout", FindBy.Id);

            System.Threading.Thread.Sleep(500); ////////////////////////////////

            // Shipping Information
            SeleniumSetMethods.EnterText(driver, "firstName", shipping.FirstName, FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "lastName", shipping.LastName, FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "address1", shipping.Address1, FindBy.Id);
            // need to expand address2 section here
            SeleniumSetMethods.EnterText(driver, "city", shipping.City, FindBy.Id);
            SeleniumSetMethods.SelectDropDown(driver, "state", shipping.State, FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "postalCode", shipping.ZipCode, FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "email", shipping.Email, FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "phoneNumber", shipping.PhoneNumber, FindBy.Id);

            // Save and Continue Button
            SeleniumSetMethods.Click(driver, ".js-next-step", FindBy.CssSelector);

            // Continue to Payment
            SeleniumSetMethods.Click(driver, ".js-next-step", FindBy.CssSelector);

            System.Threading.Thread.Sleep(1000); ///////////////////////////////

            driver.SwitchTo().Frame(4);

            // Billing Information
            string ccn = billing.CreditCardNumber;

            SeleniumSetMethods.EnterText(driver, "creditCardNumber", ccn.Substring(0, 4), FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "creditCardNumber", ccn.Substring(4, 4), FindBy.Id);
            string creditCardNumber = ccn.Substring(8);

            foreach (var c in creditCardNumber.ToCharArray())
            {
                SeleniumSetMethods.EnterText(driver, "creditCardNumber", c.ToString(), FindBy.Id);
            }

            SeleniumSetMethods.EnterText(driver, "expirationDate", billing.ExpirationDate, FindBy.Id);
            SeleniumSetMethods.EnterText(driver, "cvNumber", billing.CVV2, FindBy.Id);

            if (Constants.DEBUG_MODE)
            {
                driver.Quit();
                return(false); //works
            }

            driver.SwitchTo().ParentFrame();//relative=parent
            // Purchase
            SeleniumSetMethods.Click(driver, ".d-lg-ib", FindBy.CssSelector);
            return(true);
        }