Ejemplo n.º 1
0
 private static List <string> GetDropdownOptions(IWebDriver driver, string dropdownId)
 {
     return(new SelectElement(HtmlElementHelper.FindElementById(driver, dropdownId))
            .Options
            .Select(opt => opt.Text)
            .ToList());
 }
Ejemplo n.º 2
0
 public void ThenICanSeeValueForId(string value, string elementId)
 {
     WithErrorLogging(() =>
     {
         Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, elementId).Text);
     });
 }
Ejemplo n.º 3
0
 public void WhenIClickOnTheLink(string linkLabel)
 {
     WithErrorLogging(() =>
     {
         HtmlElementHelper.FindElementByXpath(Browser, $"//a[contains(.,'{linkLabel}')]").Click();
     });
 }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 public void WhenIClickOn(string elementId)
 {
     WithErrorLogging(() =>
     {
         var button = HtmlElementHelper.FindElementById(Browser, elementId);
         button.Click();
     });
 }
Ejemplo n.º 6
0
 public void ThenICanSeeValueInTheOverviewSection(string value, string section)
 {
     WithErrorLogging(() =>
     {
         var sectionId = HtmlElementHelper.GetSectionIdFromSection(section);
         Assert.Contains(value, HtmlElementHelper.FindElementById(Browser, sectionId).Text);
     });
 }
Ejemplo n.º 7
0
 public void ThenAlertIsPresent(string alertTitle)
 {
     WithErrorLogging(() =>
     {
         var alerts = HtmlElementHelper.FindElementsByXpath(Browser, "//*[contains(@id, 'alert-')]");
         Assert.NotNull(alerts.SingleOrDefault(a => a.Text.Contains(alertTitle)));
     });
 }
Ejemplo n.º 8
0
 public void ClickOnTheNavigationBar(string label)
 {
     WithErrorLogging(() =>
     {
         var pageLink = HtmlElementHelper.FindElementByXpath(Browser, $"//*[@id='navigation-side-menu']/li[contains(.,'{label}')]/a");
         pageLink.Click();
     });
 }
Ejemplo n.º 9
0
 public void ThenICanSeeTheError(string errorMessage)
 {
     WithErrorLogging(() =>
     {
         var errorSection = HtmlElementHelper.FindElementByXpath(Browser, "//*[@class='nhsuk-error-summary']");
         Assert.Contains(errorMessage, errorSection.Text);
     });
 }
Ejemplo n.º 10
0
 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();
     });
 }
Ejemplo n.º 11
0
 public void WhenIExpandSection(string sectionId)
 {
     WithErrorLogging(() =>
     {
         var element = HtmlElementHelper.FindElementById(Browser, sectionId).FindElement(By.TagName("summary"));
         element.Click();
     });
 }
Ejemplo n.º 12
0
 public void GivenIChooseToLogInWithDifferentAccount()
 {
     WithErrorLogging(() =>
     {
         Browser.Navigate().GoToUrl($"{Settings.EnvironmentConfig.RootUriString}");
         HtmlElementHelper.FindElementById(Browser, "otherTile").Click();
     });
 }
Ejemplo n.º 13
0
 public void ThenLinkIsPresentOnOverviewSection(string linkText, string section)
 {
     WithErrorLogging(() =>
     {
         var sectionId = HtmlElementHelper.GetSectionIdFromSection(section);
         var linkId    = $"{sectionId}-{linkText}-link";
         Assert.NotNull(HtmlElementHelper.FindElementById(Browser, linkId));
     });
 }
Ejemplo n.º 14
0
 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(" ", ""));
     });
 }
Ejemplo n.º 15
0
 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);
     });
 }
Ejemplo n.º 16
0
 public void ThenICannotSeeTheElement(string elementId)
 {
     WithErrorLogging(() =>
     {
         SetImplicitWait(TimeSpan.FromSeconds(1));
         Assert.Empty(HtmlElementHelper.FindElementsById(Browser, elementId));
         SetImplicitWait(Settings.ImplicitWait);
     });
 }
Ejemplo n.º 17
0
 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);
     });
 }
Ejemplo n.º 18
0
 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();
     });
 }
Ejemplo n.º 19
0
 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);
     });
 }
Ejemplo n.º 20
0
 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");
     });
 }
Ejemplo n.º 21
0
 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);
     });
 }
Ejemplo n.º 22
0
 public void WhenISelectRadioOrCheckbox(string elementId)
 {
     WithErrorLogging(() =>
     {
         var element = HtmlElementHelper.FindElementById(Browser, elementId);
         if (!element.Selected)
         {
             element.Click();
         }
     });
 }
Ejemplo n.º 23
0
 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");
     });
 }
Ejemplo n.º 24
0
 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));
        }
Ejemplo n.º 26
0
        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);
     }
 }
Ejemplo n.º 28
0
        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);
            }
        }
Ejemplo n.º 29
0
 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());
     }
 }
Ejemplo n.º 30
0
        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);
                }
            });
        }