Actions
Page Objects tend to either perform actions or find items on the page. Seleno Page Objects provide a number of Actions and Locators that you can use.
Navigator
Used to perform actions that take you to another page, such as clicking a button or a link, or navigating to a URL. There is a strongly typed option to navigate with a controller expression using routing. Page Objects expose the Navigator class with the Navigate
property.
Navigate.To<RegisterPage>(By.LinkText("Register"));
Page Reader
Read values from the page using view model based strongly typed methods. Page Objects that extend Page<T>
expose the Page Reader class with the Read
property. For example, to read all fields into a new instance of the current model type (T
) in a page you can use the ModelFromPage
method:
var model = Read.ModelFromPage();
Read
is currently only available with the generically-typed page object for now, but if you want this functionality with non-generic page objects (by instead supplying strings for the id) then to add an issue to our Github site so we can prioritise it.
Page Writer
Write values to the page using view model based strongly typed methods. Page Objects that extend Page<T>
expose the Page Writer class with the Input
property. For example, to write all fields from a model of the current type (T
) from the form on a page you can use the Model
method:
Input.Model(modelInstanceToFillInFormUsing);
Input
is currently only available with the generically-typed page object for now, but if you want this functionality with non-generic page objects (by instead supplying strings for the id) then to add an issue to our Github site so we can prioritise it.
Script Executor
If none of the above meet your needs then you have the ultimate control by executing JavaScript with the Script Executor class. Page Objects expose the Script Executor class with the Execute
property.
return Execute.ScriptAndReturn<TReturn>(string.Format("$('#{0}').attr('{1}')",Id,attributeName));
Updated less than a minute ago