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 OneTimeTearDown()
        {
            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(),'Taxes')]")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Tax Classes')]")).Click();
            MyDriver.FindElement(By.XPath("//td[contains(text(), 'Taxable Goods')]/following-sibling::td/a")).Click();;
            foreach (var item in MyDriver.FindElements(By.CssSelector("select[name$='[tax_rate_id]']")))
            {
                SelectElement Select = new SelectElement(item);
                string        Text   = Select.SelectedOption.Text;
                string        Name;
                if (Text == "PercentageTestTax" || Text == "FixedTestTax")
                {
                    Name = item.GetAttribute("name");
                    string quiery = "//select[@name='" + Name + "']/parent::td/following-sibling::td/button[@data-original-title='Remove']";
                    MyDriver.FindElement(By.XPath(quiery)).Click();
                }
            }
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Save']")).Click();

            MyDriver.FindElement(By.Id("menu-system")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Tax Rates')]")).Click();
            foreach (var item in MyDriver.FindElements(By.XPath("//td[contains(text(),'FixedTestTax')]/preceding-sibling::td/input")))
            {
                item.Click();
            }
            foreach (var item in MyDriver.FindElements(By.XPath("//td[contains(text(),'PercentageTestTax')]/preceding-sibling::td/input")))
            {
                item.Click();
            }
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Delete']")).Click();
            MyDriver.SwitchTo().Alert().Accept();

            MyDriver.FindElement(By.Id("menu-system")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Geo Zones')]")).Click();
            foreach (var item in MyDriver.FindElements(By.XPath("//td[contains(text(),'UA Tax Zone')]/preceding-sibling::td/input")))
            {
                item.Click();
            }
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Delete']")).Click();
            MyDriver.SwitchTo().Alert().Accept();

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

            MyDriver.Quit();
        }
Ejemplo n.º 3
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 OneTimeSetup()
        {
            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(),'Geo Zones')]")).Click();

            MyDriver.FindElement(By.CssSelector("a[data-original-title='Add New']")).Click();
            MyDriver.FindElement(By.Id("input-name")).SendKeys("UA Tax Zone");
            MyDriver.FindElement(By.Id("input-description")).SendKeys("Special Eco Taxes");
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Add Geo Zone']")).Click();
            SelectElement Country = new SelectElement(MyDriver.FindElement(By.Name("zone_to_geo_zone[0][country_id]")));

            Country.SelectByText("Ukraine");
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Save']")).Click();

            MyDriver.FindElement(By.Id("menu-system")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Taxes')]")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Tax Rates')]")).Click();
            MyDriver.FindElement(By.CssSelector("a[data-original-title='Add New']")).Click();
            MyDriver.FindElement(By.Id("input-name")).SendKeys("FixedTestTax");
            MyDriver.FindElement(By.Id("input-rate")).SendKeys("2");
            SelectElement FixedTaxType = new SelectElement(MyDriver.FindElement(By.Id("input-type")));

            FixedTaxType.SelectByText("Fixed Amount");
            SelectElement FixedGeoZone = new SelectElement(MyDriver.FindElement(By.Id("input-geo-zone")));

            FixedGeoZone.SelectByText("UA Tax Zone");
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Save']")).Click();

            MyDriver.FindElement(By.CssSelector("a[data-original-title='Add New']")).Click();
            MyDriver.FindElement(By.Id("input-name")).SendKeys("PercentageTestTax");
            MyDriver.FindElement(By.Id("input-rate")).SendKeys("5");
            SelectElement PercentageTaxType = new SelectElement(MyDriver.FindElement(By.Id("input-type")));

            PercentageTaxType.SelectByText("Percentage");
            SelectElement PercentageGeoZone = new SelectElement(MyDriver.FindElement(By.Id("input-geo-zone")));

            PercentageGeoZone.SelectByText("UA Tax Zone");
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Save']")).Click();

            MyDriver.FindElement(By.Id("menu-system")).Click();
            MyDriver.FindElement(By.XPath("//a[contains(text(),'Tax Classes')]")).Click();
            MyDriver.FindElement(By.XPath("//td[contains(text(), 'Taxable Goods')]/following-sibling::td/a")).Click();
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Add Rule']")).Click();
            var           AllSelects     = MyDriver.FindElements(By.CssSelector("#tax-rule select"));
            SelectElement FixedTaxRateId = new SelectElement(MyDriver.FindElement(By.CssSelector($"#tax-rule-row{AllSelects.Count / 2 - 1} select[name = 'tax_rule[{AllSelects.Count / 2 - 1}][tax_rate_id]']")));

            FixedTaxRateId.SelectByText("FixedTestTax");
            SelectElement FixedTaxBased = new SelectElement(MyDriver.FindElement(By.CssSelector($"#tax-rule-row{AllSelects.Count / 2 - 1} select[name = 'tax_rule[{AllSelects.Count / 2 - 1}][based]']")));

            FixedTaxBased.SelectByText("Shipping Address");
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Add Rule']")).Click();
            SelectElement PercentageTaxRateId = new SelectElement(MyDriver.FindElement(By.CssSelector($"#tax-rule-row{AllSelects.Count / 2} select[name = 'tax_rule[{AllSelects.Count / 2}][tax_rate_id]']")));

            PercentageTaxRateId.SelectByText("PercentageTestTax");
            SelectElement PercentageTaxBased = new SelectElement(MyDriver.FindElement(By.CssSelector($"#tax-rule-row{AllSelects.Count / 2} select[name = 'tax_rule[{AllSelects.Count / 2}][based]']")));

            PercentageTaxBased.SelectByText("Shipping Address");
            MyDriver.FindElement(By.CssSelector("button[data-original-title='Save']")).Click();

            ServiceMethodsSet.UserLogIn(MyDriver, "*****@*****.**", "12121212");
            ServiceMethodsSet.AddProductToShoppingCart(MyDriver);

            MyDriver.FindElement(By.CssSelector("a[title='Shopping Cart']")).Click();
        }