private static void VendorManuallyCreatesTransaction(Action <RemoteWebDriver> vendorActionBeforeCreatingTransaction, Action <RemoteWebDriver> transactionSubmitHandler) { var vendorScenario = new WithAVendorDBScenario(); var vendorEmail = "*****@*****.**"; var vendorPassword = "******"; using (var site = new KeyHubWebDriver()) { string editVendorUserUrl = null; SiteUtil.CreateLocalAccount(site, vendorEmail, vendorPassword, firstBrowser => { firstBrowser.FindElementByCssSelector("a[href='/Account/LogOff']"); firstBrowser.Navigate().GoToUrl(site.UrlFor("/Account")); editVendorUserUrl = firstBrowser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href"); }); // Log in as admin to give the new vendor account vendor permissions using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor(editVendorUserUrl)); SiteUtil.SubmitLoginForm(browser, "admin", "password"); AdminUtil.CreateAccountRightsFor(browser, vendorEmail, ObjectTypes.Vendor, vendorScenario.VendorName); } using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, vendorEmail, vendorPassword); vendorActionBeforeCreatingTransaction(browser); browser.Navigate().GoToUrl(site.UrlFor("/")); browser.FindElementByCssSelector("a[href='/Transaction/Create']").Click(); SiteUtil.SetValueForChosenJQueryControlMulti(browser, "div#Transaction_SelectedSKUGuids_chzn", vendorScenario.SkuCode); browser.FindElementByCssSelector("form[action^='/Transaction/Create'] input[type='submit']").Click(); transactionSubmitHandler(browser); var appKeyValue = GetAppKeyFromTransactionCompletePage(browser); LicenseValidatorTests.AssertRemoteValidationCheckPasses( site, "example.com", appKeyValue, vendorScenario.FeatureCode, vendorScenario.PublicKeyXml); } } }
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); }); } } }