I am new to Atata and trying to send say a TAB key to a page and verify the contents which is higlighted (like say on a Google page) . I know we can do like below on say a page using Press
but could not figure a way to send the special keys like TAB , CTRL, ENTER and all
Go.To<ContactPage>().Press("abc");
You should use Keys
class from OpenQA.Selenium
namespace that contains all necessary keys, like below:
Go.To<ContactPage>().Press(Keys.Tab);
// Or
Go.To<ContactPage>().Press("abc" + Keys.Tab);
There is also unique Atata triggers feature. There are [PressEnter]
, [PressTab]
, [PressEscape]
and [PressKeys("abc")]
attributes. Trigger attribute will automatically press the specified key(s) after the value is set to control. For example:
public class SearchPage : Page<_>
{
[FindById("search-query")]
[PressEnter] // Adds trigger.
public TextInput<_> Query { get; private set; }
}
And then test:
Go.To<SearchPage>().
Query.Set("abc"); // Enter will be pressed after "abc" text is set.