Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The new WatiN 2.0 beta 1 does offer some base classes to help you structure test classes.</p> <p>It basically comes down to having a class for each page (inheriting the WatiN.Core.Page class). In these page classes you add properties for each control you want to access. Something like:</p> <pre><code>public Button OkButton { get { return Document.Button("okbuttonId"); } </code></pre> <p>and you can create methods to wrap some more complicated actions an a page. For instance:</p> <pre><code>public void AddPerson(string name, string email) { /// logic goes here tp click on NewButton, set the textfields and click on OkButton } </code></pre> <p>These page classes offer the advantage of defining your elements in one place.</p> <p>In your test code you can create a page class as follows:</p> <pre><code>using(var ie = new IE("www.somedomain.com/person")) { var page = ie.Page&lt;PersonDetailPage&gt;(); page.AddPerson("J. Doe", "jdoe@example.com"); // Do some Assert } </code></pre> <p>Another interesting base class to help you structure your code is the Control class. When you use ASP you'll use controls which will not render to just one html element in the rendered page. Instead it will often be a construct of elements contained in a Div element. When creating your own control class and inherit Control you'll be able to wrap the controls (html) internals and behavior. This makes it very easy to reuse the control in your page classes. Following an example on how to instantiate a control:</p> <pre><code>var calendar = Document.Control&lt;CalendarControl&gt;("calendarId"); </code></pre> <p>Hope this gives you some insight in how you can structure your Pages and controls.</p> <p>Jeroen</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload