public void Setup(KeyHubWebDriver site, bool canDeleteManualDomainsOfLicense = true) { using (var browser = BrowserUtil.GetBrowser()) { base.Setup(site); browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, UserEmail, UserPassword); VendorUtil.CreatePrivateKey(browser, VendorName); VendorUtil.CreateFeature(browser, "first feature", VendorName); VendorUtil.CreateFeature(browser, "second feature", VendorName); VendorUtil.CreateSku(browser, "first sku", VendorName, "first feature", canDeleteManualDomainsOfLicense); VendorUtil.CreateSku(browser, "second sku", VendorName, "second feature", canDeleteManualDomainsOfLicense); // Create a Customer var customerName = VendorUtil.CreateCustomer(browser); // Create a License VendorUtil.CreateLicense(browser, "first sku", customerName); VendorUtil.CreateLicense(browser, "second sku", customerName); } }
public void VendorCanEditAFeature() { using (var site = new KeyHubWebDriver()) { var scenario = new WithAVendorScenario(); scenario.Setup(site); using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, scenario.UserEmail, scenario.UserPassword); VendorUtil.CreateFeature(browser, "first feature", scenario.VendorName); var featureRow = browser.FindElement(By.XPath("//td[contains(text(),'first feature')]/ancestor::tr")); featureRow.FindElement(By.CssSelector("a[href^='/Feature/Edit']")).Click(); var nameInput = browser.FindElementByCssSelector("#Feature_FeatureName"); nameInput.Clear(); nameInput.SendKeys("second name"); browser.FindElementByCssSelector("form[action^='/Feature/Edit'] input[type='submit']").Click(); browser.FindElementByCssSelector(".success"); browser.FindElement(By.XPath("//td[contains(text(),'second name')]")); } } }
public void VendorCanRenameAndRemovePrivateKeys() { using (var site = new KeyHubWebDriver()) { var scenario = new WithAVendorScenario(); scenario.Setup(site); using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, scenario.UserEmail, scenario.UserPassword); var privateKeyName = VendorUtil.CreatePrivateKey(browser, scenario.VendorName); var privateKeyRow = browser.FindElementByXPath("//td[contains(text(),'" + privateKeyName + "')]/ancestor::tr"); privateKeyRow.FindElement((By.CssSelector("a[href^='/PrivateKey/Edit']"))).Click(); var nameInput = browser.FindElementByCssSelector("input#PrivateKey_DisplayName"); nameInput.Clear(); nameInput.SendKeys("second name"); browser.FindElementByCssSelector("form[action^='/PrivateKey/Edit'] input[type='submit']").Click(); privateKeyRow = browser.FindElementByXPath("//td[contains(text(),'second name')]/ancestor::tr"); Assert.Equal(1, browser.FindElementsByCssSelector(".private-key-list").Count()); Assert.Equal(1, browser.FindElementsByCssSelector(".private-key-list tbody tr").Count()); privateKeyRow.FindElement((By.CssSelector("a[href^='/PrivateKey/Remove']"))).Click(); browser.FindElementByCssSelector("form[action^='/PrivateKey/Remove'] input[type='submit']").Click(); Assert.Equal(1, browser.FindElementsByCssSelector(".private-key-list").Count()); Assert.Equal(0, browser.FindElementsByCssSelector(".private-key-list tbody tr").Count()); } } }
public void AdminShouldBeAbleToAddAndRemoveUserRights() { using (var site = new KeyHubWebDriver()) { string userEmail = "*****@*****.**"; using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); browser.FindElementByCssSelector("a[href^='/Account/Register']").Click(); SiteUtil.SubmitRegistrationForm(browser, userEmail, "password"); SiteUtil.WaitUntilUserIsLoggedIn(browser); browser.FindElementByCssSelector("a[href^='/Account']").Click(); browser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href"); } using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, "admin", "password"); var customerName = VendorUtil.CreateCustomer(browser); AdminUtil.CreateAccountRightsFor(browser, userEmail, ObjectTypes.Customer, customerName); browser.FindElementByCssSelector(".account-rights-table"); var accountRights = browser.FindElementsByCssSelector(".account-rights-table tbody tr"); Assert.Equal(1, accountRights.Count()); Assert.Contains(customerName, accountRights.First().Text); accountRights.First().FindElement(By.CssSelector("a[href^='/AccountRights/Delete']")).Click(); browser.FindElementByCssSelector("input[value='Confirm Delete']").Click(); new WebDriverWait(browser, TimeSpan.FromSeconds(2)).Until(waitBrowser => { return(browser.FindElementByCssSelector(".account-rights-table") != null && browser.FindElementsByCssSelector(".account-rights-table tbody tr").Count() == 0); }); } } }
public void VendorCanManuallyCreateTransactionForExistingCustomers() { string purchasingCustomer = "purchasing customer name"; string owningCustomer = "owning customer name"; VendorManuallyCreatesTransaction(browser => { VendorUtil.CreateCustomer(browser, purchasingCustomer); VendorUtil.CreateCustomer(browser, owningCustomer); }, browser => { browser.FindElementByCssSelector("#cb_ExistingPurchasingCustomer").Click(); SiteUtil.SetValueForChosenJQueryControl(browser, "#PurchasingCustomerId_chzn", purchasingCustomer); browser.FindElementByCssSelector("#cb_OwningCustomerIsPurchasingCustomerId").Click(); browser.FindElementByCssSelector("#cb_ExistingOwningCustomer").Click(); SiteUtil.SetValueForChosenJQueryControl(browser, "#OwningCustomerId_chzn", owningCustomer); browser.FindElementByCssSelector("form[action^='/Transaction/Checkout'] input[type=submit]").Click(); }); }