Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LMBQ-299: Adding SetTaxonomyFieldByTextAsync function #345

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
MZole marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// A convenience method that merges <see cref="ElementRetrievalUITestContextExtensions.Get"/> and <see
/// cref="NavigationWebElementExtensions.ClickReliablyAsync(IWebElement, UITestContext, int)"/> so the <paramref
Expand Down