How to perform the navigation to the page by dynamic/parameterized URL.
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}
.
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}");
}
}
Go.To(GoogleSearchPage.WithQuery("test"));
Go.To<GoogleSearchPage>();