private static void ChangeAndTestLocalization(IBrowserWrapper browser) { AssertUI.InnerTextEquals(browser.First("p"), "This comes from resource file!", false, true); // change language browser.Last("a").Click(); AssertUI.InnerTextEquals(browser.First("p"), "Tohle pochází z resource souboru!", false, true); }
private void TestLinkButton(IBrowserWrapper browser, string id, bool shouldBeEnabled, ref int currentPresses) { browser.First($"#{id}").Click(); if (shouldBeEnabled) { currentPresses++; } AssertUI.InnerTextEquals(browser.First("#linkbuttons-pressed"), currentPresses.ToString()); }
public static void CheckArticleCount(IBrowserWrapper browser, string repeaterUiId, int expectedCount) { var articles = browser.First($"div[data-ui='{repeaterUiId}']").FindElements("article[data-ui='test-article']"); if (articles.Count != expectedCount) { throw new UnexpectedElementStateException($"There should be only 2 article in the repeater. There are {articles.Count}"); } }
private void ValidateDefaultRouteLinkState(IBrowserWrapper browser, string suffix = "") { AssertUI.HyperLinkEquals(browser.First("#opt1_empty"), "FeatureSamples/ParameterBinding/OptionalParameterBinding" + suffix, UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt1_param_empty"), "FeatureSamples/ParameterBinding/OptionalParameterBinding" + suffix, UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt1_param_A2"), "FeatureSamples/ParameterBinding/OptionalParameterBinding" + suffix, UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt1_param_ID2"), "FeatureSamples/ParameterBinding/OptionalParameterBinding/4", UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt1_param_ID2A2"), "FeatureSamples/ParameterBinding/OptionalParameterBinding/5", UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt2_empty"), "FeatureSamples/ParameterBinding/OptionalParameterBinding2/300", UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt2_param_A"), "FeatureSamples/ParameterBinding/OptionalParameterBinding2/300", UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt2_param_2"), "FeatureSamples/ParameterBinding/OptionalParameterBinding2/3", UrlKind.Relative, UriComponents.PathAndQuery); AssertUI.HyperLinkEquals(browser.First("#opt2_param_ID2A2"), "FeatureSamples/ParameterBinding/OptionalParameterBinding/4", UrlKind.Relative, UriComponents.PathAndQuery); }
private void ReturnedFileDownload(IBrowserWrapper browser, string fileContent) { browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_ReturnedFile_ReturnedFileSample); var jsexec = browser.GetJavaScriptExecutor(); jsexec.ExecuteScript("window.downloadURL = \"\";"); jsexec.ExecuteScript("DotVVM.prototype.performRedirect = function(url){window.downloadURL = url};"); browser.First("textarea").SendKeys(fileContent); browser.First("input").SendKeys(Keys.Enter); var downloadURL = (string)jsexec.ExecuteScript("return window.downloadURL;"); Assert.IsNotNull(downloadURL); string returnedFile; using (var client = new WebClient()) { returnedFile = client.DownloadString(browser.GetAbsoluteUrl(downloadURL)); } Assert.AreEqual(fileContent, returnedFile); }
private void ValidatePostbackHandlersComplexSection(string sectionSelector, IBrowserWrapper browser) { IElementWrapper section = null; browser.WaitFor(() => { section = browser.First(sectionSelector); }, 2000, "Cannot find static commands section."); var index = browser.First("[data-ui=\"command-index\"]"); // confirm first section.ElementAt("input[type=button]", 0).Click(); AssertUI.AlertTextEquals(browser, "Confirmation 1"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "1"); // cancel second section.ElementAt("input[type=button]", 1).Click(); AssertUI.AlertTextEquals(browser, "Confirmation 1"); browser.ConfirmAlert(); browser.Wait(); AssertUI.AlertTextEquals(browser, "Confirmation 2"); browser.DismissAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "1"); // confirm second section.ElementAt("input[type=button]", 1).Click(); AssertUI.AlertTextEquals(browser, "Confirmation 1"); browser.ConfirmAlert(); browser.Wait(); AssertUI.AlertTextEquals(browser, "Confirmation 2"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "2"); // confirm third section.ElementAt("input[type=button]", 2).Click(); Assert.IsFalse(browser.HasAlert()); browser.Wait(); AssertUI.InnerTextEquals(index, "3"); // confirm fourth section.ElementAt("input[type=button]", 3).Click(); AssertUI.AlertTextEquals(browser, "Generated 1"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "4"); // confirm fifth section.ElementAt("input[type=button]", 4).Click(); AssertUI.AlertTextEquals(browser, "Generated 2"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "5"); // confirm conditional section.ElementAt("input[type=button]", 5).Click(); Assert.IsFalse(browser.HasAlert()); browser.Wait(); AssertUI.InnerTextEquals(index, "6"); browser.First("input[type=checkbox]").Click(); section.ElementAt("input[type=button]", 5).Click(); AssertUI.AlertTextEquals(browser, "Conditional 1"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "6"); browser.First("input[type=checkbox]").Click(); section.ElementAt("input[type=button]", 5).Click(); Assert.IsFalse(browser.HasAlert()); browser.Wait(); AssertUI.InnerTextEquals(index, "6"); browser.First("input[type=checkbox]").Click(); section.ElementAt("input[type=button]", 5).Click(); AssertUI.AlertTextEquals(browser, "Conditional 1"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "6"); //localization - resource binding in confirm postback handler message section.ElementAt("input[type=button]", 6).Click(); AssertUI.AlertTextEquals(browser, "EnglishValue"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "7"); browser.First("#ChangeLanguageCZ").Click(); browser.WaitFor(() => { index = browser.First("[data-ui=\"command-index\"]"); AssertUI.InnerTextEquals(index, "0"); }, 1500, "Redirect to CZ localization failed."); section = browser.First(sectionSelector); //ChangeLanguageEN section.ElementAt("input[type=button]", 6).Click(); AssertUI.AlertTextEquals(browser, "CzechValue"); browser.DismissAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "0"); section.ElementAt("input[type=button]", 6).Click(); AssertUI.AlertTextEquals(browser, "CzechValue"); browser.ConfirmAlert(); browser.Wait(); AssertUI.InnerTextEquals(index, "7"); }