Пример #1
0
        public void Run_Test(int radiobutton , int addons)
        {
            driver.Navigate().GoToUrl("https://secure.safebytes.com/driverassist/14/register/?an=DRIV&ec=0&os=%D0%9C%D0%B0%D0%B9%D0%BA%D1%80%D0%BE%D1%81%D0%BE%D1%84%D1%82%20Windows%208.1%20%D0%9A%D0%BE%D1%80%D0%BF%D0%BE%D1%80%D0%B0%D1%82%D0%B8%D0%B2%D0%BD%D0%B0%D1%8F&osb=64bit&pr=AMD%20FX(tm)-8320%20Eight-Core%20Processor%20&mb=ASUSTeK%20Computer%20INC.%20&vc=NVIDIA%20GeForce%20GT%20630%20%20&ram=15%2C98%20GB&hd=232%2C88%20GB");

            IWebElement query = driver.FindElement(By.CssSelector("button.activate-now"));
            query.SendKeys(Keys.Enter);
            System.Threading.Thread.Sleep(5000);
            switch (radiobutton)
            {
                // Select 2 years plan ( left )
                case 1:
                    driver.FindElement(By.Id("donev")).Click();
                    break;
                // Select 6 months ( center)
                case 2:
                    driver.FindElement(By.Id("twov")).Click();
                    break;
                // Select 1 year ( right)
                case 3:
                    driver.FindElement(By.Id("dthreev")).Click();
                    break;
                // do nothing leave all as is ( preselected both addons )
                case 0:
                    break;
            }
            System.Threading.Thread.Sleep(5000);
            switch (addons)
            {
                case 1:
                    // here we UNselect SAF
                    driver.FindElement(By.XPath("//form[@id='select_form']/div/div[2]/div[3]/div[2]/div[7]/span")).Click();
                    break;
                case 2:
                    // here we UNselect TSC
            driver.FindElement(By.XPath("//form[@id='select_form']/div/div[2]/div[3]/div[2]/div[7]/div[2]/span")).Click();
                    break;

                // here we UNselect SAF + TSC
                case 12:
                    // here we UNselect SAF
                    driver.FindElement(By.XPath("//form[@id='select_form']/div/div[2]/div[3]/div[2]/div[7]/span")).Click();
                    // here we UNselect TSC
                driver.FindElement(By.XPath("//form[@id='select_form']/div/div[2]/div[3]/div[2]/div[7]/div[2]/span")).Click();
                    break;
                // do nothing leave preselected 6 months
                case 0:
                    break;
            }

            //driver.FindElement(By.Id("dthreev")).Click();
            // here we UNselect TSC
            driver.FindElement(By.XPath("//form[@id='select_form']/div/div[2]/div[3]/div[2]/div[7]/div[2]/span")).Click();
            // here we UNselect SAF
            driver.FindElement(By.XPath("//form[@id='select_form']/div/div[2]/div[3]/div[2]/div[7]/span")).Click();

            //query.SendKeys(Keys.Space);

            //driver.FindElement(By.Name("include-driver-updates")).Click();

            // end of selection Addons
            query = driver.FindElement(By.XPath("(//input[@value=' '])[4]"));
            query.SendKeys(Keys.Enter);

            driver.FindElement(By.Id("form_name")).Clear();
            driver.FindElement(By.Id("form_name")).SendKeys("max qa");
            driver.FindElement(By.Id("form_email")).Clear();
            driver.FindElement(By.Id("form_email")).SendKeys("*****@*****.**");
            driver.FindElement(By.Id("form_postal_zip")).Clear();
            driver.FindElement(By.Id("form_postal_zip")).SendKeys("V8V1J9");
            driver.FindElement(By.Id("cc_num")).Clear();
            driver.FindElement(By.Id("cc_num")).SendKeys("4111111111111111");
            new SelectElement(driver.FindElement(By.Id("cc_month"))).SelectByText("04");
            driver.FindElement(By.CssSelector("option[value=\"04\"]")).Click();
            new SelectElement(driver.FindElement(By.Id("cc_year"))).SelectByText("2016");
            driver.FindElement(By.Id("cc")).Clear();
            driver.FindElement(By.Id("cc")).SendKeys("123");
            driver.FindElement(By.Id("submit-button")).Click();
            // ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]
            // ERROR: Caught exception [ERROR: Unsupported command [waitForFrameToLoad | receipt_body | 25000]]
            // ERROR: Caught exception [ERROR: Unsupported command [selectFrame | name=receipt_body | ]]

            // Making sure there is "Thank you " line in receipt
            try
            {
                //make sure it is in the main document right now
                driver.SwitchTo().DefaultContent();

                //find the outer frame, and use switch to frame method
                IWebElement Receipt_iFrame = driver.FindElement(By.Id("receipt_body"));
                driver.SwitchTo().Frame(Receipt_iFrame);

                string thanks_purchase_css_text = driver.FindElement(By.ClassName("thanks-purchase")).Text;
                Assert.IsTrue(Regex.IsMatch(thanks_purchase_css_text, "Thank.You.for.Your.Purchase!"));
            }
            catch (AssertionException e)
            {
                EmailAlert EA = new EmailAlert();
                EA.send_email_alert("Text not found :Thank You for Your Purchase" + e.Message);

                verificationErrors.Append("Text not found :Thank You for Your Purchase");
            }

            // Making sure we got a license on receipt
            try
            {
                //make sure it is in the main document right now
                driver.SwitchTo().DefaultContent();

                //find the outer frame, and use switch to frame method
                IWebElement Receipt_iFrame = driver.FindElement(By.Id("receipt_body"));
                driver.SwitchTo().Frame(Receipt_iFrame);

                Assert.IsTrue(Regex.IsMatch(driver.FindElement(By.CssSelector("body")).Text, ".*[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}.*"));

            }
            catch (AssertionException e)
            {
                EmailAlert EA = new EmailAlert();
                EA.send_email_alert("License Key Not found!" + e.Message);

                verificationErrors.Append("License Key Not found!");
            }
        }