public void EnterAllGigyaSettings() { _driver.Navigate().GoToUrl(Config.Site1BaseURL + "umbraco#/gigya/gigyaTree/edit/-1"); Thread.Sleep(5000); _driver.Navigate().Refresh(); Thread.Sleep(5000); var model = new GigyaConfigSettings { ApiKey = Config.Site1ApiKey, ApplicationKey = Config.Site1ApplicationKey, ApplicationSecret = Config.Site1ApplicationSecret, DataCenter = Config.Site1DataCenter, LanguageFallback = Config.Site1LangFallback }; EnterGigyaSettings(model); model = new GigyaConfigSettings { ApiKey = Config.Site2ApiKey, ApplicationKey = Config.Site2ApplicationKey, ApplicationSecret = Config.Site2ApplicationSecret, DataCenter = Config.Site2DataCenter, LanguageFallback = Config.Site2LangFallback }; var tree = _driver.FindElement(By.CssSelector("#tree"), 5); tree.FindElement(By.PartialLinkText("Home (1)")).Click(); var inherited = _driver.FindElement(By.Id("Inherited"), 10); if (!string.IsNullOrEmpty(inherited.GetAttribute("checked"))) { inherited.Click(); } EnterGigyaSettings(model); }
private void EnterGigyaSettings(GigyaConfigSettings settings) { _driver.FindElement(By.Id("api-key"), 10).ClearAndSendKeys(settings.ApiKey); _driver.FindElement(By.Id("application-key")).ClearAndSendKeys(settings.ApplicationKey); IWebElement applicationSecretLabel = null; var applicationSecret = _driver.FindElement(By.Id("application-secret"), 2); if (applicationSecret == null || !applicationSecret.Displayed) { applicationSecretLabel = _driver.FindElement(By.XPath("//label[@for='application-secret']")); var buttons = applicationSecretLabel.FindElement(By.XPath("..")).FindElements(By.TagName("button")); foreach (var button in buttons) { if (button.Displayed) { // edit button is only one visible button.Click(); applicationSecret = _driver.FindElement(By.Id("application-secret"), 2); break; } } } applicationSecret.ClearAndSendKeys(settings.ApplicationSecret); _driver.FindElement(By.Id("data-center")).SendKeys(settings.DataCenter); _driver.FindElement(By.Id("language-fallback")).SendKeys(settings.LanguageFallback); _driver.FindElement(By.CssSelector("button[type=\"submit\"]")).Click(); var successAlert = _driver.FindElement(By.ClassName("alert-success"), 10); Assert.IsNotNull(successAlert, "Failed to save settings."); // wait for speech bubble to hide Thread.Sleep(7000); // refresh and make sure application secret is masked _driver.Navigate().Refresh(); applicationSecretLabel = _driver.FindElement(By.XPath("//label[@for='application-secret']"), 10); var applicationSecretValue = applicationSecretLabel.FindElement(By.XPath("..")).FindElement(By.CssSelector("span")).Text; var nonEncryptedValues = applicationSecretValue.Replace("*", string.Empty); Assert.AreEqual(nonEncryptedValues.Length, 4, "Should only be 4 non encrypted values."); // test invalid settings shows alert var saveButton = _driver.FindElement(By.CssSelector("button[type=\"submit\"]")); TestErrorShownForInvalidSetting(saveButton, _driver.FindElement(By.Id("api-key"), 10)); TestErrorShownForInvalidSetting(saveButton, _driver.FindElement(By.Id("application-key"), 10)); applicationSecret = _driver.FindElement(By.Id("application-secret"), 2); if (applicationSecret == null || !applicationSecret.Displayed) { applicationSecretLabel = _driver.FindElement(By.XPath("//label[@for='application-secret']")); var buttons = applicationSecretLabel.FindElement(By.XPath("..")).FindElements(By.TagName("button")); foreach (var button in buttons) { if (button.Displayed) { // edit button is only one visible button.Click(); applicationSecret = _driver.FindElement(By.Id("application-secret"), 2); break; } } } applicationSecret.ClearAndSendKeys(settings.ApplicationSecret); SaveSettingsAndCheckForError(saveButton); var dcs = new string[] { "EU", "RU", "US" }; var invalidDc = dcs.First(i => i != Config.Site1DataCenter); _driver.FindElement(By.Id("data-center")).SendKeys(invalidDc); SaveSettingsAndCheckForError(saveButton); }