diff --git a/Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs index 01acae2a2..0eebf4ba3 100644 --- a/Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs @@ -239,6 +239,12 @@ public static Task SetTaxonomyFieldByIndexAsync(this UITestContext context, stri return SetFieldDropdownByIndexAsync(context, baseSelector, index); } + public static Task SetTaxonomyFieldByTextAsync(this UITestContext context, string taxonomyId, string text) + { + var baseSelector = ByHelper.Css($".tags[data-taxonomy-content-item-id='{taxonomyId}']"); + return SetFieldDropdownByTextAsync(context, baseSelector, text); + } + public static async Task SetContentPickerByDisplayTextAsync(this UITestContext context, string part, string field, string text) { var searchUrl = context.Get(ByHelper.GetContentPickerSelector(part, field)).GetAttribute("data-search-url"); @@ -275,6 +281,20 @@ private static async Task SetFieldDropdownByIndexAsync(UITestContext context, By await context.ClickReliablyOnAsync(byItem); } + private static async Task SetFieldDropdownByTextAsync(UITestContext context, By baseSelector, string text) + { + var byItem = baseSelector + .Then(By.XPath($"//span[contains(@class,'multiselect__option')]//span[text() = '{text}']")) + .Visible(); + + while (!context.Exists(byItem.Safely())) + { + await context.ClickReliablyOnAsync(baseSelector.Then(By.CssSelector(".multiselect__select"))); + } + + await context.ClickReliablyOnAsync(byItem); + } + /// /// A convenience method that merges and so the