public void CheckCurrencyFormatOfPrice(string currency, string pattern)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            string Price = MyDriver.FindElement(By.XPath("//div[@id='content']//div[@class='col-sm-4']//li/h2")).Text.Trim();

            StringAssert.IsMatch(pattern, Price);
        }
        public void CheckFixedTaxHasTheSameValueAsInAdminPanel(string currency)
        {
            ServiceMethodsSet.AdminLogIn(MyDriver, "admin", "Lv414_Taqc");
            MyDriver.FindElement(By.Id("menu-system")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Localisation')]")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Currencies')]")).Click();

            decimal XRate = Decimal.Parse(MyDriver.FindElement(By.XPath($"//td[text()='{currency}']/following-sibling::td[@class='text-right'][count(*)=0]")).Text.Replace('.', ','));

            ServiceMethodsSet.AdminLogOut(MyDriver);

            MyDriver.Navigate().GoToUrl(@"http://192.168.17.128/opencart/upload/");
            MyDriver.FindElement(By.CssSelector("a[title='Shopping Cart']")).Click();

            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            ServiceMethodsSet.ChooseShippingDetails(MyDriver, "Ukraine", "L'vivs'ka Oblast'", "123456");

            int Quantity = Int32.Parse(MyDriver.FindElement(By.CssSelector("input[name^='quantity']")).GetAttribute("value"));

            FixedTestTax = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'FixedTestTax:')]/parent::td/following-sibling::td")).Text;
            decimal ActualFixedTestTaxValue   = Decimal.Parse(Regex.Match(FixedTestTax, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal ExpectedFixedTestTaxValue = Math.Round(2m * XRate * Quantity, 2);

            Console.WriteLine(ActualFixedTestTaxValue);
            Console.WriteLine(ExpectedFixedTestTaxValue);
            Assert.AreEqual(ExpectedFixedTestTaxValue, ActualFixedTestTaxValue);
        }
        public void CheckPriceIsPositiveNumber(string currency)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            decimal ActualResult = ServiceMethodsSet.GetPriceValue(MyDriver);

            Assert.IsTrue(ActualResult >= 0);
        }
Ejemplo n.º 4
0
        public void CheckCurrencyLabel(string currency, string pattern)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            string Actual = MyDriver.FindElement(By.CssSelector("button.btn.btn-link.dropdown-toggle")).Text;

            StringAssert.IsMatch(pattern, Actual);
        }
        public void CheckCurrencyFormatOfExTax(string currency, string pattern)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            string ExTaxAllText = MyDriver.FindElement(By.XPath("//div[@id='content']//div[@class='col-sm-4']//li/h2/../following-sibling::li[contains(text(), 'Ex Tax')]")).Text;
            int    СolщnIndex   = ExTaxAllText.IndexOf(":");
            string ExTax        = ExTaxAllText.Substring(СolщnIndex + 1).Trim();

            StringAssert.IsMatch(pattern, ExTax);
        }
        public void CheckCurrencyFormatOfOldPrice(string currency, string pattern)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            MyDriver.FindElement(By.Name("search")).Clear();
            MyDriver.FindElement(By.Name("search")).SendKeys("Canon EOS 5D");
            MyDriver.FindElement(By.CssSelector("#search button")).Click();
            MyDriver.FindElement(By.CssSelector(".caption a")).Click();
            string OLdPrice = MyDriver.FindElement(By.CssSelector("#content li>span[style]")).Text;

            StringAssert.IsMatch(pattern, OLdPrice);
        }
        public void CheckCorrectCalculationOfPersentageTax(string currency)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            ServiceMethodsSet.ChooseShippingDetails(MyDriver, "Ukraine", "L'vivs'ka Oblast'", "123456");
            SubTotal          = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'Sub-Total:')]/parent::td/following-sibling::td")).Text;
            FlatShippingRate  = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'Flat Shipping Rate:')]/parent::td/following-sibling::td")).Text;
            PercentageTestTax = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'PercentageTestTax:')]/parent::td/following-sibling::td")).Text;
            Total             = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[text()='Total:']/parent::td/following-sibling::td")).Text;

            decimal SubTotalValue = Decimal.Parse(Regex.Match(SubTotal, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal ActualPercentageTestTaxTaxValue = Decimal.Parse(Regex.Match(PercentageTestTax, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal FlatShippingRateValue           = Decimal.Parse(Regex.Match(FlatShippingRate, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal ExpectedPercentageTestTaxValue  = Math.Round((SubTotalValue + FlatShippingRateValue) * 0.05m, 2);

            Console.WriteLine(ActualPercentageTestTaxTaxValue);
            Console.WriteLine(ExpectedPercentageTestTaxValue);
            Assert.AreEqual(ExpectedPercentageTestTaxValue, ActualPercentageTestTaxTaxValue);
        }
        public void CheckCurrencyFormat(string currency, string pattern)
        {
            ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            ServiceMethodsSet.ChooseShippingDetails(MyDriver, "Ukraine", "L'vivs'ka Oblast'", "123456");

            SubTotal          = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'Sub-Total:')]/parent::td/following-sibling::td")).Text;
            FlatShippingRate  = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'Flat Shipping Rate:')]/parent::td/following-sibling::td")).Text;
            FixedTestTax      = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'FixedTestTax:')]/parent::td/following-sibling::td")).Text;
            PercentageTestTax = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'PercentageTestTax:')]/parent::td/following-sibling::td")).Text;
            Total             = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[text()='Total:']/parent::td/following-sibling::td")).Text;

            StringAssert.IsMatch(pattern, SubTotal);
            Console.WriteLine(SubTotal);
            StringAssert.IsMatch(pattern, Total);
            Console.WriteLine(Total);
            StringAssert.IsMatch(pattern, FixedTestTax);
            Console.WriteLine(FixedTestTax);
            StringAssert.IsMatch(pattern, PercentageTestTax);
            Console.WriteLine(PercentageTestTax);
        }
