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 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); }
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); }