private static List <string> GetDropdownOptions(IWebDriver driver, string dropdownId) { return(new SelectElement(HtmlElementHelper.FindElementById(driver, dropdownId)) .Options .Select(opt => opt.Text) .ToList()); }
public void ThenICanSeeValueForId(string value, string elementId) { WithErrorLogging(() => { Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, elementId).Text); }); }
public void WhenIClickOnTheLink(string linkLabel) { WithErrorLogging(() => { HtmlElementHelper.FindElementByXpath(Browser, $"//a[contains(.,'{linkLabel}')]").Click(); }); }
public UIElement(string htmlTag, bool isSvg) { Initialize(); _gcHandle = GCHandle.Alloc(this, GCHandleType.Weak); _isFrameworkElement = this is FrameworkElement; var type = GetType(); var tag = HtmlElementHelper.GetHtmlTag(type, htmlTag); HtmlTag = tag.Name; Handle = GCHandle.ToIntPtr(_gcHandle); HtmlId = Handle; if (isSvg) { _wasmConfig |= WasmConfig.IsSvg; } if (tag.IsExternallyDefined) { _wasmConfig |= WasmConfig.IsExternalElement; } Uno.UI.Xaml.WindowManagerInterop.CreateContent( htmlId: HtmlId, htmlTag: HtmlTag, handle: Handle, uiElementRegistrationId: UIElementNativeRegistrar.GetForType(type), htmlTagIsSvg: HtmlTagIsSvg, isFocusable: false ); InitializePointers(); UpdateHitTest(); }
public void WhenIClickOn(string elementId) { WithErrorLogging(() => { var button = HtmlElementHelper.FindElementById(Browser, elementId); button.Click(); }); }
public void ThenICanSeeValueInTheOverviewSection(string value, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, sectionId).Text); }); }
public void ThenAlertIsPresent(string alertTitle) { WithErrorLogging(() => { var alerts = HtmlElementHelper.FindElementsByXpath(Browser, "//*[contains(@id, 'alert-')]"); Assert.NotNull(alerts.SingleOrDefault(a => a.Text.Contains(alertTitle))); }); }
public void ClickOnTheNavigationBar(string label) { WithErrorLogging(() => { var pageLink = HtmlElementHelper.FindElementByXpath(Browser, $"//*[@id='navigation-side-menu']/li[contains(.,'{label}')]/a"); pageLink.Click(); }); }
public void ThenICanSeeTheError(string errorMessage) { WithErrorLogging(() => { var errorSection = HtmlElementHelper.FindElementByXpath(Browser, "//*[@class='nhsuk-error-summary']"); Assert.Contains(errorMessage, errorSection.Text); }); }
public void WhenITakeActionOnAlert(string title) { WithErrorLogging(() => { var alert = HtmlElementHelper.FindElementsByXpath(Browser, "//*[contains(@id, 'alert-')]").Single(a => a.Text.Contains(title)); alert.FindElement(By.LinkText("Take action")).Click(); }); }
public void WhenIExpandSection(string sectionId) { WithErrorLogging(() => { var element = HtmlElementHelper.FindElementById(Browser, sectionId).FindElement(By.TagName("summary")); element.Click(); }); }
public void GivenIChooseToLogInWithDifferentAccount() { WithErrorLogging(() => { Browser.Navigate().GoToUrl($"{Settings.EnvironmentConfig.RootUriString}"); HtmlElementHelper.FindElementById(Browser, "otherTile").Click(); }); }
public void ThenLinkIsPresentOnOverviewSection(string linkText, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var linkId = $"{sectionId}-{linkText}-link"; Assert.NotNull(HtmlElementHelper.FindElementById(Browser, linkId)); }); }
public void ThenICanNoValueForFieldInTheOverviewSection(string field, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var htmlId = $"{sectionId}-{field}"; Assert.Empty(HtmlElementHelper.FindElementById(Browser, htmlId).Text.Replace(" ", "")); }); }
public void ThenICanSeeValueForFieldInTheOverviewSection(string value, string field, string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var htmlId = $"{sectionId}-{field}"; Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, htmlId).Text); }); }
public void ThenICannotSeeTheElement(string elementId) { WithErrorLogging(() => { SetImplicitWait(TimeSpan.FromSeconds(1)); Assert.Empty(HtmlElementHelper.FindElementsById(Browser, elementId)); SetImplicitWait(Settings.ImplicitWait); }); }
public void ThenICanSeeCorrectTitlesForTable(string tableId) { WithErrorLogging(() => { var tableColumnTitles = HtmlElementHelper.FindElementById(Browser, tableId).FindElement(By.TagName("thead")) .FindElements(By.TagName("th")).Select(title => title.Text).ToArray(); var expectedTitles = GetExpectedColumnsTitlesForTable(tableId); Assert.Equal(tableColumnTitles.Select(titles => titles.Replace("\n", "").Replace("\r", "")), expectedTitles); }); }
public void WhenIGoToEditTheSection(string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var link = Browser.FindElement(By.Id($"{sectionId}-title")) .FindElement(By.LinkText("Edit")); link.Click(); }); }
public void ThenICanSeeTheCorrectLabelsForOverviewSection(string section) { WithErrorLogging(() => { var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var expectedLabels = GetExpectedLabels(section); var actualLabels = HtmlElementHelper.FindElementById(Browser, sectionId).FindElements(By.ClassName("notification-details-label")) .Select(label => label.Text).ToArray(); Assert.Equal(expectedLabels, actualLabels); }); }
public void WhenIRemoveFromInputList(string inputId) { WithErrorLogging(() => { var inputElement = HtmlElementHelper.FindElementById(Browser, inputId); inputElement.Click(); inputElement.SendKeys(Keys.Control + "a"); inputElement.SendKeys(Keys.Delete); inputElement.SendKeys("\t"); }); }
public void ThenLinkIsNotPresentOnOverviewSection(string linkText, string section) { WithErrorLogging(() => { SetImplicitWait(TimeSpan.FromSeconds(1)); var sectionId = HtmlElementHelper.GetSectionIdFromSection(section); var linkId = $"{sectionId}-{linkText}-link"; Assert.Empty(HtmlElementHelper.FindElementsById(Browser, linkId)); SetImplicitWait(Settings.ImplicitWait); }); }
public void WhenISelectRadioOrCheckbox(string elementId) { WithErrorLogging(() => { var element = HtmlElementHelper.FindElementById(Browser, elementId); if (!element.Selected) { element.Click(); } }); }
public void WhenISelectFromInputList(string value, string inputListId) { WithErrorLogging(() => { var inputList = HtmlElementHelper.FindElementById(Browser, inputListId); inputList.Click(); inputList.SendKeys(Keys.Control + "a"); inputList.SendKeys(Keys.Delete); inputList.SendKeys(value); HtmlElementHelper.FindElementById(Browser, inputListId + "__option--0").Click(); inputList.SendKeys("\t"); }); }
public void ThenICanSeeTheWarningForId(string warningMessage, string warningId) { WithErrorLogging(() => { var warningElement = HtmlElementHelper.FindElementById(Browser, warningId); try { var wait = new WebDriverWait(Browser, Settings.ImplicitWait); wait.Until(ExpectedConditions.TextToBePresentInElement(warningElement, warningMessage)); } catch (WebDriverTimeoutException) { Assert.Contains(warningElement.Text, warningMessage); } }); }
public HttpResponseMessage GetChartElement(Guid formId, string controlId, Guid?threadId = null) { sysBpmsDynamicForm dynamicForm = new DynamicFormService().GetInfo(formId); ChartHtml control = (ChartHtml)dynamicForm.FindControl(controlId); EngineSharedModel engineSharedModel = dynamicForm.ProcessId.HasValue ? new EngineSharedModel(threadId, dynamicForm.ProcessId, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId) : new EngineSharedModel(dynamicForm.ApplicationPageID.Value, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId); control.Helper = HtmlElementHelper.MakeModel(engineSharedModel, new UnitOfWork(), HtmlElementHelperModel.e_FormAction.Onload, dynamicForm); control.FillData(); return(Request.CreateResponse(HttpStatusCode.OK, control)); }
public static IHtmlContent FormatHtmlElementHtml(this IHtmlHelper htmlHelper, IElementView <HtmlElementSettings, HtmlElementContent> view) { if (string.IsNullOrWhiteSpace(view.Content.FormattedHtml)) { return(new HtmlString(string.Empty)); } IUrlHelper urlHelper = new UrlHelper(htmlHelper.ViewContext); HtmlElementHelper helper = new HtmlElementHelper(view, urlHelper); IStringUtilities utilitites = new StringUtilities(); string html = utilitites.BlockReplace(view.Content.FormattedHtml, "[[{", "}]]", helper.Replace); return(new HtmlString(html)); }
public object GetValue(Guid formId, string controlId, Guid?threadId = null) { using (DynamicFormService dynamicFormService = new DynamicFormService()) { sysBpmsDynamicForm dynamicForm = dynamicFormService.GetInfo(formId); BindingElementBase control = (BindingElementBase)dynamicForm.FindControl(controlId); EngineSharedModel engineSharedModel = dynamicForm.ProcessId.HasValue ? new EngineSharedModel(threadId, dynamicForm.ProcessId, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId) : new EngineSharedModel(dynamicForm.ApplicationPageID.Value, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId); UnitOfWork unitOfWork = new UnitOfWork(); control.Helper = HtmlElementHelper.MakeModel(engineSharedModel, unitOfWork, HtmlElementHelperModel.e_FormAction.Onload, dynamicForm); control.FillData(); return((control.Type == "HTMLCODE" || control.Type == "TITLE") ? control.Label : control.Value); } }
public void GetDataGridReport(Guid formId, string controlId, string format, Guid?threadId = null) { sysBpmsDynamicForm dynamicForm = new DynamicFormService().GetInfo(formId); DataGridHtml control = (DataGridHtml)dynamicForm.FindControl(controlId); EngineSharedModel engineSharedModel = dynamicForm.ProcessId.HasValue ? new EngineSharedModel(threadId, dynamicForm.ProcessId, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId) : new EngineSharedModel(dynamicForm.ApplicationPageID.Value, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId); control.Helper = HtmlElementHelper.MakeModel(engineSharedModel, new UnitOfWork(), HtmlElementHelperModel.e_FormAction.Onload, dynamicForm); control.FillDataItem(true); using (ReportEngine reportEngine = new ReportEngine(engineSharedModel, new UnitOfWork())) { reportEngine.PrintRdlcDataGrid(HttpContext.Current.Response, control, format == "pdf" ? DomainUtility.ReportExportType.PDF : DomainUtility.ReportExportType.Excel); } }
public List <ComboSearchItem> GetListElement(Guid formId, string controlId, Guid?threadId = null) { using (DynamicFormService dynamicFormService = new DynamicFormService()) { sysBpmsDynamicForm dynamicForm = dynamicFormService.GetInfo(formId); ListItemElementBase control = (ListItemElementBase)dynamicForm.FindControl(controlId); EngineSharedModel engineSharedModel = dynamicForm.ProcessId.HasValue ? new EngineSharedModel(threadId, dynamicForm.ProcessId, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId) : new EngineSharedModel(dynamicForm.ApplicationPageID.Value, base.MyRequest.GetList(base.IsEncrypted, base.ApiSessionId).ToList(), base.ClientUserName, base.ApiSessionId); UnitOfWork unitOfWork = new UnitOfWork(); control.Helper = HtmlElementHelper.MakeModel(engineSharedModel, unitOfWork, HtmlElementHelperModel.e_FormAction.Onload, dynamicForm); control.FillData(); return(control.Options.Select(item => new ComboSearchItem() { text = item.Label, id = item.Value, }).ToList()); } }
public void WhenIEnterValueIntoFieldWithId(string value, string elementId) { WithErrorLogging(() => { // In some scenarios, inputs only become clickable after an asynchronous event. // Consequently, we add a wait here to ensure that the input is ready. Browser.WaitUntilElementIsClickable(By.Id(elementId), Settings.ImplicitWait); var element = HtmlElementHelper.FindElementById(Browser, elementId); element.Click(); element.SendKeys(Keys.Control + "a"); element.SendKeys(Keys.Delete); element.SendKeys(value + "\t"); if (!Settings.IsHeadless) { Thread.Sleep(1000); } }); }