Ejemplo n.º 9
0
        public void Setup()
        {
            IWebDriver MyDriver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            MyDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            ServiceMethodsSet.AdminLogIn(MyDriver, "admin", "Lv414_Taqc");
            MyDriver.FindElement(By.Id("menu-system")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Localisation')]")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Currencies')]")).Click();

            EurRate = Decimal.Parse(MyDriver.FindElement(By.XPath("//td[text()='EUR']/following-sibling::td[@class='text-right'][count(*)=0]")).Text.Replace('.', ','));
            GbpRate = Decimal.Parse(MyDriver.FindElement(By.XPath("//td[text()='GBP']/following-sibling::td[@class='text-right'][count(*)=0]")).Text.Replace('.', ','));

            MyDriver.Navigate().GoToUrl(@"http://192.168.17.128/opencart/upload/");
            MyDriver.Manage().Window.Maximize();
            MyDriver.FindElement(By.CssSelector(".owl-wrapper-outer")).Click();
            ServiceMethodsSet.ChangeCurrency(MyDriver, "USD");
            UsdPrice = ServiceMethodsSet.GetPriceValue(MyDriver);
            ServiceMethodsSet.ChangeCurrency(MyDriver, "EUR");
            EurPrice = ServiceMethodsSet.GetPriceValue(MyDriver);
            ServiceMethodsSet.ChangeCurrency(MyDriver, "GBP");
            GbpPrice = ServiceMethodsSet.GetPriceValue(MyDriver);
            MyDriver.Quit();
        }
        public void CheckCorrectCulculationOfTotal(string currency)
        {
            MyDriver.Navigate().GoToUrl(@"http://192.168.17.128/opencart/upload/");
            MyDriver.FindElement(By.CssSelector("a[title='Shopping Cart']")).Click(); ServiceMethodsSet.ChangeCurrency(MyDriver, currency);
            ServiceMethodsSet.ChooseShippingDetails(MyDriver, "Ukraine", "L'vivs'ka Oblast'", "123456");

            string SubTotal          = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'Sub-Total:')]/parent::td/following-sibling::td")).Text;
            string FlatShippingRate  = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'Flat Shipping Rate:')]/parent::td/following-sibling::td")).Text;
            string PercentageTestTax = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'PercentageTestTax:')]/parent::td/following-sibling::td")).Text;
            string Total             = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[text()='Total:']/parent::td/following-sibling::td")).Text;
            string FixedTestTax      = MyDriver.FindElement(By.XPath("//div[@id='content']//strong[contains(text(),'FixedTestTax:')]/parent::td/following-sibling::td")).Text;

            decimal FixedTestTaxValue         = Decimal.Parse(Regex.Match(FixedTestTax, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal SubTotalValue             = Decimal.Parse(Regex.Match(SubTotal, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal PercentageTestTaxTaxValue = Decimal.Parse(Regex.Match(PercentageTestTax, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal FlatShippingRateValue     = Decimal.Parse(Regex.Match(FlatShippingRate, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal ActualTotalValue          = Decimal.Parse(Regex.Match(Total, @"\d+\.\d{2}").Value.Replace(".", ","));
            decimal ExpectedTotalValue        = SubTotalValue + FlatShippingRateValue + FixedTestTaxValue + PercentageTestTaxTaxValue;

            Console.WriteLine(ExpectedTotalValue);
            Console.WriteLine(ActualTotalValue);

            Assert.AreEqual(ExpectedTotalValue, ActualTotalValue);
        }