public void SetUp() { MyDriver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); MyDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); MyDriver.Navigate().GoToUrl(@"http://192.168.17.128/opencart/upload/"); MyDriver.Manage().Window.Maximize(); ServiceMethodsSet.UserLogIn(MyDriver, "*****@*****.**", "12121212"); MyDriver.FindElement(By.XPath("//a[text()='Phones & PDAs']")).Click(); MyDriver.FindElement(By.CssSelector(".product-layout .fa.fa-shopping-cart")).Click(); MyDriver.FindElement(By.CssSelector("a[title='Shopping Cart']")).Click(); MyDriver.FindElement(By.CssSelector("a[href='#collapse-shipping']")).Click(); SelectElement Country = new SelectElement(MyDriver.FindElement(By.Id("input-country"))); Country.SelectByText("United Kingdom"); SelectElement Zone = new SelectElement(MyDriver.FindElement(By.Id("input-zone"))); Zone.SelectByText("Aberdeen"); MyDriver.FindElement(By.Id("input-postcode")).Clear(); MyDriver.FindElement(By.Id("input-postcode")).SendKeys("123456"); MyDriver.FindElement(By.Id("button-quote")).Click(); }
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(); }