Update for Atata v2.2+
New methods were added in Atata v2.2.0 to Go
class:
Go.ToNewWindow<TPage>(...)
Go.ToNewWindowAsTab<TPage>(...)
Solution for older Atata version
Apparently CTRL+T combination doesn't work anymore for chromedriver. But we can use window.open()
JavaScript which also opens new tab.
AtataContext.Current.Driver.ExecuteScript("window.open()");
// You also need to switch to newly opened tab.
Go.ToNextWindow<OrdinaryPage>(); // Set the type of your page object instead of OrdinaryPage.
Go.ToUrl("/someurl"); // Set URL.
You can also extract this code block to a method:
public static TPage CreateAndSwitchToNewTab<TPage>(string url)
where TPage : Page<TPage>
{
AtataContext.Current.Driver.ExecuteScript("window.open()");
var page = Go.ToNextWindow<TPage>();
Go.ToUrl(url);
return page;
}
And use it in tests in a form of:
CreateAndSwitchToNewTab<ProductsPage>("/products")
.PageTitle.Should.Contain("Products");