示例#1
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");
        }
示例#2
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());
            }
        }
示例#3
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);
        }
示例#4
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");
        }
示例#5
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);
        }
示例#6
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");
 }
示例#7
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);
        }