Navigation to Page by Dynamic URL

How to perform the navigation to the page by dynamic/parameterized URL.

Given

Let’s use Google search page as example. For example we need to get to search results page by passing query text into URL. To make it work we need to build URL in such format: https://www.google.com/search?q={QUERY} .

Implementation

Assume that https://www.google.com/ is the BaseUrl of AtataContext.

using Atata;

namespace SampleApp.UITests
{
    using _ = GoogleSearchPage;

    [Url("/search")]
    public class GoogleSearchPage : Page<_>
    {
        public static _ WithQuery(string query) =>
            new _().AppendNavigationUrl($"?q={query}");
    }
}

Usage

With Query Parameter

Go.To(GoogleSearchPage.WithQuery("test"));

Without Query Parameter

Go.To<GoogleSearchPage>();